Posts

Showing posts from May, 2012

using tsql split row into multiple rows -

i looking write script change table 1 table 2. table 1 accountno name other field 1 mr t , mrs m lambert xxx i need rewrite table 2 accountno split name other field 1 mr t lambert xxx 1 b mrs m lambert xxx if you, take scripting language of choice , write converter aid. me looks perl or ruby fit task quite nicely. for example, in ruby like: require 'active_record' activerecord::base.establish_connection('postgresql://localhost/db') sql = activerecord::base.connection sql.begin_db_transaction # fetch data source table sql.execute('select * source_table').each |source_row| # source_row hash of following form: # { 'col_name_1' => 'col_value_1', 'col_name_2' => ... } # prepare transformed rows array result in destination table transformed_rows = [ ] # make transformed rows need...

javascript - Empty elements in JS array declaration -

it's first question here, after have been reading years, nice me please. i'm having trouble array management in js/jq. i have array several elements, processed $.each function. want extract matching elements array , return array. reason (don't know if it's because array declaration, jquery.each function...) i'm having first empty element. i think i'm making more difficult understand it's, made jsfiddle. var arr = new array(); $.each([1,2,3], function(index,element){ if (element == 2){ arr[index] = element; } }); arr must have 1 element, arr.length returns 2 because first array slot empty. here fiddle http://jsfiddle.net/moay7y95/ i'm sure it's simple , little stupid thing, i've not been able find answer. thanks in advance! best solution: use .filter var arr = [1, 2, 3].filter(function(value){ return value == 2 }); if return value true, element included in returned array, otherwise ignored. pure...

html - How to upload image to a database using webmatrix 3? -

i have 2 different cshtml pages. 1 creating database , second 1 showing data. don't know how upload image. every time upload png file , says "4 : unable cast object of type 'system.string' type 'system.byte[]'." datatype in database image here code: @{ var productname=""; var productprice=""; var productexpiredate=""; var productdescription=""; var productimage=""; productname=request["pname"]; productprice=request["price"]; productexpiredate= request["expiredate"]; productdescription= request["description"]; productimage = request["image"]; if(ispost){ var sqlinsert = "insert productinfo (name, price, expiredate, description, image) values (@0,@1,@2,@3,@4)"; var db = database.open("product"); db.execute(sqlinsert, productname , productprice, productexpiredate, productdescription, productimage); //response.redirect(...

OrangeHRM Symfony(1.4) site moved from local to live server causing a page crash -

i moved site local live server. working fine on local server causing page crash on live server. have cleared cache. fine on local server , on live server except single page crash on live server error "an internal error occurred. please contact system administrator." when check logfile orangehrm.log inside symfony/log following message appears thu 14 may 2015 12:29:13 pm gst,102 [1376] error filter.exceptioncatcherfilter - uncaught exception: exception 'sfrenderexception' message 'the template "viewrequestsuccess.php" not exist or unreadable in "here should directory name empty(this added mention error point)".' in /var/zpanel/hostdata/some_app_name/public_html/hrm_something_com/symfony/cache/orangehrm/prod/config/config_core_compile.yml.php:2029 stack trace: #0 /var/zpanel/hostdata/some_app_name/public_html/hrm_something_com/symfony/cache/orangehrm/prod/config/config_core_compile.yml.php(3908): sfview->prerendercheck...

jquery datatable is slow if i use select box in each row -

i using jquery data table , each row having 2 select boxes in 2 cells. 1 select box having around 400 option values , select box having around 30 options values. rendering around 15 rows @ time. in case,rendering slow , hangs browser seconds. any solution fast performance? you delay filling select boxes until user clicks on them, way keep dom clean until need options. if options same across rows considder creating 1 select box , positioning on row user hovers mouse.

git - Github pages showing old code -

i have rudimentary understanding of github: know how create, add, commit, push , clone repositories. i've started exploring github pages host projects. latest project started in march , pushed gh-page. have since refractored , improved code , made quite few changes. on local server changes shown after pushing github , making new gh-page several times, still see old project. could please help. if shows non-fast-forward updates rejected , means local , remote repository out of sync because or else made changes upstream repo , possible cause of problem. try fetch , merge changes or use pull command. source: https://help.github.com/articles/dealing-with-non-fast-forward-errors if isn't problem, show errors when pushing? , project have multiple branches?

assembly - Matrix Multiplication in MIPS, Array Looping -

first time on stackoverflow, please forgive me if i'm doing wrong. trying create c code below in mips: void mm (int c[][], int a[][], int b[][]) { int i, j ,k; (i = 0; != 4; = + 1) (j = 0; j != 4; j = j + 1) (k = 0; k != 4; k = k + 1) c[i][j] = c[i][j] + a[i][k] * b[k][j] } here's mips code: .text main: j mm mm: la $a3, array_a # base address array_a loaded $a3 la $a1, array_b # base address array_b loaded $a1 la $a2, array_c # base address array_c loaded $a2 li $t1, 4 # $t1 = 4 (row-size , loop end) li $s0, 0 # = 0; initialize 1st loop loop1: li $s1, 0 # j = 0; restart 2nd loop loop2: li $s2, 0 # k = 0; restart 3rd loop sll $t2, $s0, 2 # $t2 = * 4 (size of row of c) addu $t2, $t2, $s1 # $t2 = * size(row) + j sll $t2, $t2, 2 # $t2 = byte offset of [i][j] addu $t2, $a2, $t2 # $t2 = byte offset of [i][j] lw $t4, 0($t2) # $t4 = 2 bytes of c[i][j] loop3: sll $t0, $s2, 2 # $t0 = k * 4 (size of row of b) addu $...

python - Cannot install html package with pip in virtualenv -

in root project folder have created virtual environment python 3.4 using following commands: $ virtualenv -p /library/frameworks/python.framework/versions/3.4/bin/python3.4 venv $ source venv/bin/activate now install packages pip project , do: $ venv/bin/pip install html and following error (full traceback except have replaced path '...'): collecting html using cached html-1.16.tar.gz complete output command python setup.py egg_info: traceback (most recent call last): file "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked attributeerror: 'module' object has no attribute '__path__' during handling of above exception, exception occurred: traceback (most recent call last): file "<string>", line 3, in <module> file ".../venv/lib/python3.4/site-packages/setuptools/__init__.py", line 11, in <module> setuptools.extension import exte...

java - Jboss 7 Destroy Singleton EJB -

@startup @singleton @accesstimeout(value = 0) public class myejb { @schedule(dayofweek = "*", hour = "*", minute = "*", second = "*/20", year = "*", persistent = false, info = "myejb job.................") @accesstimeout(value = 0) public void execute() { try { lgg.debug("starting..........."); thread.sleep(35000); lgg.debug("ending............."); } catch (interruptedexception e1) { } } i have following code. want stop(destroy) current ejb working after 20 second , start singltone ejb instance. how achieve that? this not possible. cannot safely force thread stop in jvm, , there no mechanism in ejb interrupt thread. best can cooperatively interrupt: call method on singleton notify wake (that is, change thread.sleep else countdownlatch). note, you'll need change default @lock or @concurrencymanagement allow bean reent...

javascript - Recommended Menu Sidebar to the Leftside of the Webpage -

i'm looking menu sidebar. a button should enable display or remove menu. when feel redo available button should show menu sidebar. the menu should located on left side. the menu should not affect remaining component. menu should acted independent. the menu should located in webpage when use vertical scroll. today, have problem find one. can recommend me? info: i'm using jquery , bootstrap here download page and here demo this library created plane jquery , bootstrap used on of projects , recommend you. hope helps.

c# - Format of the initialization string does not conform to the OLE DB specification -

i'm getting following error when trying read excel file using third-party component format of initialization string not conform ole db specification now, know words "third party component" going set off alarm bells here, hear me out. here's connection string i'm using provider=microsoft.ace.oledb.12.0; data source=c:\users\rory\downloads\testdb_4.xls; extended properties='excel 8.0;hdr=yes;'; i've got exact connection string work no problem following c# code using (oledbconnection conn = new oledbconnection()) { datatable dt = new datatable(); conn.connectionstring = connstring; using (oledbcommand comm = new oledbcommand()) { comm.commandtext = "select * [test_db$]"; // test_db name of sheet comm.connection = conn; using (oledbdataadapter da = new oledbdataadapter()) { da.selectcommand = comm; da.fill(dt); // stuff dt } ...

java - error while starting flume -

i trying use dynatrace source flume , hadoop sink,where dynatrace , flume on same server , hadoop on server. however,when starting flume,i getting below error : error [conf-file-poller-0] (org.apache.flume.conf.file.abstractfileconfigurationprovider$filewatcherrunnable.run:211) - unhandled error java.lang.nosuchmethoderror: org.slf4j.spi.locationawarelogger.log(lorg/slf4j/marker;ljava/lang/string;iljava/lang/string;ljava/lang/throwable;)v @ org.apache.commons.logging.impl.slf4jlocationawarelog.debug(slf4jlocationawarelog.java:120) @ org.apache.hadoop.metrics2.impl.metricssystemimpl.register(metricssystemimpl.java:220) @ org.apache.hadoop.metrics2.metricssystem.register(metricssystem.java:54) @ org.apache.hadoop.security.usergroupinformation$ugimetrics.create(usergroupinformation.java:106) @ org.apache.hadoop.security.usergroupinformation.(usergroupinformation.java:208) @ org.apache.flume.sink.hdfs.hdfseventsink.authenticate(hdfsevent...

SOLR Exception in thread "Scanner-0" java.lang.OutOfMemoryError: Java heap space -

solr gets hang , when check stderrout.log of jetty error: exception in thread "scanner-0" java.lang.outofmemoryerror: java heap space found , increase heap size of java: you use java -xmx4096m in order set heap 4 gb. you add export _java_options=-xmx4096m shell (.bashrc, .zshrc) file. https://askubuntu.com/questions/542585/how-to-increase-java-heap-size

pandas - Select the row and column element of a dataframe and decide the regression variables -

i have pandas dataframe containing 10 columns , 1000 rows. want perform multinomial logit regression. however, want use different independent variable based on choice. for example, have y "mode chosen" i.e car, bus, train etc. , have attributes of modes x such "car travel time" "bus travel time" etc. i want perform mnlogit wherein, when chosen mode car, x must car travel time , when chosen mode bus, x must bus travel time. want if data.mode_chosen == "car": x = data["car travel time"] elif data.mode_chosen == "bus": x = data["bus travel time"] ..... i want access nth row , mth column , find whether car or bus or train , choose dependent variables per choice. ps: amateur programmer , new forum, kindly let me know if have not made question clear.

version control - Different Revision Increment in one SVN Repository -

how make branch have different revision increment in 1 repository example: repo ----master | ----trunk when commit on trunk 5 times , merge master the result: repo ----master (rev:1) | ----trunk (rev:5) and commit on trunk 4 times , merge master the result: repo ----master (rev:2) | ----trunk (rev:9) can done in svn? no. these revision numbers internal id svn identify revisions. if don't change code @ all, svn-properties get's it's own revision-number. svn doesn't allow user set revision number commit , frankly don't see need this. if want make such counts, have independently svn.

meteor autoform string array shows empty field -

Image
i make edit form collection, has array fields 'phones', each element string when trying make afarrayfield field shows block 1 empty string schema: {phones: {type: array, mincount: 1, label: "phones numbers"}, {"phones.$": {type: string} } template: {{> afquickfield name="phones" value=phones}} in object array 'phones' presented i've following: phones: { type: [string], mincount: 1, label: "phones numbers" }, 'phones.$': { autoform: { affieldinput: { type: 'text' } } } template helper template.home.helpers({ doc: {phones: ['09988765', '0998776']} // should come db.findone }) in template: {{#autoform id='test' schema="schema.array" type="update" doc=doc}} {{> afquickfield name="phones" value=doc.phones}} {{/autoform}} i...

c# - Quitting BackgroundWorker using flag -

imagine have such code: private bool flag = false; public someclass() { public void setup() { worker = new backgroundworker(); worker.dowork += worker_dowork; if(!worker.isbusy) worker.runworkerasync(); } void worker_dowork(object sender, doworkeventargs e) { if(flag == true) return; //whatever want background thread do... someclass.somestaticmethodwhichhasloopinside(); } } when user clicks exit button in application can set flag=true inside - right way stop thread started backgroundworker ? want when application wants quit - stop thread. or automatically killed? no. don't that. not work expected. flag field isn't declared volatile ; possible true value of field isn't flushed memory yet. other thread still see flag false because caches own copy of value , backgroundworker may never end. instead, call backgroundworker.cancelasync , check backgroundworke...

php - How to use phpMail under MAMP for Windows -

i use couchcms content manager website. install mamp (windows version) php/mysql/apache solution. i'm trying enable phpmail feature use gmail's smtp, failed. my php.ini in c:\mamp\conf\php5.6.3\php.ini [mail function] ; win32 only. smtp = smtp.gmail.com smtp_port = 25 auth_username = xxxxxx auth_password = xxxxxx ; win32 only. sendmail_from = xxxxx@gmail.com ; unix only. may supply arguments (default: "sendmail -t -i"). ;sendmail_path = any idea debug issue? if use mamp need provide separate smtp solution. example, can install email relay or other 3rd party software smtp server or smtp relay functionality, configure , use scripts executed in mamp servers. smtp = smtp.gmail.com smtp_port = 25 smtp.gmail.com can accessed on ssl/tls need use ports 465 or 587. php mail send function can work no-ssl smtp servers can not use send email on gmail servers. so have provide own smtp solution if using mamp. mamp pro bundled stmp relay functionality ,...

c++ - Having trouble updating an object's attributes? -

i have virtual method called update account, based on pointer found find method , returned main, account update accordingly. there parent class called account, savings derived from. however, savings not output updated interest , not take interest effect. all accounts have balance , deposit not change among accounts, that's why calling account's deposit method void savings::updateaccount(date *date) { int interestmonths; short lastyear; short lastmonth; float currbal; //these current date - differs account creation //date , allows calculation of interest lastmonth = getaccountmonth(); lastyear = getaccountyear(); currbal = getaccountbal(); if (((date -> getyear ( ) - lastyear) * 12 + (date -> getmonth ( ) - lastmonth )) > 0) { interestmonths = ((date -> getyear ( ) - lastyear) * 12 + (date -> getmonth ( ) - lastmonth)); ...

gridview - Devexpress AspxGridView Hide SelectCheckbox programatically? -

just quick one i have devexpress gridview selectcheckbox column turned on, , operations based on work fine. want hide checkbox row conditionally based on column value in grid. is possible selectcheckbox in command column, or have create template in column , bit of work-around? either way, how? you can achieve in grid rowdatbound event have work around ..here give demo code.. foreach (gridviewdatacolumn c in gridview.columns) { checkbox chk=grid.findeditrowcelltemplatecontrol(grid.columns("name_colum"), "namecheckbox") if(your condition) {chk.visble=false;} }

c# - asp.net application not connecting to oracle 11g even after installing oracle instant client for 11g -

Image
i have asp.net mvc application using oracle 11g database. in development machine every thing worked fine, while deploying in production server asp.net application not able connect database server. throwing empty exception. i wrote simple console application test db connectivity. not working. realized because machine doesn't have oracle client installed. installed oracle instant client 11g database 32 bit version. after console application started working web application still not connect. i google lot , decided analyse using process monitor. in process monitor found web application (iis) looking oraclient12.dll. this oraclient12.dll part of oracle client 12c database. can't understand why looking dll. after installing oracle database client 12g, above issue oraclient12.dll got fixed. iis not able locate oraclsce12.dll. searched whole file-system file not find. does know should install oraclsce12.dll. thanks, sujith i facing similar issue, came know ...

Which methods are available via DDP in Meteor? -

when communicating meteor server on ddp, i've found following methods available: if have defined method mymethod in meteor.methods({ ... }) {"msg":"method","method":"mymethod","params":[],"id":"1"} if have enabled accounts-password package {"msg":"method","method":"createuser","params":[{ ... }],"id":"1"} {"msg":"method","method":"login","params":[{ ... }],"id":"1"} if there exists collection called mycoll on server {"msg":"method","method":"/mycoll/insert","params":[{"_id":"some-doc"}],"id":"1"} {"msg":"method","method":"/mycoll/update","params":[{ ... }],"id":"1"} {"msg":"method...

vba - Excel formulas have stopped working -

i have excel sheet has basic + array excel formulas, earlier used work last 1 week not give me desired result. i have tried following things nothing seems work. change formula setting manual automatic. change format of cell text general. no space before equal sign. note: using 2010 excel , rest in office uses 2013 , shared on common folder. can 1 of reason ? regarding anz formula, rows have match. inserted 12 rows part of trades worksheet , expanded range u1:u65548 , z1:z65548. aw column remains @ aw1:aw65536. while ranges can offset each other, have same size. this shows on formula finex well.

linux - Why is using tail to copy a file so much slower than cp, and using awk twice as fast? -

i'm trying strip out header line of large csv file. first methods tried (using tail , awk) work compared copying entire file! so, fun, let's try few silly potentially didactically interesting methods copying files. using cp: $ time cp my_big_file.csv copy_of_my_big_file.csv real 0m2.208s user 0m0.002s sys 0m2.171s using tail: $ time tail -n+1 my_big_file.csv > copy_of_my_big_file.csv real 0m44.506s user 0m37.521s sys 0m3.107s using awk: $ time awk '{if (nr!=0) {print}}' my_big_file.csv > copy_of_my_big_file.csv real 0m24.951s user 0m20.336s sys 0m2.869s what accounts such large discrepancies between using tail vs cp vs awk? cp copying fs block block, without asking question. thing happening @ kernel level. tail reading line line , filtering recreate file line line. of course, fs bufferize in read , write case, less efficient, cause have cross several layers (kernel-user space), , forth

php - MYSQL SELECT statement Where last Date If Trace = 12 -

create table if not exists `sporesfungi` ( `idspore` varchar(4) character set latin1 collate latin1_bin not null, `name` varchar(25) not null, `type` varchar(10) not null, primary key (`idspore`), key `idspore` (`idspore`) ) create table if not exists `sporecount` ( `idspore` varchar(4) character set latin1 collate latin1_bin not null, `tracenum` int(2) not null, `tracehour` int(4) not null, `amount` int(11) not null, `date` date not null, unique key `idspore_2` (`idspore`,`tracehour`,`date`), key `idspore` (`idspore`) ) since can't still post images put that, i'm trying take type sporesfungi , amount & idspore sporecount , make inner join, sporecount want latest date data has tracenum = 12 highest value have. so want data on recent date tracenum reached 12. this have tried no results yet select amount, idspore, sporesfungi.type sporecount inner join sporesfungi on sporecount.idspore = sporesfungi.idspore date = ( ...

c# - Calling a control from 3rd Party DLL -

i using control dll in html page as <object id="att" width="100%" height="100%" classid="clsid:e20ec898-e4ee-4a20-a5a5-e10144fdc6ba" codebase="avtechmediacontrol.cab#version=1,1,7,6" viewastext> </object> but want access same wpf application. when try choose dll in toolbox, following error, “the following controls added toolbox not enabled in active designer” i need way add wpf project. not want go webbrowser control. activex controls cannot directly added wpf view, can hosted inside of windows form control. , wpf can host winforms controls. microsoft has walk through describing process . the short description of you'll add windowsformhost xaml view. msdn walk though shows being done in code behind, windowsformhost can added in xaml. you'll set child of windowsformhost activex control. have done in code behind there no support adding activex controls in xaml editor. ...

java - Sending images as a base64 string to a google cloud endpoint from cms -

i trying send image cms google cloud endpoint stored in google datastore. image converted base64 string send endpoint. works fine when i'm sending android application when try sending cms throws error. i've had change api method because other api method uses custom object java , cms using javascript. ways have found send image endpoint either string, text or blob. this part of method on cms sends image endpoint var testapi = gapi.client.itemapi; var testapimethod = testapi.storeitemfromjs({ "id" : id, "name" : name, "description" : description, "status" : status, "contents" : contents, "resource": { "image": image }}); testapimethod.execute(); this current api method, can see it's using text image: @apimethod(name = "storeitemfromjs", path="itembean/store/js") public entity storeitemfromjs(@named("id")string id, @named("name") string name, ...

ios - Dynamic printing of class and function -

i beginner xcode , want dynamic printing of function being executed. so want function display functionexecuted() executed in classname that grab function name , class name dynamically. have already: class myviewcontroller: viewcontroller { func appactivity() { var class: string = "myviewcontroller" println("\(___function___) executed in \(class)") } override func viewdidload() { // etc. code appactivity() } } which run appactivity() function when view loaded. have output of: appactivity() executed in myviewcontroller when looking for: viewdidload() executed in myviewcontroller i want retain not having appactivity take input parameters. also, instead of defining class name explicitly, have dynamically name of class function in. i know might not best way of accomplishing more learning , understanding. my recommendation in extension. extensions perhaps highlight of swift, imho. can decorat...

parse.com - AngularJS, Parse REST Api, and jQuery UI Sortable problems -

i have sortable , angular working together, have no idea send sortable list parse rest api. ( have 3 list need submit @ once different ng-models.) whats best way post , update/delete these list. angular.module('sslive') .factory('listfactory', ['$http', '$location', 'parse_uri', '$cookiestore', 'parse_headers', function ($http, $location, parse_uri, $cookiestore, parse_headers) { var getlist = function () { return $http.get(parse_uri + 'classes/setlist', parse_headers); }; var addlist = function (list) { $http.post(parse_uri + 'classes/setlist', list, parse_headers) .success(function () { $location.path('/dashboard'); }); }; var updatelist = function () { $http.put(parse_uri + 'classes/setlist:rid', parse_headers) .sucess(function () { $location.path('/dashboard'); }) ...

java - Maven checkstyle error : Expected @param tag for '<T>' -

i have following method generic types, when run maven checkstyle(maven-checkstyle-plugin, 2.121) kept gives me expected @param tag '<t>' error message during maven build. how on this? /** * read in specified type of object request body. * @param request httpservletrequest * @param expected expected type t * @return <t> specified type of object */ public <t extends object> t getexpectedvalue( final httpservletrequest request, final class<t> expected) i used following turn generic param tag off, didn't work , have above mentioned java doc well. <module name="javadoctype"> <property name="allowmissingparamtags" value="true"/> </module> it telling you did not write javadoc method type parameter: /** * ... * @param <t> type parameter * @param .... */ public <t extends object> t getexpectedvalue( final httpservletrequest request, final class<t...

linux - Add custom timestamp overlay on video with bash -

does know bash command linux write custom timestamp ( dd:mm hh:mm:ss ) in video file ffmpeg, cvlc or other program? this works nicely. used method record quite lot of video , timestamp in realtime. http://einar.slaskete.net/2011/09/05/adding-time-stamp-overlay-to-video-stream-using-ffmpeg/

javascript - My "push array" function is not working -

i working on final fantasy atb battle system , i'm trying implement "haste feature". instead of waiting 6 seconds before can act, haste let act within 3 seconds. setup user object has status property empty array. when haste button executed, "push" word "haste" array. make statement says if have "haste status", have timer act on 3 seconds on 6. problem i'm running if have other "haste" array, effect breaks. example, if hit haste button 3 times, push "haste" word array 3 times, not issue can remove later. issue i'm having if other single "haste" in array, effect not work, not want because in future i'm going use push in other status effects. how can tell code if other array items in array, still execute effect? function hastebutton() { atbreset() user.status.push("haste"); console.log(user.status); }; var user = { status: [] }; function timebar(el, color) { var el...

asp.net web api - How to configure Web Api access as Azure Active Directory Graph API -

i have setup webapi application , under permissions has access windows azure active directory. the application able access graph api, , there no prompt user login. how can achieve similar setup webapi? want applications have permissions setup access it. set way: http://bitoftech.net/2014/09/12/secure-asp-net-web-api-2-azure-active-directory-owin-middleware-adal/ but unlike when accessing graph api "windows azure active directory", prompts login. you need use different overload of acquiretokenasync if don't want prompted authenticate. means using secret authentication of application. string tenantid = "[your domain, such contoso.onmicrosoft.com]"; string clientsecret = "[get configure page in portal]"; string resazuregraphapi = "https://graph.windows.net"; var context = new authenticationcontext(string.format("https://login.windows.net/{0}", tenantid)); clientcredential clientcred = new clientcredential(client...

Does this Java program need to be two separate Files -

hi taking java class , first assignment involving object oriented programming. getting issues simplecalc portion , wondering if work should 2 separate files or if missing component allows statcalc part , simplecalc part speak 1 another. please keep in mind new java might need spelled out bit more have seen on stack on flow in past @ times, however, appreciate thank in advance. here code: package tutorial; /* * object of class statcalc can used compute several simple statistics * set of numbers. numbers entered dataset using * enter(double) method. methods provided return following * statistics set of numbers have been entered: number * of items, sum of items, average, standard deviation, * maximum, , minimum. */ public class statcalc { private int count; // number of numbers have been entered. private double sum; // sum of items have been entered. private double squaresum; // sum of squares of items. priva...

amazon web services - Best way to launch aws ec2 instances with ansible -

i'm trying create small webapp infrastructure ansible on amazon aws , want process: launch instance, configure services, etc. can't find proper tool or module deal ansible. ec2 launch. thanks lot. this short answer of question, if want detail , automated role, please let me know. thanks prerequisite : ansible python boto library set aws access , secret keys in environment settings (best inside ~./boto) to create ec2 instance(s): in order create ec2 instance, please modified these parameters can find inside "ec2_launch.yml" file under "vars": region # want launch instance(s), usa, australia, ireland etc count # number of instance(s), want create once, have mentioned these parameter, please run following command: ansible-playbook -i hosts ec2_launch.yml contents of hosts file: [local] localhost [webserver] contents of ec2_launch.yml file: --- - name: provision ec2 instance hosts: local connection: ...

c++ - How do I make this program smaller, more efficient? -

i doing practice question went this: write program asks user enter number of hamburgers eaten ten different people (p1, p2, ... etc.) once data has been entered program must analyze data , output person ate least hamburgers, , outputs person ate hamburgers. i know code isn't ideal(to least, determined finish have go off of question. if you're willing help, don't afraid throw more complex things @ me, that's how learn, right? here's code: #include <iostream> #include <string> using namespace std; int main() { int p1 = 0; int p2 = 0; int p3 = 0; int p4 = 0; int p5 = 0; int p6 = 0; int p7 = 0; int p8 = 0; int p9 = 0; int p10 = 0; cout << "how many pancakes did p1 eat?" << endl; cin >> p1; cout << "how many pancakes did p2 eat?" << endl; cin >> p2; cout << "how many pancakes did p3 eat?" << ...

ruby on rails - NoMethod Error undefined method `first_name' for nil:NilClass -

running rails 4.1.8 | ruby 2.1.5p273 i'm trying display current username notes created current user using: <%= "#{note.user.first_name.capitalize} #{note.user.last_name.capitalize[0]}" %> in show.html.erb. <% @notes.each |note| %> <tr> <td> <h4> <%= "#{note.user.first_name.capitalize} #{note.user.last_name.capitalize[0]}" %> </h4> <p><%= note.created_at.strftime("%-m/%-d/%y") %></p> </td> <td> <p><%= h(note.comment).gsub(/\n/, '<br/>').html_safe %></p> if take <%= "#{note.user.first_name.capitalize} #{note.user.last_name.capitalize[0]}" %> app works fine. i checked notescontroller note , can't seem find issue. class notescontroller < applicationcontroller before_action :set_note, only: [:edit, :update, :destr...

javascript - Unable to handle click events in Firefox -

the button trying handle: < input type="submit" class="btn flownextbtn" value="next" name="p:i:f:bottom:next" id="p:i:f:bottom:next"> here's have tried: $(".flownextbtn").click(function() { alert("clicked"); }); and $("[id='p:i:f:bottom:next']").click(function() { alert("clicked"); }); and $("[id='p:i:f:bottom:next']").one("click", function() { alert("clicked"); }); and document.getelementbyid("p:i:f:bottom:next").addeventlistener("click", function() { alert("clicked"); }); and document.getelementbyid("p:i:f:bottom:next").onclick = function() { alert("clicked"); }; all of above work fine in chrome; when button clicked alert popup. ideas what's causing firefox dislike script? i'm not seeing errors in firebug console. when debug objects usi...

Display all child nodes of selected node of treeview in textbox in vb.net -

not sure on how around this. i able display current selected node in textbox (or richtextbox) doing following: private sub treeview1_afterselect(sender object, e treevieweventargs) handles treeview1.afterselect richtextbox1.text = e.node.text end sub however, can't figure out way of displaying all child nodes of selected parent. would able point me in right direction? you need called recursive subroutine drill down child nodes of each node iterate through them: private sub treeview1_afterselect(sender object, e treevieweventargs) handles treeview1.afterselect dim mynode treenode = e.node textbox1.text = mynode.text getchildnodes(mynode) end sub sub getchildnodes(tnode treenode) 'iterate through child nodes of node passed subroutine each node treenode in tnode.nodes textbox1.text += node.text 'if node passed subroutine contains child nodes, 'call subroutine each 1 of them 'if wa...

How to check for a single field being set in a C bitfield -

i have following style of union - defined in interface not easy change. i want check if foo field being set. , don't want itemizing other fields. so immediate thoughts construct mask, bitfield doing it's best hide details position of named field. i couldn't think of better creating variable 1 field set , inverting raw field. there neater solution? typedef union struct { unsigned char user:1; unsigned char zero:1; unsigned char foo:1; unsigned char bar:1; unsigned char blah:1; unsigned char unused:3; }; unsigned char raw; } flags_t; bitwise xor negation of want: 11011111 ^ 00100000 = 11111111 then check value == 255. can make clean using own struct build negation setting bar->foo = 0 , else 1. edit: little elaboration because feel bad not being pretty when that's you're asking for: struct { unsigned char bad:1; unsigned char bad:1; unsigned char foo; unsigne...

html - JQuery override element -

i have 8 items in list on hover expand content through code(i post code 1 item) (function($){ "use strict"; jquery("#foto-chiara").click(function() { if($("#foto-chiara").css('top') == '0px'){ $("#foto-chiara").stop().animate({top:$("#bio-chiara").height() +'px'},1000); }else{ $("#foto-chiara").stop().animate({top:'0px'},1000); }; $("#info-chiara").toggle(500); }); }(jquery)); the issue occur when item in first row expand , override content of item above. how can prevent this? css code #foto-chiara{ background-image:url("http://www.aspeera.it/wp-content/uploads/2015/04/chiara_foto1.png");width:200px;height:200px;position:absolute;top:0px; } #info-chiara{ display:none; background-image:url("http://www.aspeera.it/wp-content/uploads/2015/04/chiara_fondo1.png"); width:200px; height:150px; position:absolute; } html code(only 1 item) <ul ...

c# - SQL Rows as CheckBoxes -

i have employee web form employees can assigned number of markets. i'm attempting take sql row values , assign them checkboxes in c#. so example sql database following: employeeid marketid 99999 1 99999 2 99999 4 my code behind is string sqlconn = configurationmanager.connectionstrings["connectionstring"].connectionstring; using (sqlconnection sqlconnection1 = new sqlconnection(sqlconn)) { using (sqlcommand cmd = new sqlcommand()) { cmd.commandtext = ("usp_employeemarkets"); cmd.commandtype = commandtype.storedprocedure; cmd.connection = sqlconnection1; cmd.parameters.addwithvalue("employeeid", id); sqlconnection1.open(); sqldatareader sdr = cmd.executereader(); while (sdr.read()) { market1checkbox.checked = sdr["marketid"].equals(1); market2checkbox.checked = sdr["marketid"].equals(2); market3...