Posts

Showing posts from January, 2013

c++ - Invalid read of size 1 in tetris using valgrind -

i trying write tetris dynamic 2d array of rows , cols named data; make function called edit_2darray duplicate original 2d array , make each column longer, , rest fill space; ==21909== invalid read of size 1 ==21909== @ 0x100002c0a: tetris::print() const (main.cpp:300) ==21909== 0x1000011cb: test_example() (main.cpp:59) ==21909== 0x100001053: main (main.cpp:36) ==21909== address 0x10080a9c1 1 bytes inside block of size 2 free'd ==21909== @ 0x1000132f7: free (in /usr/local/cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==21909== 0x100005188: tetris::edit_2darray(int, int) (tetris.cpp:214) ==21909== 0x1000056ec: tetris::add_piece(char, int, int) (tetris.cpp:279) ==21909== 0x10000118f: test_example() (main.cpp:57) ==21909== 0x100001053: main (main.cpp:36) ==21909== block alloc'd @ ==21909== @ 0x100012ebb: malloc (in /usr/local/cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==21909== 0x10005743d:

c# - ASP.NET File Not Found for Custom Control -

i have deployed same website application 2 servers. on server a, application works perfect. on server b, below error message comes when attempting view page loads specific custom control. error message: file '/website/controls/mycustomcontrol.ascx' not exist. stack trace: @ system.web.ui.util.checkvirtualfileexists(virtualpath virtualpath) @ system.web.compilation.buildmanager.getvpathbuildresultinternal(virtualpath virtualpath, boolean nobuild, boolean allowcrossapp, boolean allowbuildinprecompile) @ system.web.compilation.buildmanager.getvpathbuildresultwithnoassert(httpcontext context, virtualpath virtualpath, boolean nobuild, boolean allowcrossapp, boolean allowbuildinprecompile) @ system.web.compilation.buildmanager.getvpathbuildresult(httpcontext context, virtualpath virtualpath, boolean nobuild, boolean allowcrossapp, boolean allowbuildinprecompile) @ system.web.ui.templatecontrol.loadcontrol(virtualpath virtualpath) @ system.web.ui.templatecontrol.loadcontrol(

ios - Hidden status of WKInterfaceButton in WatchKit -

is there way check current hidden status of wkinterfacebutton in watchkit? it looks cannot that. can store own variable state , use it. below can check definition of button's parent class. public class wkinterfaceobject : nsobject { public func sethidden(hidden: bool) public func setalpha(alpha: cgfloat) @available(watchos 2.0, *) public func sethorizontalalignment(horizontalalignment: wkinterfaceobjecthorizontalalignment) @available(watchos 2.0, *) public func setverticalalignment(verticalalignment: wkinterfaceobjectverticalalignment) public func setwidth(width: cgfloat) public func setheight(height: cgfloat) @available(watchos 2.0, *) public func setrelativewidth(width: cgfloat, withadjustment adjustment: cgfloat) @available(watchos 2.0, *) public func setrelativeheight(height: cgfloat, withadjustment adjustment: cgfloat) @available(watchos 2.0, *) public func sizetofitwidth() @available(watchos 2.0,

android - documentation for annotation_processors (buck) -

related ticket parameters annotation processors disabled , undocumented how use annotation_processors , annotation_processor_deps ? im using realm in sample android app , without annotations (for @realmclass , @realmmoudule ) app crashes when built via buck (works if built via gradle). in case stumbles on this, way use annotation processors buckbuild is: the annotation_processors immutable list of processor class. can identify package name used in meta-inf/services/javax.annotation.processing.processor file, example: realm processor the annotation_processor_deps immutable list of rules (generally prebuilt_jar or android_prebuilt_aar ) holding annotation processor a sample buck build file of project uses realm java prebuilt_jar( name = 'realm', binary_jar = 'libs/realm-android-0.82.2.jar' ) android_library( name = 'main-lib', srcs = glob(['app/src/main/java/com/yourcompany/project/**/*.java']), deps = [ &

vsix - Open custom user control in tool window using VS Package -

Image
i'm trying create simple custom command (added in tools menu option) open tool bar custom control in vs 2013 using vs package project. i'm following https://msdn.microsoft.com/en-us/library/bb165987.aspx guide not sure why it's not working. when click on it, opens tool window without content under it. want show mycontrol.cs or custom control content under it. i've tried lot find out on google no relevent article found same. i've notice when created new vs package, created "mycontrol.xaml" file loading it's data properly. deleted file , created new user control "mycontrol.cs" not loading data. not sure if requires vsix project or vs package. there other way this? nothing in vsix development simple @ first. try using tutorial . it's series can find here . for show custom tool window content have extend toolwindowpane class , override window property returning content iwin32window. tutorial explains it, , migh

java - Clojure doto macro -

i going call .touppercase method within doto macro follows doto returns small letters: (doto (java.lang.string. "clojure") (.touppercase)) returns "clojure". macroexpansion , return value object created: (clojure.core/let [g__7359 (java.lang.string. "cojure")] (.touppercase g__7359) g__7359) , why don't uppercased answer? doto part of clojure's java interop features. designed make possible write java out soooo darn many parens. so foo foo = new foo; foo.setx().sety().makefactory().applyphaseofmoon(); which has 8 parens becomes: (doto foo .sety .makefactory .applyphaseofmoon) which has total of two. in case if dig expanstion of example: user> (doto "hi" .touppercase) "hi" expands to: user> (macroexpand-1 '(doto "hi" .touppercase)) (clojure.core/let [g__110453 "hi"] (.touppercase g__110453) g__110453) where second line this: user> (.toupper

powershell - Bash script passed to AWS EC2 Instance as User Data file fails to load on initial boot -

i have simple bash script i'm trying pass aws ec2 ubuntu instance via powershell script using aws library. #!/bin/bash apt-get update apt-get upgrade heres powershell script encodes file contents in base64 , calls cmdlet starts ec2 instance: $filecontent = get-content $userdatatarget $filecontentbytes = [system.text.encoding]::utf8.getbytes($filecontent) $filecontentencoded = [system.convert]::tobase64string($filecontentbytes) $masterinstance = new-ec2instance -imageid ami-4c7a3924 -mincount 1 -maxcount 1 -keyname awskey -securitygroups $securitygroup -instancetype "t1.micro" -userdata $filecontentencoded this snippet cloud init log: cloud-init v. 0.7.5 running 'modules:final' @ fri, 02 oct 2015 21:05:24 +0000. 33.88 seconds. /bin/bash: apt-get update apt-get upgrade: no such file or directory 2015-10-02 21:05:24,294 - util.py[warning]: failed running /var/lib/cloud/instance/scripts/part-001 [127] 2015-10-02 21:05:24,298 - cc_scripts_user.py[warning

ios9 - Xcode 7 "CoreFoundation/CFUserNotification.h" file not found -

i porting mobileterminal ios. getting error xcode 7 ios sdk 9.0. here git repo. here full error: /applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator9.0.sdk/system/library/frameworks/corefoundation.framework/headers/corefoundation.h:92:10: 'corefoundation/cfusernotification.h' file not found followed context: /users/user1/documents/dev/ios-term/classes/terminal/terminalgroupview.mm:4:9: in file included /users/user1/documents/dev/ios-term/classes/terminal/terminalgroupview.mm:4: /users/user1/documents/dev/ios-term/classes/terminal/terminalgroupview.h:4:9: in file included /users/user1/documents/dev/ios-term/classes/terminal/terminalgroupview.h:4: /applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator9.0.sdk/system/library/frameworks/uikit.framework/headers/uikit.h:11:9: in file included /applications/xcode.app/contents/developer/platforms/iphonesimulator.pla

javascript - Dygraphs vertical line with label -

i need place vertical line label on dygraph national holiday line in example - http://www.fusioncharts.com/dev/chart-attributes.html?chart=msline i have searched google 2 hours , can't find examples. can shoot me example or put me on right track? thanks. best practice today add highlighted region using underlay callback ( example ). try specifying "underlaycallback" option within "new dygraph()" call. use html canvas context draw line. on creating graph: // graph range on x axis: var xmin=0, xmax=1; // horizontal line y value: var yvalue = 0.5; new dygraph(document.getelementbyid('garph'), data, { // graph options underlaycallback: function(ctx, area, dygraph) { var xleft = dygraph.todomcoords(min, yvalue); var xright = dygraph.todomcoords(max, yvalue); ctx.strokestyle = 'black'; ctx.beginpath(); ctx.moveto(xleft[0], xleft[1] ); ctx.lineto(xright[0], xright[1]);

java - Creating a void method that reads a file, that can be called by other methods in the class? -

public class dash { public void readfile(string fil) throws filenotfoundexception { try { scanner input = new scanner(new file(fil)); string text = input.next(); input.close(); } catch (filenotfoundexception e) { } } public int getnumdashes() throws filenotfoundexception { readfile(fil); string text = input.next(); // code find number of dashes string of read file. } } as indicated in title, read file in 1 method. since cannot return string readfile method, have obtain string within getnumdashes method. however, i'm not sure how this. second method's return value based of off whatever file name passed readfile() . you use non-static field string, store text input file. public class dash { string text; public void readfile(string fil) throws filenotfoundexception { try{ scanner input = new scanner (new file(fil)); text= i

c# - This transaction has expired. Please return to the recipient's website to complete your transaction using their regular checkout flow -

Image
this weird gets. i've been using same paypal code on dev enviroment (sandbox) on 2 months. today when redirected paypal (to pay transaction) error i have no clue possibly cuasing error didn't change in code @ all. any ideas? thanks this paypal intermitent problem, trying few hours later did trick. weird...

jquery - Use external multi modal JavaScript -

i utilize external multi modal github script in meteor run bootstrap modals taken meteor bootstrap package have installed on app. there no meteor package this. i'm using $.getscript() jquery function source js file. set such: meteor.startup( function () { $.getscript("https://cdn.rawgit.com/ngzhian/multi-step-modal/master/multi-step-modal.js"); }); unfortunately when include this, file url gets loaded modal functionality doesn't work. believe html correct. there alternative way include third party libraries? library possibly broken? meteor.startup( function () { $.getscript("https://cdn.rawgit.com/ngzhian/multi-step-modal/master/multi-step-modal.js",function() { // here script loaded , can use it's functions }); });

javascript - JS: Why does code run differently on the console than when it's on a .js file? -

i'm studying javascript, , book i'm following suggests easiest place test code (for exercises , exploring concepts) on browser console itself, that's i've been doing. however, professional friend of mine told me instead make html page, link js file , put code want test there, inside invoked function. way load , reload page on browser see output on console. i confused why same piece of simple code run or output differently if typed directly on console versus if loaded file. then came across piece of code (used illustrate closure on loops) on material : for (var i=1; i<=5; i++) { settimeout(function timer(){ console.log(i); }, i*1000 ); } the book says code should output number 6 5 times, when typed on console (google chrome) output 5 , 5 6 s (one per second). remembering friend said, followed suggestion and, indeed, the same code, when executed js file linked html, outputs differently , resulting in number 6 5 times. exactly why ha

sql - Crosstab function in Postgres returning a one row output when I expect multiple rows -

i have table m of following format: id scenario period ct 2 1 1 1 2 1 2 1 2 1 3 1 2 1 4 1 2 2 1 1 2 2 2 1 2 2 3 1 2 2 4 1 2 3 1 1 2 3 2 1 2 3 3 1 2 3 4 1 i want create following table: id scenario period 1 2 3 4 2 1 1 1 2 1 2 1 2 1 3 1 2 1 4 1 2 2 1 1 2 2 2 1 2 2 3 1 2 2 4 1 2 3 1 1 2 3 2 1 2 3 3 1 2 3 4 1 the tablefunc extension has been

python - NoReverseMatch error in Django 1.8 -

using django admin add users error: noreversematch @ /admin/usuarios/user/add/ reverse 'usuarios_user_change' arguments '(u'',)' , keyword arguments '{}' not found. 1 pattern(s) tried: [u'admin/usuarios/user/(.+)/$'] i'm using abastractbaseuser , useradmin all have admin in urlconf is url(r'^admin/',include(admin.site.urls))

c# - sending values to url string on dropdown selected value change in asp.net MVC -

i have 2 tables. first development region , second zone. zone has got regionid foreign key. populate row zone table related region selected dropdown list. cannot figure out why value not being passed in url string. please me out , suggest best way accomplish it. below models, controllers , view. model zone public class zone { [key] public int zoneid { get; set; } [required] [display(name = "zone code")] [regularexpression(@"^[a-za-z]*$"), stringlength(5, errormessage = "code cannot more 5 charachter long")] [column("zcode")] public string zonecode { get; set; } [display(name ="zone"),regularexpression(@"^[a-z]+[a-z]*$"),required] public string zonename { get; set; } public int regionid { get; set; } public virtual devregion devregion { get; set; } [required] [display(name ="active")] public boolean isactive { get; set; } } model devregions public cla

firefox - imacros select text on page -

i'm need select text on page. version build=8940826 recorder=fx tab t=1 event type=click selector="#post-3175>div>h2" button=0 event type=click selector="#imacros-highlight-div" button=0 event type=click selector="#imacros-highlight-div" button=0 this not work,the text outlined. the code below highlights element 'h2' outlined 'imacros'. event type=click selector="#post-3175>div>h2" button=0 set s "var doc = window.document;" add s "var rng = doc.createrange();" add s "var elssel = doc.getelementsbytagname('h2');" add s "for (i = 0; < elssel.length; i++) {" add s "if (elssel[i].style.outline == '1px solid blue') {" add s "rng.selectnodecontents(elssel[i]);" add s "sel = window.getselection();" add s "sel.addrange(rng);" add s "break; }}" url goto=javascript:{eval("{{s}}")}

asp.net - How can I deal this deck(Dictionary) in C# -

i have 2 players, want each of them receive 26 random out of 52 card deck. have idea how can give each player, 26 random cards 52 card deck? this should empty original 52 card deck dictionary, , create 2 smaller 26 card deck dictionary. i have been struggle 3 day, , have done research do. here deck class: class deck { public dictionary<int, string> createnewdeck() { dictionary<int, string> newdeck = new dictionary<int, string>() { {1, "~/cards/c1.png"}, {2, "~/cards/c2.png"}, {3, "~/cards/c3.png"}, {4, "~/cards/c4.png"}, {5, "~/cards/c5.png"}, {6, "~/cards/c6.png"}, {7, "~/cards/c7.png"}, {8, "~/cards/c8.png"}, {9, "~/cards/c9.png"}, {10, "~/cards/c10.png"}, {11, "~/cards/cj.png"}, {12, "~/cards/cq.png"}, {13, "~/cards/ck.png"}, {14, "~/cards/d1.png"

Adding php to html -

i added php of pages, not coming on of pages. <body class="menu"> <!-- slide bar starts here --> <?php require ('/php/slider.php');?> <!--slide bar ends here--> <div class="body"> store comming </div> <script src="store.js"></script> </body> in php file had this. <header> <a href="#" class="menu-toggle"> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </a> <nav class="menu-side"> <div class="listing"> <div class="box"><a class="list" href="/"><h1>home</h1></a></div> <div class="box"><a class="list" href

html - FusionChart AngularJS: Cannot display two separate charts "No Data to display" -

the code identical tutorials. here html: <div fusioncharts width="300" height="100" type="column2d" datasource="{{mydatasource}}" > </div> <div fusioncharts width="300" height="100" type="column2d" datasource="{{mydatasource2}}" > </div> here angularjs code: $scope.mydatasource = { chart: { caption: weekobject.week }, data: [ { label: "saturday", value: weekobject.days[0]._fe_items_sold.tostring() }, { label: "sunday", value: weekobject.days[1]._fe_items_sold.tostring() }, { label: "monday", value: weekobject.days[2]._fe_items_sold.tostring() }, { label: "tuesday", value: weekobject.days[3]._fe_items_sold.tostring() },

Python to PHP on server send image -

i have raspberry pi running lamp stack, arduino , camera hooked up. end goal when arduino takes photo, writes image php address emailed. right now, i'm trying image placed in right place. here's php snippet: <?php print_r($_files); move_uploaded_file($_files["file"]["tmp_name"], "/var/www/images/mypic.jpg"); ?> my python code doing: import requests r = requests.get('https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png') r2 = requests.post('http://192.168.1.100/accept_image.php', data = r.content) i realize image going overwritten. that's not problem. can add timestamp later etc etc. however, gives me error code. i'm beginner @ php , use python scientific computing not sure if i'm passing picture correctly. know ip correct can connect , it's in network. i have looked @ python script send image php still getting stuck. edit: upon further debugging: print_r($_

html - javascript accept only image not working -

in code want accept image file .otherwise not accept , give alert not image file . i have done below code in jsfiddle:-- jsfiddle link but problem it..it not giving message.what doing wrong? https://jsfiddle.net/weufx7dy/2/ you forgot add id on file element <input type="file" id="file" name="fileupload" size="50" />

html - How to edit the css part of table-rows which are called using PHP? -

<script> function gotoquiz(qcid){ window.location="<?php echo site_url();?>/quiz/attempt/"+qcid; } </script> <style> .tablesorter{ margin: 10px 0 10px 0 !important; } .tablesorter thead tr{ background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#ebebeb)); border-bottom: 1px solid#ddd; } .tablesorter td { padding: 14px 10px; text-align: center; border-top: 1px solid #ffffff; border-bottom: 1px solid #e0e0e0; border-left: 1px solid #e0e0e0; background: #fafafa; background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa)); background: -moz-linear-gradient(top, #fbfbfb, #fafafa); } .tablesorter thead tr{ text-align:center; } table tr.even { background: #f6f6f6 !important; background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#f6f6f6)) !important; background: -moz-linear-gradient(top, #f8f8f8, #f6f6f6); } </style> &l

amazon web services - SSL installed on AWS EC2 Load Balancers not working -

Image
i newbie in aws , installed ssl certificate on aws ec2 load balancers. have add ssl certificate load balancers , went fine. when checked our url on ssl checker says url not found. here load balancer description tap instance status: this load balancers listeners what wrong in ssl configuration ? your appreciated. for https instance port should 80. so https 443 <-> http 80 assuming instances don't run on both 80 , 443 , want ssl offloading @ elb level.

odoo 8 - How to hide button based user? -

i'm developing openerp 8.0 module , in point of process user can take workflow of responsibility. tried this: _columns = { 'check' : fields.function(_get_check, type='boolean', obj='stock_picking', method=true), } <button name="force_assign" states="confirmed,waiting,partially_available" type="workflow" attrs="{'invisible': ['|', ('check', '=', true), '|']}"/> but getting following error: uncaught error: unknown field check in domain ["|",["check","=",true],"|",["state","not in",["confirmed","waiting","partially_available"]]] please me. try this: _columns = { 'check' : fields.function(_get_check, type='boolean', obj='stock_picking', method=true, store=true ), } hope helps...

c# - Disregard incorrect user input until correct input is received -

i'm having trouble code. have make simple choice game , need have if user inputs invalid option pauses story until choose valid response. tried wrapping whole thing in while(1==1) , entering invalid responses in console window , printed out "that wasn't option" infinitely. how remedy this?? thanks. // first choice, scene 1 if-statements while (1 == 1) { string firstscene = console.readline(); firstscene = firstscene.trim(); string firstchoice = firstscene.tolower(); console.writeline(); if (firstchoice == "rudely") { assholefactor++; console.writeline(">>\"you're damn right was! we've been working on years. thought you'd happy hours @ office amounted something.\" (douche factor increased)"); break; } if (firstchoice == "nicely")

java - Checking out maven project error. "handshake alert: unrecognized_name" -

Image
trying check out maven project gives me handshake alert: unrecognized_name googled no luck. adding -djsse.enablesniextension=false eclipse.ini not work. tried using java 1.7 / 1.8 ,,, svn connector 1.7/1.8. nothing ! anyhow supposed ask me username , password, not , gives me error screen below. please help! i had problem ,its caused svn connector, didn't find solution should use javahl connector, reason doesn't work on linux.

python - List of objects: how to extract attributes from a particular region or slice? -

Image
this image numpy docs left me wondering. if multidimensional list (or ndarray ) containing objects attribute in common, how can 1 extract specific parts? i have read other questions how extract attributes entire list , extracting rows , columns easy using list comprehensions, can't wrap head around how it, instance, 2nd , 4th slices shown in image, especially 4th slice. this useful board game i'm making, slice board , check, example, if group of tiles have particular value or if share specific attribute. you want check if have attribute in common can reduce 1d-case raveling result of indexing. array = np.arange(25).reshape(5,5) array[2::2,2::2] # gives you: array([[12, 14], [22, 24]]) array[2::2,2::2].ravel() #gives you: array([12, 14, 22, 24]) since seems 1d cases solveable (with list comprehensions) might trick. list comprehensions have aware multidimensional arrays should ravelled or flattened (see numpy documentation) if don't want array of axis

arrays - .sort not working in Swift 2.0 -

i'm trying sort arrays of combinations have. multidimensional array, need sort out array that's inside now. for combination in mycombinations { combination.sort({$0 < $1}) print("\(combination)") } here's code sort out array , here's result. ["lys", "dyt", "lrt"] ["lys", "dyt", "gbc"] ["lys", "dyt", "lbc"] i got warning says "result of call 'sort' unused" me out this? thanks. in swift 2, sort sortinplace (and sorted sort ), , both methods called on array (they global functions). when call combination.sort({$0 < $1}) return sorted array, you're not sorting source array in place. and in example result of combination.sort({$0 < $1}) not assigned variable, that's compiler telling error message. assign result of sort : let sortedarray = combination.sort({$0 < $1}) print(sortedarray)

mongodb - Compare Size of Arrays Inside an Array of Objects -

i want find documents scompetitions.length greater competitions.length . here's sample documents document: { "_id" : objectid("59b28f432b4353d3f311dd1b"), "name" : "ford focus rs 2008", "requirements" : [ { "ranktype" : "d1", "competitions" : [ objectid("59b151fd2b4353d3f3116827"), objectid("59b151fd2b4353d3f3116829") ], "scompetitions" : [ "rallye monte-carlo", "rally sweden" ] }, { "ranktype" : "a3", "competitions" : [ objectid("59b151fd2b4353d3f3116f6b") ], "scompetitions" : [ "rally italia sardegna", "neste rally finl

javascript - RangeError: Maximum call stack size exceeded after using .map -

i'm trying show list of todos having trouble maximum call stack size exceeded after using .map. can tell me problem is? import react, { component } 'react'; import './todo.css'; export default class todo extends component { constructor(props) { super(props); this.state = { todos: ['to 1 thing', 'to thing'] }; } showtodos() { return this.state.todos.map((todo) => ( <todo key={todo} todo={todo} /> )); } render() { return ( <div classname={'container'}> {this.showtodos()} </div> ) } } it's because rendering todo element in showtodos() method, try render list of todo list of todo list of todo list,... instead, render new div element : showtodos() { return this.state.todos.map((todo) => ( <div key={todo}>{todo}</div> )); }

javascript - Spawning Enemies not working in canvas -

i trying spawn enemies @ random intervals when write code commented below screen turns white , canvas off , enemies spawned @ random location instead @ top position declared.please check code commented , let me know doing wrong. https://jsfiddle.net/rz7udd72/ } // function animateplanets() { // var time = date.now(); // if (time > lastspawn + spawntime) { // lastspawn = time; // spawnplanets(); // } // canvascontext.clearrect(0,0,canvas.width, canvas.height); // for(var i=0; < planets.length; i++){ // var planet = planets[i]; // planet.y += planetspeedy; // canvascontext.beginpath(); // canvascontext.arc(planet.x, planet.y, planetradius, 0, math.pi * 2, false); // canvascontext.fillstyle = 'red'; // canvascontext.fill(); // canvascontext.closepath(); // } // }

c++ - copy constructor undefined behavior -

below code snippet used learning. here trying create linked-list class. i'm yet define proper copy ctor ; but, expecting compiler supplied copy ctor atleast copy value of head pointer didn't happen:- #include<iostream> using namespace std; class list; class listnode { int idata; char cdata; listnode *next; public: listnode(); listnode(int , char , listnode *); listnode* operator++(int); friend class list; }; listnode::listnode() :idata(int()), cdata(char()), next(null) { cout<<"default ctor"<<endl; } listnode::listnode(int i, char c, listnode *argnext) :idata(i), cdata(c), next(argnext) { cout<<"param ctor idata: "<<this->idata<<" cdata: "<<this->cdata<<" next: "<<this->next<<endl; } listnode* listnode::operator++(int) { cout<<"postfix operator overload"<<endl; return this->next; } class list { listnode *head; pu

swift - Calling a JS framework method through JavaScriptCore results in unexpected output -

i trying leverage of functionality found in chroma.js in macos app. i have following initial setup func initializejs() { if let jssourcepath = bundle.main.path(forresource: "chroma", oftype: "js") { { let jssourcecontents = try string(contentsoffile: jssourcepath) self.jscontext?.evaluatescript(jssourcecontents) } catch { print(error.localizeddescription) } } } i want test whether works trying use scale method chroma offers calling function: open func testscale(withcolors colors: [nscolor], mode:string = "lab") { // transform colors array array compatible chroma.js let arr = colors.map({ (color) -> string in return color.tohexstring() }) // call "scale" method array if let scale = self.jscontext?.objectforkeyedsubscript("chroma").invokemethod("scale", witharguments: arr) { print(scale) } } wh

javascript - updating the new values in the services -

when click open first window button popup opens,which contains text box. when copy url in popup , hit save saves sample pdf in grid, when refresh disappears. is there anyway can permanently save in grid updating in grid? my code follows, , available jsfiddle . $("#save").click(function() { grid.datasource.add({ "filename": $("#fname").val(), "threedots": "last name" }); $("#fname").val(''); }); you getting value of #fname never gets updated. file input here #batchfile . also, want strip path value, , file name only. can .replace(/.*[\/\\]/, '') see here: jsfiddle . $("#save").click(function() { var f = $('#batchfile').val(); f = f.replace(/.*[\/\\]/, ''); grid.datasource.add({ "filename": f, "threedots": "last name" }); });

linux - Is there a command parameter to specify the path for rz -

i use rz command in ssh client upload files remote app server a. if log in remote server , in path /home/xxx/ . want upload file under path '/home/xxx/work'.so rz command, there command parameter specify a's path uploaded file put? use compound command on remote side: ssh foo@bar "cd work && rz ..."

python - Unable to import a class in unittest -

this beginner question i'm pulling hair out. i have simple python script "foo": #!/usr/bin/env python class foo(): def __init__(self): self.do_something() def do_something(self): print "foo" def main(): foo() if __name__ == '__main__': main() script works fine: $ python foo.py foo i want test function "do_something" in unittest , have code: #!/usr/bin/env python import unittest import foo foo import * class testfoo(unittest.testcase): def test_foo(self): foo() def main(): unittest.main() if __name__ == "__main__": main() if run tests, however, get: $ python pyunit/foo.py e ====================================================================== error: test_foo (__main__.testfoo) ---------------------------------------------------------------------- traceback (most recent call last): file "pyunit/foo.py", line 9, in test_foo foo() nameerror: global name 'foo'

css - floating a list of divs of variable height in 3 column format -

Image
i have list of product divs containing 2 more divs each displayed vertically within - top 1 containing image , bottom 1 text. text variable in size outer divs size variable. these outer divs float left , go 3 row until div long text happens next row starts after column, leaving gap. so if have row 2nd div has 3 lines of text other two's 1, 4th div start not in first position on next line in 3rd. here image demonstrating see vs second do: and i'm aiming do do not use float. take @ fiddle: jsfiddle demo css: .block { width: 33.33%; display: inline-block; vertical-align: top; margin-right: -3px; } .inner { min-height: 100px; margin-bottom: 10px; background: #000; }

python - PyQt5: Object has no attribute 'exec_' with two main windows -

i new pyqt, when creating ui files, copied 1 mainwindow (mainfile.ui) , changed produce ui file (intro.ui). know not way create ui files, gives error: object has no attribute 'exec_' . here code: mainfile = "mainfile.ui" ui_mainwindow, qtbaseclass = uic.loaduitype(mainfile) fileintro = "intro.ui" ui_windowintro,_ = uic.loaduitype(fileintro) class mainwindow(qtwidgets.qmainwindow, ui_mainwindow): def __init__(self): qtwidgets.qmainwindow.__init__(self) ui_mainwindow.__init__(self) self.setupui(self) self.buttonintro.clicked.connect(self.openwindowintro) def openwindowintro(self): s = windowintro() s.show() s.exec_() #here problem. class windowintro(qtwidgets.qmainwindow, ui_windowintro): def __init__(self): qtwidgets.qmainwindow.__init__(self) ui_windowintro.__init__(self) self.setupui(self) #close window self.button2.clicked.connect(sel

linear algebra - Parallel saxpy implementation in Go isn't scaling well across cores -

Image
so i'm trying implement implementation of saxpy both blocked , can computed in parallel using 8-cores available on machine. started assumption small sizes of vectors x , y fit l1 cache of machine (split 256kb - 128kb data, 128kb code), can computed in serial. test assumption, wrote 2 implementations of saxpy, 1 blocked serial version of saxpy (bss) , blocked parallel version of saxpy (bps). blocking algorithm used when sizes of vectors larger 4096 elements long. following implementations: const cachecap = 32*1024/8 // 4096 func blocked_serial_saxpy(a float64, x []float64, incx int, b float64, y []float64, incy int, z []float64, incz int) { zn := len(z) //fmt.println("zn: ", zn) if zn <= cachecap { serial_saxpy(a, x, incx, b, y, incy, z, incz) return } nblocks := zn/cachecap + 1 //fmt.println("nblocks: ", nblocks) := 0; < nblocks; i++ { beg := * cachecap end := (i + 1) * cachecap if