Posts

Showing posts from September, 2013

c - Is InternetOpenUrl function on Windows secure enough? If not, how to make it stronger? -

the internetopenurl() documentation says: wininet functions use simple check against certificates comparing matching host names , simple wildcarding rules. that suggests it's not doing much, , can circumvented e.g. forging self-signed certificate. on other hand, kb 182888 "how handle invalid certificate authority error wininet" suggests wininet functions indeed checking root ca. what truth? internetopenurl() fail if cert not valid. or if not fail, verify cert ourselves, in simplest possible way. how can it? tl; dr; yes, internetopenurl() checks certificate authority default. i did little test: #include <cassert> #include <iostream> #include <windows.h> #include <wininet.h> int main(int argc, char *argv[]) { hinternet internet = internetopena("test agent", internet_open_type_direct, null, nu

sockets - Multiplayer game in Java. Connect client (player) to game that was created by other client -

i working on multiplayer game , cant find out how can connect other clients created game. mean client create socket connection server , how other clients (a,b...) can connect client a? can me please? p.s. i'm new network programming, if can attach example grateful. another client cannot connected client because of firewall. you can create 2 majors kinds of network: server-client peer-to-peer but client can save data server , server can send them clients (you don't need peer-to-peer network allow client b send data client a). example: client b send map position server, server send data clients, client able draw character tileset @ position of client b. for connect 2 pcs together, need forward port modem of server pc used server, , open port firewall of pc used server. you can take here creating multiplayer game in python , give example clients able connect them irc , play @ tic-tac-toe game (so didn't have manage server). have add example in jav

jquery - FluentValidation: Get CustomState on client side -

i want integrate bootstraps .alert alert-warning classes fluentvalidation show/hide warning messages. thought put custom state on rule , send client side show , hide alert message, cannot figure out. here have far: public class foovalidator : abstractvalidator<foovm> { public foovalidator () { rulefor(model => model.temperature) .notnull() .lessthanorequalto(model => model.maxtemp) .withstate(model => validationtype.warning) .withmessage("warning, temp should less or equal {comparisonvalue}") .greaterthanorequalto(model => model.mintemp) .withstate(model => validationtype.warning) .withmessage("warning, temp should greater or equal {comparisonvalue}"); } } and here lessthanorequalto validator client rules. please note have todo @ end set state argument client public class lessthanorequalpropertyvalidator : fluentvalidationpropertyvalidator {

python - Matplotlib can't give up old argument -

i made mistake in command matplotlib: newline.=plot((x0,x1),(y0,y1),color='light grey') turns out there no "light grey". well, figured fix it: newline.remove() newerline,=plot((x0,x1),(y0,y1),color='grey') but matplotlib returns same horrendously long error message, root problem being exc = valueerror(u'to_rgb: invalid rgb arg "light grey"\ncould not convert string float: light grey',) that is, somehow, matplotlib thinks still trying plot "light grey". have tried few things around this, won't give light grey problem. it's offended or something. have ideas? pretty complex plot. don't want tear down , start again. if matters, running python on enthought canopy 1.5.2, linux.

html - div backgrounds, except header, wont show up? -

this question has answer here: inline nav example doesn't work [duplicate] 1 answer ive searched around week, havent found answer helps me. im basic @ html , experience have neopets lol im making page class @ school, , have 3 div ids active in page. header div works fine, maincontent , navigation ids seem ignore fact want bg colour orange. appreciated! html: <html><head><title>gumi megpoid | home</title></head> <body> <div id="header"><h1>gumi megpoid</h1></div> <div id="navigation"> <p><a href="{text:link 1 url}">home</a> <a href="{text:link 2 url}">albums</a> <a href="{text:link 3 url}">lyrics</a> <a href="{text:link 4 url}">tours</a> </p></div> <div id=”mainconten

osx - How to pass two Strings from Swift to a C++ function, and getting an array of Integers? -

i trying pass 2 strings swift c++ function, handle them there, , return array of integers (probally vector), not sure yet. i've tried (c++ function declaration): void exmaple(char* one, char* two); but not able pass strings swift c++. then changed function little: void example(void* one, void* two) { string &a = *reinterpret_cast<string*>(one); string &b = *reinterpret_cast<string*>(two); cout<<"string b is: "<<b<<endl; } and tried calling function in swift: let astr = unsafemutablepointer<string>.alloc(10) astr.initialize("stringa") let bstr = unsafemutablepointer<string>.alloc(10) bstr.initialize("stringb") example(astr, bstr) but output is: string b is: how can pass 2 strings swift c++ function, , return array/vector of integers? swift has magic bridging allows pass regular swift strings directly c functions. example, strlen has signature size_t st

javascript - Exporting a d3.js overlay on top of a Bing Map using html2canvas -

Image
has attempted use html2canvas bing maps. have been able html2canvas work google maps need work bing maps. when attempt export svg d3.js overlay ontop of bing map looks this? my html2canvas export code follows: html2canvas($svg, { proxy: "", usecors: true, background: "#e8f0f6", onrendered: function (canvas) { var = document.createelement('a'); a.download = name; a.href = canvas.todataurl('image/png'); document.body.appendchild(a); a.click(); }, width: 450, height: 700, });

javascript - Refresh page when container div is resized -

this simple , pretty straightforward question: if media query breakpoints set @ 750px , 970px, using jquery, possible refresh page after width of .container div changes on browser resize , how? you want use media query instead but, can listen resize event if want this: addeventlistener('resize', function() { location.reload(); }); if want reload if breakpoint past, can keep track of last innerwidth , reload if value crossed. or instead of using innerwidth, use width of div. example: var last = document.getelementbyid('mydiv').clientwidth; addeventlistener('resize', function() { var current = document.getelementbyid('mydiv').clientwidth; if (current != last) location.reload(); last = current; });

ember.js - I need some ideas for this. Emberjs -

i have helper named format-log //format-log.js import ember 'ember'; export function formatlog(text) { var hashtag = text.match(/[#]\w+/g); var newtext = text; if (hashtag !== null && hashtag !== undefined) { ( var = 0; < hashtag.length; i++){ newtext = newtext.replace(hashtag[i], "<a href='' class='hash'>"+ hashtag[i] +"</a>"); } return newtext; }else{ return text; } } export default ember.handlebars.makeboundhelper(formatlog); when make new log, have need add hashtag example "this example #log" that text go-through helper , returns format "this example < href="">#log< /a>" i wanna filter log contains same hashtag make trends twitter, using ember cli , ember-data my model //log.js import ds 'ember-data'; export default ds.model.extend({ text: ds.attr('string'),

jquery - Lose focus and move on for div tag -

in website have following code in angular : <div class="create-new-type"> <a ng-repeat="type in availabletypes" href="/{{type.type_name | lowercase}}/" ng-bind="type.name"></a> </div> i have div tag hidden , appears when user clicks on menu. div tag appear left side of window. problem when user clicks on tab button still shows focus on these links hidden. how (in jquery) tell skip elements in div focus if it's not showing , move on next element? i read below regarding this: how allow keyboard tab focusing on div navigate ui using keyboard use display:none hide links instead of other things opacity or height 0

c# - Non-Entity Class Requiring [Key] Attribute -

i getting entitytype 'schedulenote' has no key defined. define key entitytype. poco has nothing entity framework. ef require define [key] every class in project whether or not deals database? update: here schedulenote code: using system; namespace domain { public class schedulenote { public string noteid { get; set; } public notetypeenum type { get; set; } public string typefk { get; set; } public string userid { get; set; } public string authorname { get; set; } public string subject { get; set; } public string message { get; set; } public datetime? startdate { get; set; } public datetime? enddate { get; set; } public datetime insertdate { get; set; } public datetime? deletedate { get; set; } public bool ispublic { get; set; } public bool ismodified { get; set; } public bool isdeleted { get; set; } } public enum notetypeenum {

c - Why does this execute a jump instruction? -

i have seen interesting c code in boot loader of small embedded product. the code consists of 2 parts: boot loader , main code. start of main code address stored in function pointer. below code i'm talking about typedef struct { uint32_t myotherfield; void (*maincodestartaddress)(void); } mystruct; mystruct mystruct = {0x89abcdef, 0x12345678}; void main(void) { // code ... mystruct.maincodestartaddress(); // jump start of application } i can't figure out why works? why machine go application code? appreciated. the construct void (*maincodestartaddress)(void) declares function pointer named maincodestartaddress . point function taking no arguments , doesn't return anything. you can assign function of same type function pointer, example: void some_function(void) { // useful } mystruct.maincodestartaddress = some_function; then can call this: mystruct.maincodestartaddress(); // same calling some_function(); in example fixed addre

Pattern matching while reading from the files using Perl -

i'm running issue while reading file , matching pattern file content 1: recturing svc 2: finance : : 9: payments : : 19: mobile : : 29: bankers my code looks this open(inputfile, "<$conf_file") or die("unable open text file"); foreach (<inputfile>) { print "$_"; } close inputfile; print "please choose number list above: "; chop($input = <stdin>); $input = trim($input); print "your choice was: $input\n"; $temp = "$input:"; open(inputfile, "<$conf_file") or die("unable open text file comparision"); foreach $line (<inputfile>) { if ($line =~ /$temp/) { print " exact match: $& \n"; print " after match: $' \n"; $svc = $'; print "servicel $svc \n"; } } close inputfile; it matching multiple items, example 9: , 19: , 29: when select. example, if enter 9 prints 9: payments 19: m

java - index out of bounds error why? -

the line x.set(7,y) in code below throwing indexoutofboundsexception , , can't figure out why. can help? linkedlist<myclass> x = new linkedlist<myclass>(); x = myarraylist.get(7); iterator<myclass> itr = x.iterator(); myclass y = new myclass(); while (itr.hasnext()) { y = itr.next(); if (z.methodcalltogetstr().equals(y.methodcalltogetstr()))//z myclass object { y.inccount(); x.set(7, y); break; assuming myarraylist.get(7) creates 7 elements, these elements numbered 0 6. 7th 1 off end of list.

php - MySQL returns 2 values for every field requested -

this question has answer here: how stop mysql duplicating every column's entry in returned arrays? 4 answers when doing query() select statement results contain 2 entries field. $sql = "select first_name, last_name users"; $rslt = $conn->query($sql); in example above, results contain 4 items in array. 2 incrementing integers key, 1 key set "first_name" , 1 key set "last_name". array ( [first_name] => bill [0] => bill [last_name] => johnson [1] => johnson ) i'm sure stupid question, there quick way either change way results returned contains 1 key=>value each field or there way remove data? what want final array 1 of 2 things... required result 1 array ( [first_name] => bill [last_name] => johnson ) required result 2 array ( [0] => bill [1] => johnson ) thanks in advance.

java - Android listview custom rows -

i have problem custom layout i've set listview. have button adds elements listview , uses custom row everytime try press button add crashes. can suggest solution on how fix this? i'm pretty new android btw. here's code: import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.button; import android.widget.listadapter; import android.widget.listview; import java.util.arraylist; public class projectcreatescreen extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.secondary_layout1); button btn = (button) findviewbyid(r.id.addbtn); final arraylist<string> listitems=new arraylist<string>(); final listadapter addadapter = new arrayadapter<string>(this, r.layout.custom_row, listitems);

embedded - How can I use crt0.o to setup .bss and .data in my bare metal C program? -

i wrote bare metal c program running on stm32f4. it's nothing fancy, usual led-blinky-program. in project have written initialization routines clearing .bss section , initializing .data section myself. this wasn't complicated. in linker script, instructed linker create symbols marking start , end of .data , .bss section. .data 0x20001000 : align(4) { __etext = loadaddr(.data); __data_start__ = addr(.data) ; *(.data*) ; __data_end__ = addr(.data) + sizeof(.data) ; } >ram at>rom .bss : align(4) { __bss_start__ = addr(.bss) ; *(.bss*) ; __bss_end__ = addr(.bss) + sizeof(.bss) ; } >ram then using these symbols in code: extern unsigned int __etext; extern unsigned int __data_start__; extern unsigned int __data_end__; extern unsigned int __bss_start__; extern unsigned int __bss_end__; void reset_handler() { unsigned int * src; unsigned int * dest; src = &__ete

How Hadoop stores emails data -

i'm naive big data field. started exploring tools hadoop , got clarity framework , map/reduce framework still have lot of questions: want analyse emails , email categoriation can organise emails different categories wondering how should store emails hdfs. should first of convert emails text file (composed of spaced-separated columns: date, author, subject, content..) or sequence file composed of binary key-value pairs , store file hdfs ? i'm not used work sequence files read many articles how hdfs store unstructured data type of file. can please enlighten me? thanks in advance.

sql - Return records based on the result of a function -

i have records follows: 1) bel 1) mersen a) vishay-sprague circuit partners bentek circuit test i want return distinct set if record has closing bracket, remove entire bracket prefix ( 1) mersen becomes mersen) otherwise return record is. ad hoc, 1 off query. i've tried this. if (charindex(')', (select [manufacturer] [dbo].[qpl_itmsupac_nf]), 1) > 0) select distinct substring([dbo].[qpl_itmsupac_nf].[manufacturer], 4, 99) [dbo].[qpl_itmsupac_nf] else select distinct [dbo].[qpl_itmsupac_nf].[manufacturer] [dbo].[qpl_itmsupac_nf] ...but error: subquery returned more 1 value... the above in procedure. thoughts? use exists , move function subquery. in case, charindex() equivalent like ')%' : if (exists (select 1 [dbo].[qpl_itmsupac_nf] manufacturer ')%') ) select distinct substring([dbo].[qpl_itmsupac_nf].[manufacturer], 4, 99) [dbo].[qpl_itmsupac_nf] else select distinct [dbo

d3.js - Y axis level need to be moved little left in dc.js chart -

Image
i drawing charts using dc.js.the following frequency vs day chart i using following line generate titles: ..something.yaxislabel("frequency").xaxislabel('day'); but problem see when frequency large y axis title colliding frequency numbers. there simple way move y axis title left? the layout of auxiliary elements such axes , legends not automatic in dc.js; use .margins() adjust necessary. https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#marginsmargins it great figure out automatically difficult calculate, , easy work around, guess no 1 has gotten annoyed enough submit fix. :)

git - Github- Cloning a private repo to a public repo -

i making android project under supervision of professor has given me access private repo created project. wondering whether can make repo(public) project can reflected onto profile , 1 can see that? also there way sync these 2 repos if ppush one, other automatically gets updated? i new @ github , great me.thank in advance. you need add other repo remote client, , push it, in terminal can this: git remote add public https://github.com/user/repo.git and then git push public master if using kind of ui git can add remote way , push.

JavaScript NaN equvialence -

this question has answer here: what rationale comparisons returning false ieee754 nan values? 12 answers just fun trying compare value set nan value set nan. why 2 variables, identical values, not equivalent? var = number.nan var b = number.nan === b false == b false var = nan var b = nan === b false == b false why happen? nan not number, there no evaluated numberic value compare - use isnan() compare nan values. w3 schools link

python - Sort 2D numpy array (by row) based on another 2D array of same shape -

with 2 arrays: x = np.array([[1,2,3], [2,3,1]]) x array([[1, 2, 3], [2, 3, 1]]) y = np.array([['a','b', 'c'], ['a','b', 'c']]) y array([['a', 'b', 'c'], ['a', 'b', 'c']], dtype='|s1') i trying sort y based on values of x row row without looping through each row, i.e xord = x.argsort() in range(x.shape[0]): print y[i][xord[i]] ['a' 'b' 'c'] ['c' 'a' 'b'] is there more efficient way sort array y based on corresponding row order of x? first can use np.argsort indices of x elements based on position after sorting,then can elements y based on indices of x np.take() : >>> s=np.argsort(x) >>> np.take(y,s) array([['a', 'b', 'c'], ['c', 'a', 'b']], dtype='|s1')

Accessing BigCommerce Logged In user from wordpress on subdomain -

so need way lock down both bigcommerce , wordpress if user not logged in. first suggestion asking if when user created in bigcommerce create same user account in wp... doesn't seem approach me since user not need interaction user on wp need block access pages if not logged in. so thought check if user logged bigcommerce, pass variable wp header file. if variable not exist redirect them bigcommerce login. install bigcommerce using header wp match , works why assume should able pass variable check if user logged bigcommerce or not. have not been able find documentation in api accessing if user logged in or not. has done , or know if possible? or know of better solution trying do. maybe check cookie or session? recently did project client wanted show custom content bigcommerce loggedin users , block rest. best way found check value of %%global_currentcustomerfirstname%%. "guest" non-loggedin users. can try this: localstorage.setitem("user", %%gl

c++ - How to initialize object in different class? -

i'm learning c++ , have problem basics. how init object in different class? for example have code: class { private: static int num; static string val; public: a(int n, string w) { num = n; val = w; } }; i want create object in class b, have try this: class b { private: obja; public: b(int numa, string vala){ obja = new a(numa, vala); } }; different ways(same constructor): public: b(a oba){ obja = oba; } or public: b(int numa, string vala){ obja = a(numa, vala); } always i'm getting error: no default constructor exist class "a". i've read default constructor constructor without arguments, give them, why searching default? you can following way class b { private: obja; public: b(int numa, string vala) : obja( numa, vala ) {} };

hadoop - Append a value to a PIG variable -

i need append value declared variable in pig. %declare desc 'test/nimmiv/pig' raw = load 'test.log' using pigstorage('\t') (a1:chararray, a2:chararray, a3:long); /* pig processing */ value = foreach raw generate $0; tmp = foreach raw generate $1 path; path = distinct tmp; /* dump path give me (tmp) , need append value exisitng value test/nimmiv/pig=>test/nimmiv/pig/tmp */ store value '$desc/$path'; this throwing undefined alias error. easiest way append value existing path. the undefined alias "value" doesn't seem have been introduced before , have exist before attempted store on it.

external - Apache/PHP not being able to access mounted drive -

i'm trying access mounted drive within php/apache (lamp @ centos). instance doing scandir: scandir($dir); although works fine directory on same physical disc apache installed @ (including root, var, etc, ..), not work external mounted disks: scandir('/var/log'); on local drive holds /var/www/html delivers valid output, whereas scandir('/mnt/data'); (which mount external fs) doesn't. i have been experimenting filesystem permissions , httpd.conf directives (alias / directory), have not been able find solution yet. can point me direction of how access external drives (/mnt/whatever) apache/php? thx! if process can see mount point able access files within provided permissions, including acls , mac system allow it (mac here referring mandatory access control systems, i.e. selinux , apparmor). either permissions need changed or webserver running in chroot environment (e.g. sees / /var/websrv/) or have not made right changes httpd config

wordpress - htaccess 301 for new page name across all subdomains -

i'm running wordpress multisite network multiple sites across subdomains. need change url of page copied across of them , setup redirect old url. examples: xyz.site.com/about-our-group redirect xyz.site.com/about abc.site.com/about-our-group redirect abc.site.com/about how can achieve in .htaccess file? you can use rule first rule below rewritebase line: rewriterule ^about- /about [l,nc,r=301]

Paste all combinations of a vector in R -

i have vector say: vec = c("a", "b", "c") and want paste single combinations of every item in vector result ab ac bc i know can use outer possible combinations of vector, stumped how result above. order doesn't matter in case, result plausibly be ba ca cb i need combine single pairs. sam try combn combn(vec,2, fun=paste, collapse='') #[1] "ab" "ac" "bc"

directx - Texture streaming in DirectX11, Immutable vs Dynamic -

we have case need stream textures graphics card (in game case: terrains, in case image different input sources cameras/capture cards/videos) of course in camera case, receive data in separate thread, still need upload data gpu display. i know 2 models it. use dynamic resource: create dynamic texture has same size , format input image, when receive new image set flag tells need upload, , use map in device context upload texture data (with eventual double buffer of course). advantage have single memory location, hence don't have memory fragmentation on time. drawback need upload in immediate context, upload had in render loop. use immutable , load/discard in case upload in image receiving thread, creating new resource, push data , discard old resource. advantage should have stall free upload (no need immediate context, can still run command list while texture uploading), resource can used simple trigger once available (to swap srv). drawback can fragment memory on

r - Finding percentage in a sub-group using group_by and summarise -

i new dplyr , trying following transformation without luck. i've searched across internet , have found examples same in ddply i'd use dplyr. i have following data: month type count 1 feb-14 bbb 341 2 feb-14 ccc 527 3 feb-14 aaa 2674 4 mar-14 bbb 811 5 mar-14 ccc 1045 6 mar-14 aaa 4417 7 apr-14 bbb 1178 8 apr-14 ccc 1192 9 apr-14 aaa 4793 10 may-14 bbb 916 .. ... ... ... i want use dplyr calculate percentage of each type (aaa, bbb, ccc) @ month level i.e. month type count per 1 feb-14 bbb 341 9.6% 2 feb-14 ccc 527 14.87% 3 feb-14 aaa 2674 .. .. ... ... ... i've tried data %>% group_by(month, type) %>% summarise(count / sum(count)) this gives 1 each value. how make sum(count) sum across types in month? try library(dplyr) data %>% group_by(month) %>% mutate(countt= sum(count)) %>% group_by(type, add=true) %>% mutate(per=paste0(round(1

cordova - PhoneGap: Device orientation under iOS -

Image
i created new phonegap app using following phonegap create hello-world com.hello.world helloworld with phonegap 4.2.0-0.25.0. however, not able change viewport orientation landscape on iphone or simulator. tried following 2 methods within config.xml. <preference name="orientation" value="default" /> <preference name="orientation" value="landscape" /> i still not able use app in landscape mode. (of course disabled rotation locks on iphone.) does know how solve this? i tried , worked fine. sure set correct options in xcode this: before build clear project -> cordova create orientationchange com.example.com orientationchange cd orientationchange cordova platform add ios cordova plugin add org.apache.cordova.console (you don't need orientation change it's useful debugging). cordova build run project in xcode (6.3 actual version) , give try - should work! let me know if need further help

fasta - Search and import multiple words from txt file on Biopython -

well, have fasta file has info protein in .txt , want search "string" comes after pattern , import it/write txt. comes this: >gi|1168222|sp|p46098.1| ....(text)... >gi|74705987|sp|o95264.1| ....(text)... and want accession numbers (acc): sp|**p46098**.1| , save them in file in column. there different acc throughout text , want comes after sp| , before . or if doesn't have . before next | . is there easy way of doing in biopython ? thanks this answer uses biopython extent it's possible to, uses regular expressions rest (biopython id you, not accession number alone): from bio import seqio import re open('output.txt', 'w') outfile: # open writing in seqio.parse('input.txt', 'fasta'): # parse fasta m = re.search('sp\|(.*)\|', i.id) # sp|.*| in id if m: outfile.write(m.group(1).split('.')[0] + '\n') # take what's before first dot, if just note un

scala - Why do one of these split & filter work but not the other? -

val c = s.split(" ").filter(_.startswith("#")).filter(x => x.contains("worcester") || x.contains("energy")) works but not val c = s.split(" ").filter(_.startswith("#")).filter(_.contains("worcester") || _.contains("energy")) i have not understood why latter not work - may have flaw in fundamentals any appreciated sumit using underscore known placeholder syntax. so, _.contains("x") equivalent x => x.contains("x") . can use each parameter once when using placeholder syntax. using multiple placeholders denotes multiple parameters of anonymous function (which used in order of underscores). so, when write: o.filter(_.contains("worcester") || _.contains("energy")) it theoretically equivalent to o.filter((x, y) => x.contains("worcester") || y.contains("energy")) which doesn't type check, since filt

csv - How can I output all the output of a called command in Powershell script -

i have adapted existing powershell script query list of servers logged in (or disconnected) user sessions using quser /server:{servername} , output results csv file. output logged in users doesn't capture servers had 0 users or weren't accessible (server offline, rpc not available, etc.). i'm assuming because these other conditions "errors" rather command output. so if hits server no users outputs "no user exists *" in console running script. if hits server can't reach outputs "error 0x000006ba enumerating sessionnames" , on second line "error [1722]:the rpc server unavailable." in console running script. neither of these conditions show in output.csv file. i wanted know if suggest how capture these conditions in csv "$computer has no users" , "$computer unreachable" here script $serverlist = read-host 'path server list?' $computername = get-content -path $serverlist foreach ($compu

Python Packages and Modules -

i've never needed use packages , modules before in python code base getting bigger , bigger i'd structure imported easier. i've got 10+ .py files part of package. instead of doing import each , every class when need them, how can group them in same name space can reference import package.componenta x ? right when ever utilize code, got have source files in same directory. possible package in central location can have clean project code? thanks, use __init__.py file in package , import modules want use there. when import package import in file. some info on method here .

python - KIVY performance as compared to pyqt's QGraphiscscene -

here general problem struggling with i trying create pyqt application renders thousands of points in zoom-able, pannable graph,(think star field each point represents star/planet) there 5000 points when zoomed out. user allowed interact items on scene zooming, , dragging or panning around. quite choppy , slow number of points increase several thousand. make application more responsive user interaction(zoom,dragging , panning) currently seems qgraphicsscene/qgraphicsview not per-formant/fast when there thousands of points allow user interaction. comparing kivy , wondering if qgraphicsscene/qgraphicsview correct technology/toolkit doing want. qgraphicsscene/qgraphicsview powerful/per-formant touted kivy? note: i'm using pyqt , python 2.7, , i've had cursory read kivy with careful use of kivy's graphics api, handle 5000 points trivially, since it's opengl behind scenes. panning fast, , zooming can fast or slower (but maybe still enough) depending on ho

node.js - Sequelize chaining methods -

i resql changing sequelize's function of: students.find({where: {id: 34235}}).success(function(student) { student.getcourses().success(function(courses) { console.log(courses); }); }); to: students.one({id: 34235}).courses().then(function(courses) { console.log(courses); }); i wondering if there way sequelize? for example: models.user.find(1).getproducts() i keep getting error: typeerror: object [object promise] has no method 'getproducts' thanks! this not possible in sequelize - node async nature, , have way user found before can call getproducts . however can use includes: user.find({ where: { id: x }, include: [course] }).then(function (user) {; this left join user course , able access user.course (or user.course , depending on name of course model)

Can I mount docker host directory as copy on write/overlay? -

i'd mount host directory in docker on outside read/only. i'd appear inside container read/write. so files/directories can written not changed on outside. possible using kind of overlay process? this do: on host: load directory read only. docker run --privileged -v /path/on/host:/path/on/client-read-only:ro -it ubuntu /bin/bash on client: on client use overlayfs on read-only directory mounted host. mount -t overlayfs none -o lowerdir=/path/on/client-read-only,upperdir=/path/on/client /path/on/client then use /path/on/client read/write files. edit : if have 3.18+ kernel on host, may prefer using on client: mount -t overlay overlay -o lowerdir=/path/on/client-read-only,upperdir=/path/on/client,workdir=/path/on/client-workdir /path/on/client which isn't overlayfs . overlayfs had issue regarding being unable use rm . overlay solved problem me.

c - Memory representation of differemt translations units -

how different translation units represented in memory? for e.g. //internallinkage.h static int var = 10; //file a.h void updatestatica(); //file a.cpp #include "internallinkage.h" void updatestatica() { var = 20; } //file b.h void updatestaticb(); //file b.cpp #include "internallinkage.h" void updatestaticb() { var = 30; } //main.cpp #include "internallinkage.h" #include "classa.h" #include "classb.h" int _tmain(int argc, _tchar* argv[]) { updatestatica(); updatestaticb(); printf("var = %d",var); } the output here 10 know have 3 translations units each having there own copy of static variable var. question is how these translation units maintained in memory? do have separated sections each translation unit in memory compiler can maintain static variable 'var' each translation unit? clearly there 3 different copies of variable 'var' in memory how compiler maintain copy bel

Firebase - How many databases can be created? -

is there limit number of databases created in firebase. each database have it's own login , security credentials keep data separate. https://xyz_customer_one.firebaseio.com https://xyz_customer_two.firebaseio.com https://xyz_customer_three.firebaseio.com . . . https://xyz_customer_one_million.firebaseio.com you can have 10 firebases on free plan. there no limit on number of paid firebases.

How to Enable a .NET Web Service to Receive Large Amounts of Data? -

how enable .net web service receive large amounts of data ? i have .net web service should receive several large files , save them in directory on local hard disk. program (running on computer on same network) tries call web service receives error: "line long". any suggestions? thanks, luis. code: method: public function receivefiles(byval filecontents string, byval fileinfo list(of string), byval listbinaryfilecontents list(of byte()), byval liststringfilecontents list(of string)) string() implements ireceivefiles.getdatareceivefiles ... datacontract: <operationcontract()> function getdatareceivefiles(byval filecontents string, byval fileinfo list(of string), byval listbinaryfilecontents list(of byte()), byval liststringfilecontents list(of string)) string() webconfig: <appsettings> <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true" /> </appsettings> <system.web>

c - Can anyone explain why my Merge Sort is not working? -

can please explain why not working? i'm having trouble getting numbers in array sorted , placed empty b array. i've searched high , low there seems eludes me, fellow cod3rz! #include <stdio.h> #include <string.h> void merge(int array[], int low, int mid, int high); void midpoint(int array[], int low, int high); int main(int argc, const char * argv[]){ int b[100]; int array[] = { 13, 23, 37, 45, 55, 68, 79, 93}; int arraylength = sizeof(array)/sizeof(array[0]); (int =0 ; < arraylength; i++){ ( int j= 1 + ; j < arraylength; j++){ midpoint(&array[i], ,j );{ } printf("%d\n", *b); } } return 0; } void merge(int array[], int low, int mid, int high) { int b[100]; int b[100]; int = low; int b[100]; int j = mid + 1; int b[100]; int k = 0; while (i <= mid && j <= high) { if (array[i] <= array[j]) b[k

android - Struggling with a top level FragmentPagerAdapter containing a Fragment with its own FragmentPagerAdapter -

have 2 level ui, top level has tab strip powered fragmentpageradapter. 1 of fragments in turn has 2nd level fragmentpageradapter , own tab strip carrying couple of "sub"fragments. now, sub fragments display when first time top level tabs traversed. "sub"fragments not display upon 2nd iteration here how subtabpager adapter created in 1 of fragments exist @ top level public final class mainleveltabfragment extends fragment { private subpagetabspageradapter msubpagepageradapter; private viewpager msubpageviewpager; private slidingtablayout mslidingtablayout; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = null; bundle bundle = getarguments(); rootview = inflater.inflate(r.layout.fragment_tab_main_level, container, false); msubpageviewpager = (viewpager) rootview.findviewbyid(r.id.subpage_screen_tabs_pager); mslidingtablayo

Tetris Shape Generation Algorithm in Java -

i'm building tetris game in java using software design patterns. basically, created factory algorithm retrieves string figure out type of tetris object make when it's given request main game loop, see code: public class tvshapefactory { protected tvshape tvshape = null; protected gamecontainer gc; tvshapefactory(gamecontainer gc) { this.gc = gc; } public tvshape createshape(string shape) { if (shape=="tvishape") { tvshape = new tvishape(gc); } else if (shape=="tvoshape") { tvshape = new tvoshape(gc); } else if (shape=="tvlshape") { tvshape = new tvlshape(gc); } else if (shape=="tvzshape") { tvshape = new tvzshape(gc); } else if (shape=="tvjshape") { tvshape = new tvjshape(gc); } else if (shape=="tvsshape") { tvshape = new tvs

performance - Very Large Fibonacci in Java -

i trying rapidly calculate large fibonacci numbers. here code. prohibitively slow numbers above 1 million, how can improved? public static biginteger fib(biginteger n) { int k = n.intvalue(); biginteger ans = null; if(k == 0) { ans = new biginteger("0"); } else if(math.abs(k) <= 2) { ans = new biginteger("1"); } else { biginteger km1 = new biginteger("1"); biginteger km2 = new biginteger("1"); for(int = 3; <= math.abs(k); ++i) { ans = km1.add(km2); km2 = km1; km1 = ans; } } if(k<0 && k%2==0) { ans = ans.negate(); } return ans; } binet's worked well. guys! one way calculate (n-1)th power of 2x2 matrix: a = ((1, 1), (1, 0)) then have fib(n) = a^(n-1)[0][0], n >= 1 and power of matrix a can calculated efficien

.net - Request from C# to Apache: The underlying connection was closed: An unexpected error occurred on a receive -

i have 2 linux apache servers running behind load balancer. on both apache server have installed same installation of yourls api shortening urls. sending request yourls api short url. request these servers sent c# production site, shortening urls. it worked fine months, , on request start receiving error: the underlying connection closed: unexpected error occurred on receive. nothing changed in meanwhile. apache server doesn't have security restriction or something. this code request: public dynamic sendrequest(string action, namevaluecollection parameters = null) { var client = new nokeepalivewebclient(); string jsonresult = string.empty; dynamic result; //we need form url requests var data = new namevaluecollection(); data["format"] = "json"; data["action"] = action; data["signature"] = this.key; if (parameters != null) {

javascript - Override d3 index values in Force-Directed Graph -

Image
i using force directed graph draw entity relationships company. use built in index value "index" of node instead of array index. how override d3 index value gets set? fiddle - http://jsfiddle.net/thielcole/ed9noqw1/ var forcelinks = []; var forcedata = []; d3.csv('amazonexampleforicharts.csv', function(d) { return { // index use index: d.node, parent: d.parentnode, color: d.nodecolor, level: d.hierarchy_code, business: d.business_name, power: d.decisionpower, hover: d.hoverovervalue, link: d.linkvalue }; }, function(error, rows) { forcedata = rows; $.each(forcedata, function(i, d) { // console.log(d.parent); if (d.parent != "" && d.parent !== undefined) { // generating link information here, have subtract 1 match array index forcelinks.push({source: parseint(d.parent , 10) - 1 , target: parseint(d.index , 10) - 1, v