Posts

Showing posts from March, 2015

How to check string is laid out in correct format (Python) -

i coding program needs import log files. user must input name of file in correct order of 'dd-hh.mm' (day, hour, minute). there way validate users input in correct order? thanks in advance you either use regular expressions, or try parse date time.strptime , see if there exceptions. see https://docs.python.org/2/library/time.html#time.strptime the strptime way this: try: time.strptime(input_string, "%d-%h.%m") except valueerror: print("incorrect date format") be sure check docs , see if placeholders ( %d , %h , ...) represent ranges , formats want check

javascript - CSS3 onclick animation -

trying learn basics of css3 animation , onclick events i'm stuck. i want use button id="3" start animation, red square can see here: https://jsfiddle.net/4swmegpn/ , button id="4" stop/reset animation of red square. i don't know start. i've started adding onclick to: <button id="button1" onclick=""> > </button> but after can't come do. call , activate "keyframes example" css-file, not sure how to. you can add , remove class element start / end animation. , in css add animation class (see fiddle ). practice not include javascript code in html (like onclick had), rather add event listeners in scripts: document.getelementbyid('startanim').addeventlistener('click', function() { document.getelementbyid('red').classlist.add('animate'); }); document.getelementbyid('stopanim').addeventlistener('click', function() { document.getelemen...

mongodb - Sort by number of subdocuments mongoid -

i have model person has many comments how sort people collection number of comments something person.desc(:"comments.count") you can't work 2 collections @ once need in person can can sort on. usual approach use counter cache cache number of comments in each person . you'd have this: class person include mongoid::document has_many :comments end class comment include mongoid::document belongs_to :person, :counter_cache => true end the :counter_cache => true option belongs_to add comments_count field person contain cached number of comments. once have counter cache, can say: person.desc('comments_count') to sorting. you'll need initialize counters hand using person.reset_counters or person#reset_counters things started.

PHP read a large file line by line and string replace -

i'd read large file line line, perform string replacement , save changes file, iow rewriting 1 line @ time. there simple solution in php/ unix? easiest way came on mind write lines new file , replace old one, it's not elegant. i think there're 2 option use memory read, replace store replaced string memory, once done, overwrite source file. use tmp file read & replace string write every line tmp file, once done, replace original file tmp file the #1 more effective bcuz io expensive, use if have vast memory or processing file not big. the #2 bit slow quite stable on large file. of course, may combine both way writing replaced string by chunk of lines file (instead of by line ) there're simplest, elegant ways can think out. please correct me if wrong.

SNMP agent configuration windows/linux -

Image
i need retrieve information via snmp , use information create sort of graphic application in unity. i find snmpsharp library http://www.snmpsharpnet.com/ i create little program in unity using library , installed snmp on windows machine(using windows official guide) , on localhost works! now problem how can connect other agent on lan network ? how can install agent on other device example linux pc ? i'm little confused beacuse try install snmp on other windows pc can't retrieve snmp information ; try install snmp agent on linux pc don't understand how correctly install agent have communicate across lan this code work on localhost using unityengine; using unityengine.ui; using system.collections; using snmpsharpnet; using system.net; public class snmp_walk : monobehaviour { [serializefield] public inputfield community_str; [serializefield] public inputfield agent_ip_address; [serializefield] public button mybutton ; string str_community = null; string ip ...

linux - C++. Avoiding cross-linking in multple files project -

i've been building many c++ projects university recently. consisted of multiple files 1 makefile. in prj folder makefile within, source files in src folder , headers in inc folder. makefile compiled object files in obj folder , linked final program. i got many strange errors broke down that, e.g. i've included matrices.h in vector.h file , vector.h in matrix.h . compiler said methods not exist in matrix class. i have include vector.h in matrix.h . then, include matrix in main.cpp . use sqrt() , pow() functions in files. now wonder proper avoid declaring continously < cmath > library in vector.h , matrix.h , in main.cpp ? i'd rather declare in vector.h , leave it. complier g++ , linux debian. i use preprocessor directives: #ifndef vector_hh //or matrix_hh etc. #define vector_hh #include <cmath> //class body #endif` good practice define generic header file, can include necessary header files @ one, along he...

c - Reader is not reading from a shared memory -

i'm reading file , write on shared memory.but writer writing in shared memory working fine reader not reading shared memory. maxlen[x] have stored maximum length of line. void * reader (void * param){ int i; int count=1; int waittime; waittime = rand() % 5; sleep(waittime); shm_ptr = shmat(shm_id, null, 0); if ((int)shm_ptr == -1){ printf("*** shmat error (server) ***\n"); exit(1); } sleep(1); printf("\nreader trying enter"); sem_wait(&mutex); readcount++; if(readcount==1) sem_wait(&wrt); printf("\n%d reader inside ",readcount); printf(" in crtical section \n"); int sizes=x; x=0; while (x<=sizes) { shm_ptr[x] = malloc( sizeof(char *)* maxlen[x]); puts(shm_ptr[x]); x++; } sem_post(&mutex); sem_wait(&mutex); readcount--; if(readcount==0) sem_post(&wrt); sem_post(&mutex); printf("\nreader leaving"); ...

android - Deleted file resurrects after ACTION_MEDIA_SCANNER_SCAN_FILE intent -

i have delete image in application. when use file.delete method (returns true, mean deleted), file deleted on file system, it's visible in gallery. delete gallery use sending of action_media_scanner_scan_file intent or calling mediascannerconnection.scanfile . after strange thing happens: deleted file resurrects , returns in file.listfiles method. how delete file both filesystem , gallery? delete database: import android.provider.mediastore; import android.content.context; import android.content.contentresolver; // if calling method activity pass context parameter public void deletefromdatabase(context context, file file) { uri contenturi = mediastore.images.media.getcontenturi("external"); contentresolver resolver = context.getcontentresolver(); int result = resolver.delete(contenturi, mediastore.images.imagecolumns.data + " ?", new string[]{file.getpath()}); if(result > 0){ // success } else { // fa...

Add query params to a GET request in okhttp in Android -

is there way add query params ( ?param1=val1&param2=val2 ) request using okhttp in android? i looking api , not manually adding params in loop , escaping values. try httpurl class (in okhttp package). //adds pre-encoded query parameter url's query string addencodedqueryparameter(string encodedname, string encodedvalue) //encodes query parameter using utf-8 , adds url's query string addqueryparameter(string name, string value) note: if there name/value pairs name, these functions add pair setencodedqueryparameter(string encodedname, string encodedvalue) setqueryparameter(string name, string value) note: if there name/value pairs name, these functions remove them , after add new pair example: httpurl url = new httpurl.builder() .scheme("https") .host("www.google.com") .addpathsegment("search") .addqueryparameter("q", "polar bears") .build();

c - Code not reaching statements using fgets? -

i have written code uses fgets function multiple conditions call other functions within code, namely amethod , bmethod. int main(void) { char buffer[1024]; while (fgets(buffer, 1024, stdin)) { if ((strcasecmp(buffer,"a")) == 0) { amethod(); } if ((strcasecmp(buffer, "b")) == 0) { bmethod(); } } } i'm not sure why doesn't reach if statements. great, thankyou. if in doubt, print out: int main(void) { char buffer[1024]; while (fgets(buffer, 1024, stdin)) { fprintf(stderr, "buffer [%s]\n", buffer); /* <==== */ if ((strcasecmp(buffer,"a")) == 0) { amethod(); } if ((strcasecmp(buffer, "b")) == 0) { bmethod(); } } } you find lot of errors way.

javascript - Timeout after gulp serve command -

Image
i'm new in reactjs , gulp... . i have problem gulp . problem when write gulp serve in terminal, in browser, page doesn't show , page doesn't load , after long time loading status, browser show me: this webpage not available err_connection_timed_out message. i don't know whats problem? my package.json is: { "name": "projectoverview", "version": "1.0.0", "description": "", "main": "gulpfile.js", "scripts": { "test": "echo \"error: no test specified\" && exit 1", "start": "gulp serve" }, "author": "", "license": "mit", "devdependencies": { "react": "^0.13.2", "gulp-react": "^3.0.1", "gulp": "^3.8.11", "gulp-connect": "^2.2.0", "gul...

java - mapreduce.reduce.shuffle.memory.limit.percent, mapreduce.reduce.shuffle.input.buffer.percent and mapreduce.reduce.shuffle.merge.percent -

i want verify understanding these parameters , relationship, if wrong please notify me. mapreduce.reduce.shuffle.input.buffer.percent tells total amount of memory allocated entire shuffle phase of reducer . mapreduce.reduce.shuffle.memory.limit.percent tell maximum percentage of in-memory limit single shuffle can consume mapreduce.reduce.shuffle.input.buffer.percent . mapreduce.reduce.shuffle.merge.percent usage threshold @ in-memory merge initiated, expressed percentage of total memory( mapreduce.reduce.shuffle.input.buffer.percent ) allocated storing in-memory map outputs. but hadoop-2.6 has restriction mapreduce.reduce.shuffle.merge.percent should greater mapreduce.reduce.shuffle.memory.limit.percent . means single shuffle has keys of same type otherwise purpose of restriction , relation between 3 ? i share understanding on these properties, hope help. advise me if wrong. mapreduce.reduce.shuffle.input.buffer.percent tells percentage of reducer's h...

android - Database objects not getting executed -

i running following thread in service. but, if have 3 or 4 rows of data in database, last 1 not executed. if having 4 rows of data, 3 gets executed. can tell me reason this? new thread(new runnable() { @override public void run() { list<greetings>greetings = db.getallgreetings(); if(db.getgreetingscount()>0) { { (greetings g : greetings) { calendar cal = calendar.getinstance(); d1 = cal.get(calendar.day_of_month); d2 = cal.get(calendar.month); d3 = cal.get(calendar.year); t1 = cal.get(calendar.hour); t2 = cal.get(calendar.minute); t3 = cal.get(calendar.am_pm); if (t3 == 1) { t4 = "pm"; ...

Google Cloud SQL - ERROR 2003 (HY000): Can't connect to MySQL -

Image
i trying connect google cloud sql using command line. can connect when @ home , set static ip address. however, have on road next few days , can't @ home. hoping connect mysql , make changes needed on server through hotspot on phone, happy type of internet connection working. how can connect google cloud sql though keep getting error as, error 2003 (hy000): can't connect mysql on server ... i tried creating google compute engine vm instance , setting static ip address , connection mysql through that, doesn't work. i make sure everytime authorize appropriate ip address, connecting from. i scratching head , cannot figure out why won't let me connect @ home though authorize other ip address have ever tried connect from. so whatever reason, able connect if requested ipv4 address (costs $0.01 hour) , used connect instead of free ipv6 address, connect anywhere. otherwise can connect cloud sql when using free ipv6 address @ home. check out s...

compiler construction - Convert 3 Address codes in Assembly -

Image
i trying convert 3 address codes in assembly code [code generation]. consider, the assembly code sequence is: if order changed t2 t3 t1 t4, then add done memory operand + register operand sub never done memory operand. similarly, have seen mul never done memory operand. there rule ? why mov r0,t1 used? isn't better use 1 more register , keep using r0 ? bring t1 down, t2-t3-t1-t4 new sequence , save instructions i.e. can use reg keeps value of t1 in next instruction. use register after immediate instruction have store in memory? typically, operands have involve @ least 1 register cannot, example, subtract t1 t2 directly. therefore, have move op1 register , apply operation op2 - result going register. in case, e-t1 cannot used register (it's on wrong side of operand) whereas t1-e could. one alternative negate , add t1 used without resorting memory. so: mov a, r0 add b, r0 ; t1 (r0) := a+b mov c, r1 add d, r1 ...

c - Expression must have pointer to struct or union error -

t variable coming error assigntime function onwards saying must have pointer struct or union type. pointers weakness, if explain, not give me answer, need fix helpful! cheers. //my time c file #include "my_time.h" #include <stdio.h> #include <stdlib.h> #include <stdbool.h> struct my_time_int { int hour; int minute; int second; }; void init_my_time(my_time *t) { t=(my_time)malloc(sizeof(struct init_my_time*)); } /* * alter hour, minute, , second * param h new value hour * param m new value minute * param s new value second */ void assigntime(my_time *t, int h, int m, int s) { t->hour = h; t->minute = m; t->second = s; } //following code t variable has red underline error saying expression must have pointer struct or union> char *tostring(my_time t) { char *r = (char *)malloc(12 * sizeof(char)); if (t.hour >= 12) { if (t.hour == 12) sprintf(r, "%02d:%02d:%02d pm", 12, ...

android - libGDX interface cannot be applied error -

Image
i use interfaces in libgdx. i error in androidlauncher before compile. it says line: initialize(new mygdxgame(actionresolverandroid), config); .... cannot applied you can try, run whole code here: https://github.com/kovacsakos/gdx-interfaces github repo has been updated, can see working code in it.

Why does "pip install" inside Python raise a SyntaxError? -

i'm trying use pip install package. try run pip install python shell, syntaxerror . why error? how use pip install package? >>> pip install selenium ^ syntaxerror: invalid syntax pip run command line, not python interpreter. program installs modules, can use them python. once have installed module, can open python shell , import selenium . the python shell not command line, interactive interpreter. type python code it, not commands.

vb.net arraylist of objects -

i trying create arraylist of objects, , working fine except value of 11 objects same. i've have tried multiple ways of writing code, same outcome everytime. arrfullprodlist collects name of products in database. working properly. arrproducts having issue objects being same. what doing wrong? declared private objreader sqldatareader private objproducts new cproducts private arrfullprodlist arraylist = new arraylist public arrprodcuts arraylist = new arraylist class cproduct public class cproduct private _pstrprodid string private _pstrproddesc string private _psngwhcost single private _psngretprice single private _pblntaxable boolean private _isnewprod boolean public sub new() '_pstrprodid = "" '_pstrproddesc = "" '_psngwhcost = 0 '_psngretprice = 0 '_pblntaxable = false '_isnewprod = false end sub public property strprodid() string ...

javascript - Learning jQuery's tabs + CSS Flexbox. Can anyone help get this working? -

i'm new jquery , advanced css. wondering if take @ code , me working. basically, gray box on left supposed fixed , follow page scrolls(that works). essentially, want have tabs in gray scroll bar, , have content of tabs displayed in orange-ish flexbox on right. understand issue stems separation of <ul> , content divs in html, because that's how jquery reads tabs. being said, can me achieve i'm looking for. code convoluted, advice welcome. want learn, don't hold back! $(document).ready(function () { $('#menu').tabs(); $('.ui-tabs-active').removeclass('ui-tabs-active ui-state-active'); }); body { margin:0; margin-top:10px; padding:0px; } #wrapper { border:1px solid black; display:flex; margin-left:300px; margin-right:10px; } #scrollbar { background-color:gray; height:300px; width:280px; position:fixed; margin:10px; margin-top:0px; } #box1 { back...

ios - Is it possible to get button title from IB in class? -

i have several buttons titles 0 - 9 , in custom uibutton class want able use switch check button title. buttons created in storyboard. uibutton class looks like: protocol numpaddelegate: class { func changevalue() } class numpadbutton: uibutton, numpaddelegate { let initial = string() // want assign title of button here var alternative = string() var change: bool = false { didset { let title = change ? alternative : initial settitle(title, forstate: .normal) } } func changevalue() { change = !change } } is there way or i'll have programmatically create buttons? i'm trying limit use of custom uibutton class don't have create 1 each of buttons. edit: as requested, code of when button pressed: @ibaction func buttonnumber(sender: uibutton) { let value = sender.titlelabel!.text! switch value { case "c": orderlabel.text = "" de...

mysql - Want to Calculate Hightest Pay Value For a table? -

i want list of employees have worked on activity has highest total pay value. don't use code such …where actid = 151…ect • note: total pay worked activity sum of (total hours worked * matching hourly rate) (e.g. total pay activity 151 10.5 hrs @ $50.75 + 11.5 hrs @ $25 + 3hrs @ $33,) you must use subquery in solution. actid hrsworked hourlyrate total pay 163 10 45.5 455 163 8 45.5 364 163 6 45.5 273 151 5 50.75 253.75 151 5.5 50.75 279.125 155 10 30 300 155 10 30 300 165 20 25 500 155 10 30 300 155 8 27 216 151 11.5 25 287.5 151 1 33 33 151 1 33 33 151 1 33 33 you time , effort appreciated. !! without knowledge of schema, can provide possible sketch (you'l...

sql - How to select between two dates without using year to get birthday -

select * tbl_contact e e.dob between to_date('26-apr-2000','dd-mon-year') , to_date('03-may-2002','dd-mon-year') how resolve issue. if type of dob field of table date,the following query you: select * tbl_contact e e.dob between to_date('26-apr','dd-mon') , to_date('03-may','dd-mon') i hope you

python - Invalid output of file operation -

i not getting proper output good: fo=open("test.txt","r+") print "name of file:", fo.name fo.write("life short..") str=fo.read(3) print "string in file :",str fo.close() when open file in python, maintains single pointer indicating place in file. pointer indicates next point read , next point written to. gets updated whenever read or write. when write "life short...", file pointer moved end of wrote. means when go read file, pointer past part wrote to. if want print out words wrote file, need move pointer beginning of file. can accomplished fo.seek(0) .

php - Unable to retrieve image data from table and display image -

i'm trying upload image file database php , mysqli, i'm coming across confusing piece of error. table has 2 column, 'title' , 'image'. 'title' file's name , 'image' image data. both tables not allowed accept nulls. when upload file, data stored table columns. 'title' contains right values, 'image' column contains ' <binary data> '. since table column not accept null values assumed file's data, when try retrieve , display image data in showimage.php tells me image data null. i using blob datatype store image data in table. far concerned based off online resources , examples should work. thanks. code: php: uploads.php if (isset($_post['submit'])) { $title = $_files['image']['name']; $data = $_files['image']['tmp_name']; $content = file_get_contents($data); $query = "insert images (title, image) values (?, ?)"; $statement = $da...

javascript - Changing script to send non-duplicate values to a new sheet instead of duplicate values -

i have script iterates through 2 spreadsheets, finds duplicate values in column a, appends row of these duplicate values sheet. i want script similar thing, append rows not duplicates instead of ones are. how can alter sends non duplicates "new students" sheet"? tried changing == !==. sends whole list. have been searching around while , know it's easy fix. much! brandon function compareandupdate() { var s1 = spreadsheetapp.openbyid("xxxxxx-vvxyewdki0j9tgqjl9_f-wze0zoboqrisclaa").getsheetbyname('updated student list'); var s2 = spreadsheetapp.openbyid("xxxxxx-yb9xm1j5rkws7nf23vd-ntueigspbctj3lew4").getsheetbyname('master student list'); var s3 = spreadsheetapp.openbyid("xxxxxx-yb9xm1j5rkws7nf23vd-ntueigspbctj3lew4").getsheetbyname('new students'); var values1 = s1.getdatarange().getvalues(); var values2 = s2.getdatarange().getvalues(); var resultarray = []; for(var n=0; n < values1.l...

c# - How can I write to the root element? -

when use following code can write xml file write outside root element. streamwriter sw = file.appendtext(environment.currentdirectory + "\\settings.xml"); xmltextwriter xtw = new xmltextwriter(sw); xtw.writestartelement("connection"); xtw.writeelementstring("id", name); xtw.writeelementstring("version", "2.3.1"); xtw.writeelementstring("server", ip_textbox.text); xtw.writeelementstring("port", port_textbox.text); xtw.writeelementstring("uid", user_textbox.text); xtw.writeelementstring("password", pass_textbox.text); xtw.close(); after code runs xml looks this: <?xml version='1.0' encoding='utf-8' ?> <root> </root> <connection><id>test</id><version>2.3.1</version><server>127.0.0.1</server><port>3306</port><uid>root</uid><password>root</password> when should like: <?xml...

swift - How to remove Warning message that lingers after switching from Parse 1.6.2 to a later version -

Image
i switched parse 1.6.2 1.7.1 . replaced old parse framework new one. however, build process appears looking old library. please guide me find reference old framework (null): directory not found option '-/documents/development/ios/parse-library-1.6.2' one place might in project or target settings. scroll down through them , see if can find " parse-library-1.6.2 " might included. and delete it. here's can go hunting bogus path: and in general, should not keep files used project in folders outside (e.g. " ~/documents ") of source code hierarchy.

scala - Can I add class fields dynamically using macros? -

i'm new scala macros, sorry if obvious question. i wonder if following possible before dig in deeper. let's have class named dynamicproperties is possible add members class based on this? val x: dynamicproperties = ... x.addproperty("foo", 1) x.addproperty("bar", true) x.addproperty("baz", "yep") and have translated somehow class looks more or less? class somename extends dynamicproperties { val foo: int = 1 val bar: boolean = true val baz: string: yep } i guess can done via reflection, want people use this, have auto complete when type x. fit did earlier using addproperty method. possible using scala marcos? want try implement it, know if going down dead end path or not.

java - Class path exception on raspberry pi but not on any other PC -

i have been building point of service application friend , have gotten stage of implementing it. computer, , computer of have been testing me have had no problem running program. however, when tried implement on raspberry pi running archlinux arm , java 8—which same pc, other arm archetecture—i run class path exception. specifically: could not find or load main class toc19.interface i have tried loading -cp {. or toc19} , changing mannifest file no avail. the jar file using can found here: https://www.dropbox.com/s/f5jqfasn88qxkh4/toc19.jar?dl=0 , source code can found here: https://github.com/jarrah-95/toc19 thanks help.

input - Prompt User for image URL in python -

i have following code: import requests stringio import stringio responsel = requests.get(url) iml = image.open(stringio(responsel.content)) responser = requests.get(url) imr = image.open(stringio(responser.content)) i trying find way instead prompt user url image can input url image example photobucket or imgur. there way this?

c++ - No compiler warning for returning a reference to local variable -

using: g++ -wall -ansi foo.cpp i warning foo.cpp:31: warning: reference local variable ‘x’ returned from function : int &bar(int x) { return x; } but, removing function file, no warning following function: int &get_max(int x, int y) { return x > y ? x : y; } why compiler allow this? it looks bug, warning inconsistent, if turn on optimization in gcc 5.1 catch case: warning: function may return address of local variable [-wreturn-local-addr] return x > y ? x : y; ^ while without optimization gcc misses it . so best thing file bug report . if don't believe bug or won't fix @ least there reference others having same issue.

javascript - How to cycle through an array of Audio objects -

i've started learning javascript, , i'm working on first web-embedded game, musical puzzle game uses basic principals of twelve-tone serialist music. game done, , you can find here . i'm having trouble audio. did manage play sound when user solves puzzle, can't play through notes appear on game board. here's did: created array of 12 audio objects, contains every note c b. created method called "playtonerow()" plays through them all, order determined numeric array tonerow.notes[]. here's code: this.playtonerow = function() { (var in this.notes) { notesound[this.notes[i]].play(); } }; but method plays last note of tone row. should mention knowledge of javascript has been cobbled various tutorials i've found online, , i'm there significant gaps in admittedly rudimentary coding skills. figured problem wasn't putting space in between sounds, trying play them @ once, didn't have enough channels played last...

javascript - Is this method of component communication an Ember anti-pattern? -

take html , js: {{#main-view}} <!-- page html - header, content, etc. --> {{some-action tagname='button'}} <!-- more page html --> {{/main-view}} // components/main-view.js ember.component.extend({ mainview: true, dosomething: function() { alert('doing something') } }) // components/some-action.js ember.component.extend({ mainview: null, configuremainview: function() { this.set('mainview', this.nearestwithproperty('mainview'); }.on('didinsertelement'), click: function() { this.get('mainview').dosomething(); } }) the idea have descendent components able interact interfaces of ancestors. use case example want individual page content containers able configure whether or not hamburger menu available on page, {{page-content show-menu='false'}} . way can define menu @ top level , let children configure need content. i'm coming angular world, seems more preferred way handle...

ios - How can I add the name of a contact to my table view cell? -

hey have table view 5 cells , whenever 1 of them selected, abpeoplepickernavigationcontroller pops , user can select contact. how can make selected contact's name becomes text of cell's label? i've scoured internet 2 hours , can't figure out life of me. :( closest thing found used array store multiple contacts in dynamic cells have static cells... or hints appreciated. here's have far: override func viewdidload() { super.viewdidload() } override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { let picker = abpeoplepickernavigationcontroller() picker.peoplepickerdelegate = self presentviewcontroller(picker, animated: true, completion: nil) } func peoplepickernavigationcontroller(peoplepicker: abpeoplepickernavigationcontroller!, didselectperson person: abrecordref!, property: abpropertyid, identifier: abmultivalueidentifier) { let multivalue: abmultivalueref = a...

javascript - Express 4 Routes Using Socket.io -

having rough time adding socket.io in express 4 routes. in routes/index.js have: var express = require('express'); var router = express.router(); /* home page. */ router.get('/', function (req, res, next) { res.render('index', { title: 'express' }); }); router.post('/message', function(req, res) { console.log("post request hit."); // res.contenttype('text/xml'); console.log(appjs); io.sockets.emit("display text", req); // res.send('<response><sms>'+req.body+'</sms></response>'); }); module.exports = router; but io undefined. have seen several examples of how this, none worked me. appreciated. you need pass socket.io variable router module has access. wrapping module in function call. var express = require('express'); var router = express.router(); /* home page. */ var returnrouter = function(io) { router.get('/', function(req...

cpu - Which one is right one in pipelining? -

Image
i'm studying cpu pipelining, , had trouble. want know 1 right pipelining in below picture in opinion, first gantt chart kinda "structural hazard" becuase "if" stage partially overlapped. think using 1 stage 2 instruction not allowed. think second 1 right.... right? you right. the first chart has 2 instructions being fetched during second cycle. unless specified otherwise, cannot done. there circumstances in allowable: the instruction fetch divided 2 stages, if1 , if2 , each of take 1 cycle. if1 , if2 can overlapped. the data path , instruction cache support 2 simultaneous operations.

sql server 2012 - SQL query to retrieve the matching data over secondary tables link to master tables -

i have sql server database 4 tables. 1st table contains list of names primary key: id1 name --------------- 1 abc 2 xyz 2nd table having foreign key 1st table related properties. id2 properties id1 ----------------------- 1 p1 1 2 p2 1 3 p3 1 4 p2 2 5 p3 2 6 p5 2 3rd table contains tasks: id3 task ----------- 1 t1 2 t2 4th table task properties related task table foreign key: id4 properties id3 ----------------------- 1 p1 1 2 p2 1 3 p3 1 4 p2 2 5 p3 2 6 p5 2 scenario in case have task , have match properties 1st table name's properties. e.g. on task 2, properties matched xyz. i trying group , having count no luck accurate result. is can please me out it?

What is the meaning of the data32 data32 nopw %cs:0x0(%rax,%rax,1) instruction in gcc inline asm? -

while running tests -o2 optimization of gcc compilers, observed following instruction in disassembled code function: data32 data32 data32 data32 nopw %cs:0x0(%rax,%rax,1) what instruction do? to more detailed trying understand how compiler optimize useless recursions below o2 optimization: int foo(void) { return foo(); } int main (void) { return foo(); } the above code causes stack overflow when compiled without optimization, works o2 optimized code. i think o2 removed pushing stack of function foo, why data32 data32 data32 data32 nopw %cs:0x0(%rax,%rax,1) needed? 0000000000400480 <foo>: foo(): 400480: eb fe jmp 400480 <foo> 400482: 66 66 66 66 66 2e 0f data32 data32 data32 data32 nopw %cs:0x0(%rax,%rax,1) 400489: 1f 84 00 00 00 00 00 0000000000400490 <main>: main(): 400490: eb fe jmp 400490 <main> you see operand forwarding optimization of cpu pipeline. al...

PHP array passed by reference? -

i've been looking answer issue have array far no answer here nor web. we have typo3 website has indexed search configured , installed. crawl records (~60000) using crawler extension. configured , running fine saw records not appearing on search results. i debugged typo3 code , found words not related records in index_rel table. what found when running code enters method indextypo3pagecontent() on line 573 method checkwordlist() called array of words passed argument. inside method there unset of array values. wrong because if right array passed value, array outside method checkwordlist() changed, there less words. therefore words not reverse indexed record. i can change code. easy. want understand problem. php bug? aren't php arrays passed value? using php 5.5 on ubuntu. if can giving hint of what's happening appreciate much. anyway posting bug on typo3 bug system. bests, b. arrays passed value indeed (or have pointed reference if not...

android - Native heap continues to grow by regular amounts though java heap holds steady, then fatal signal 6 crash -

my android app loads great deal of images using universal image loader in series of fragments. i've checked hprofs in memory analyzer , after fixing various leaks not seeing more. ddms java heap size increases bit around 16, meanwhile i'm checking debug.getnativeheapallocatedsize , seeing inflate around 90mb each fragment replace. around 600mb native heap app crashes fatal signal 6 sigabrt, while trying build image-heavy ui on data return. there's never out of memory error. is native heap increase causing fatal signal 6 crash, or stalled ui? , what's best way debug continued increase in native heap? the images red herring. fatal 6 indeed related ever-growing native heap. besides lots of images, app created lot of custom textviews each screen, , previous developer had typeface.createfromasset call in init these custom textviews. thousands of typefaces being added native heap. lazily creating static typeface once fixed this. to debug, best approa...

Android full screen theme for ICS and above -

what android theme should used if want full screen activities white backgrounds running on devices supporting api 14+? try in oncreate public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.main); }

jquery - Reset function on game not working -

i've been making simple tile match game using jquery , okay except after game completed doesn't reset correctly after clicking modal box) , can no longer click divs play again. to see game , code please go http://codepen.io/acnorrisuk/pen/jdogvp/ have console.logged array of values can cheat way through game see happens when resets. the reset function below: function newboard() { // reset variables tiles_flipped = 0; temp_values.length = 0; tile_values.shuffle(); tile1 = ''; tile2 = ''; $("#board").empty(); $(".tile").removeclass("transform"); $("#score").html("<p>pairs found: " + 0 + "</p>"); // gives each div unique tile number , inserts images (var = 0; < tile_values.length; i++) { $("#board").append("<div class='flip-container flip'>\ <div class='tile flipper' id=...

postgresql - How to find database name in rails console -

this odd. in rails 4 database.yml have following: development: adapter: postgresql encoding: unicode database: inspector_development password: pool: 5 i copied production database heroku , imported using form local copy of postgresql curl -o latest.dump `heroku pgbackups:url --account personal` pg_restore --verbose --clean --no-acl --no-owner -h localhost -u sam -d inspector_development latest.dump the result showed 88 expected users in pgadmin in inspector_development database on osx. however, after restarting rails app, user table still shows 1 user, not 88 see in pgadmin. i've googled how determine rails sees properties of database name in order determine finding these non-existent records? looking more closely @ user table in pgadmin see 0 columns. perhaps pgadmin mistaken? i'm unable determine db rails looking can troubleshoot this, thx, sam this works in rails 3 , rails 4 activerecord::base.connection.current_database but works driv...

java - How to fetch the list of users from ParseUser table and show the it in list view in andorid -

i trying list of first names of users parseuser table crashing error: doing work on main thread. works when try fetch other parseobjects doesn't work parseuser table. following code mainactivity.java public class mainactivity extends actionbaractivity { // declare variables listview listview; list<parseuser> ob; progressdialog mprogressdialog; arrayadapter<string> adapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); parse.initialize(this, app, secret); new remotedatatask().execute(); } // remotedatatask asynctask private class remotedatatask extends asynctask<void, void, void> { @override protected void onpreexecute() { super.onpreexecute(); // create progressdialog mprogressdialog = new progressdialog(mainactivity.this); // set progressdialog title ...

c++ - Sorting using objects in vectors -

i have function computing , set value returned vector. #include <vector> #include <algorithm> #include <iostream> void vectorloop(vector<classname>& vector) { float tempfloatvariable = 0.0; int count = 0; int update = 0; while (count != vector.size()) { if (vector[count].getvalue() == 100.0) //i hardcode can check if value empty or not { //code set of variable vector's memory's object tempfloatvariable = anotherclass.formula //does computing , return value //code gets value object overloading //code gets value object overloading //code gets value object overloading vector[count].setvalue(tempfloatvariable); update++; } else { count++; } } cout << "computation completed! (" << update << " record(s) updated)" << endl; } after of computing done, want sort them highest lo...

tableau - Filtering Values from Two Data Sets -

Image
i new tableau , having trouble finding way filter between 2 data sets. these sets tableau data extracts unable create custom sql achieve this. in dataset1 have levels of precipitation date. in dataset2 have sales revenue per date , store location. i trying visualize sum of sales revenue per store location on days precipitation. thought able create filtered list of dates in dataset1 saw precipitation subsequently filter dates in dataset2 = filtered list. any thoughts on how go this? feel should relatively simple, being unfamiliar software having trouble locating solution. thanks! please data blending tableau.it interesting feature in tableau link multiple data sources 1 sheet.it can laggy @ times use carefully. tutorial links: http://www.tableau.com/learn/tutorials/on-demand/data-blending-0 http://kb.tableau.com/articles/knowledgebase/relate-summarized-data-60 also screenshot below shows option edit relationships between data sources data blending