Posts

Showing posts from January, 2011

c# - Target .Net 4.0 when using Windows 8 / VS2012 -

i having issues building merged dll target .net4.0 on windows 8 machine. can build individual .net4.0 dlls in vs2012 not have problem: targeting .net 4.0 in vs 2012 on windows 8 i have come across following excellent blog post discuss issue: http://www.mattwrock.com/post/2012/02/29/what-you-should-know-about-running-ilmerge-on-net-45-beta-assemblies-targeting-net-40.aspx and also: could not load type 'system.runtime.compilerservices.extensionattribute' assembly 'mscorlib which suggests use following syntax during merge: /targetplatform:"v4,c:\program files\reference assemblies\microsoft\framework\.netframework\v4.0" unfortunately in windows 8 not have directory. can think of following possible solutions interested know if has solved this. copy .net 4.0 assemblies windows 7 machine above directory manually. find .net 4.0 assemblies being used vs2012 , reference those. ?? i using windows 8, , vs 2012 have not come across issue (and

c# - Control as dependencyproperty / WPF -

i have custom control derived control class. want create dependency property of control (for example, button) , place in controltemplate (so button can placed in xaml , mycontrol's users can subscribe it's events etc.). may tell me, how can it? here result code example: public class mycontrol: control { static mycontrol( ) { defaultstylekeyproperty.overridemetadata(typeof(mycontrol), new frameworkpropertymetadata(typeof(mycontrol))); } public static readonly dependencyproperty mybuttonproperty = dependencyproperty.register("mybutton", typeof(button), typeof(mycontrol), new propertymetadata(default(button))); public button mybutton { { return (button) getvalue(mybuttonproperty); } set { setvalue(mybuttonproperty, value); } } } xaml: &l

http status code 404 - Django: Static files missing when rendering template -

i using django 1.3 , trying deploy django project (client sent) on dev machine (ubuntu 12.04). problem regarding static files. directory structure follows: project_name media static css img js settings.py here settings.py: root = '/home/user/project_name' media_root = '%s/media/' % root media_url = '/media/' static_root = '%s/static/' % root static_url = '/static/' staticfiles_dirs = () my site deployed css, js , imgs missing. same case admin interface. when use link http://mysite.com/static/js/some.js gives 404. help appreciated , up-voting answer custom. you don't mention configuring web server serve static files. need point @ directory collectstatic put them into.

c# - Not able to set dropdownlist at page load -

i getting first time kind of problem i setting value of dropdownlist @ page load dataset auto setting 0 index ..... code : ddlebitda.selectedvalue = objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); i checked @ immediate windows ... objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); "between 40-60 %" ( come value data set right) ddlebitda.selectedvalue "up 10 million dollar " ( default value setting ) i tried many different code solve problem : ddlebitda.clearselection(); string ebitda = objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); ddlebitda.items.findbyvalue(ebitda).selected = true; string ebitda = objdataset.tables[0].rows[0]["acq_ebitda"].tostring(); ddlebitda.selectedindex = ddlebitda.items.indexof(ddlebitda.items.findbyvalue(ebitda)); but still not able solve problem ....truth not able understand problem ..... this should work str

c# - Retrieve XML content from SQL Server database -

i have generated xml, want use query sql server database. <?xml version=\"1.0\" encoding=\"utf-16\"?> <bank> <account> <id>90898908877454</id> <firstname>jonathan</firstname> <lastname>li</lastname> </account> </bank> c# method: public list<bankaccount> bankinf(string content) { list<bankaccount> list = new list<bankaccount>(); // want take xml content , use account transaction of user (using `id`, `firstname` , `lastname` fields) return list;// return xml of result } my database looks like bank _____ id ----- 54857485 firstname ------ jonathan lastname --------li balance --------435.54

python - OpenERP 7: Adding a button on a product view -

i playing openerp 7. doing testing , building first add-on. want add on every product view "synchronize" button on tab named "special" has been created add-on (which works fine). button displays when click on obtain following error: attributeerror: 'product.product' object has no attribute 'custom_export' if can explain me why have error , how fix it. my add-on folder name is: custom_synchronizer, have 4 files inside. __init__.py import product __openerp.py__ { "name" : "custom synchronizer", "version" : "0.1", "author" : "ajite", "category" : "product", "depends" : ["product"], "init_xml" : [], "demo_xml" : [], "update_xml" : ["product_view.xml"], "installable": true, "active": true } product.py from openerp.osv import orm, fields

javascript - Why is Firefox 30 times slower than Chrome, when calculating Perlin noise? -

i have written map generator in javascript, using classical perlin noise scripts have found in various places, functionality want. have been working in chrome, , have not experienced problems map. however, when tested in firefox, incredibly slow - hanging system. fared better in nightly build, still 30 times slower chrome. you can find test page of here: http://jsfiddle.net/7gq3s/ here html code: <!doctype html> <html> <head> <title>perlinmaptest</title> </head> <body> <canvas id="map" width="100" height="100" style="border: 1px solid red">my canvas</canvas> <script src="//code.jquery.com/jquery-2.0.0.min.js"></script> <script> $(document).ready(function(){ //log time in 2 ways var starttime = new date().gettime(); console.time("map generated in: "); var canvas = $("#map")[0]; var ctx = canvas.getcontext("2d

php - What kind of database connection strategy should i use for a social networking site -

i planning on building social networking site. went through stack overflow finding answer database connections social networking site . wasn't satisfying. need know strategy should follow create connection database social site building. (in case if there lacks of users accessing site). strategies singleton (but bad idea,sice slow after large number of connections), persistant connection - thinking of using persistant connection in mysqli. if not provide me link or suggestion of how this. choose whatever easy develop , worry better strategy later. won't know better strategy if haven't met problem yet.

Javascript change color of text and background to input value -

i'm going use javascript make function changing color of background, text simultaneously - based on value of text input. i've got background color change, can't manage text working well. function changebackground() { // working function changing background color. document.bgcolor = document.getelementbyid("color").value; // code i'd use changing text simultaneously - not work. document.getelementbyid("coltext").style.color = document.getelementbyid("color").value; } looking code above, code text document.getelementbyid("coltext").style.color = x works when input actual color, , not "color" value. this html of i'm referring (i know it's horribly optimized, it's work in progress): <form id="theform" style="margin-left:396px;"> <input id="color" type="text" onchange="changebackground();" /> <br/><input id

PHP curl json for twitter not working -

this code not working: $ch = curl_init ("https://api.twitter.com/1/statuses/user_timeline/ijustine.json?callback=twittercallback2&count=4"); curl_setopt ($ch, curlopt_returntransfer, true); $output = curl_exec ($ch); var_dump($output); if try access: https://api.twitter.com/1/statuses/user_timeline/ijustine.json?callback=twittercallback2&count=4 from browser typing address manually works , json displayed in browser. but in script it's not working. i using wamp , curl extension in php (5.3.13) activated because if run: var_dump( curl_version() ); array version 7.25.0. btw. working: $ch = curl_init (" http://yahoo.com "); curl_setopt ($ch, curlopt_returntransfer, true); $output = curl_exec ($ch); var_dump($output); but if try access http://twitter.com string '' (length=0) . , if try https://twitter.com boolean false why? do need enable additional php extensions or apache modules on localhost or else? this

json - How do I get the SHA of the latest commit on a GitHub repository via jQuery? -

i've been @ several hours , have yet find useful information anywhere. i'm trying use jquery latest commit of github repository single user show on homepage. currently, have: $.getjson("https://api.github.com/users/theinfection/repos", function(data) { $(".lastcommit").html('<a href="https://github.com/theinfection/' + data[0].name + '/commit/' + data[0].sha + '">text</a>'); }); that outputs link: https://github.com/theinfection/blue-monday-hd/commit/undefined . sort of works shows latest commit of first repo listed in json file , doesn't sha of said commit. now, want know is: how sha of commits? how sort commits in chronological order latest @ top? how commit comment text? this has been bothering me while appreciated! would help? $.getjson("https://api.github.com/users/theinfection/repos", function(data) { $.getjson(data[0].commits_url.slice(0, -6), function

algorithm - How to find the maximum edge-weighted clique? -

the maximum clique problem(mc-problem) classical np problem, , use branch-bound solve problem effectively. recently, try develop algorithm find out clique has maximum edge-weighted clique in graph, know, maximum edge-weighted clique problem(mec-problem). i have found properties problem. first, clique must maximal clique not belong larger clique. sum of edges of clique must largest of maximal clique. however, traditional algorithm of mc-problem not effective on mec-problem. therefore, want find effective algorithm on mec-problem, branch-bound algorithm. thank you. i don't think branch-and-bound algorithm can "effectively" solve max-clique problem. your algorithm may perform in application field data. however, intelligent exponential search - such backtracking , branch-and-bound exponential in worst case. the maximum edge-weighted clique problem polynomial turing reducible max-clique problem. equivalent each other in computational complexity. my sug

r - Figure position in markdown when converting to PDF with knitr and pandoc -

i'm trying control position of plot when converting pdf using knitr , pandoc. .rmd file looks this: # report text text text text text text text text text ```{r myplot, echo=false, fig.pos="placehere", results='hide'} library(ggplot2) ggplot(mtcars, aes(mpg, drat)) + geom_point() ``` text text text text text text text text text \usepackage{graphicx} \begin{figure}[placehere] \centering \includegraphics[width=0.5\textwidth]{placehere} \end{figure} text text text text text text text text text i'm converting pdf using functions provided here: http://quantifyingmemory.blogspot.co.uk/2013/02/reproducible-research-with-r-knitr.html how can place plot between second , third blocks of text? latex code not working stands. edit: i'm trying now. # report ```{r setup, include=false} # set global chunk options opts_chunk$set(cache=false) library(ggplot2) ``` ```{r, echo=false, fig.height=3} ggplot(mtcars, aes(disp, hp)) + geom_point()

How to get a working dynamic javascript reference in an SVG -

what trying set javascript script reference in embedded svg document dynamically javascript code within html. i assumed easy dynamically appending node appropriate place in embedded svg document. i found node added @ runtime (can check firefox inspect element), javascript code contained in reference not executed when needs be. anybody have idea this? else need done svg able call functions in javascript code? here simplified scenario: test.html (embeds svg) <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function activatescript() { var svgdoc = document.getelementbyid("svg"); var newref = svgdoc.contentdocument.createelement('script'); newref.setattribute("type", "text/javascript"); newre

iphone - Obtaining MKAnnotation's coordinate while dragging -

i'm creating path (mkpolyline) based on position of annotations added user. want allow users change path dragging pins. can that, mkpolyline doesn't update until pin dropped. i implemented - (void)mapview:(mkmapview *)mapview annotationview:(mkannotationview *)annotationview didchangedragstate:(mkannotationviewdragstate)newstate fromoldstate:(mkannotationviewdragstate)oldstate mkannotationviewdragstatedragging alerts me user dragging pin , not notifing new position. how can obtain current position of annotation being dragg, every time changes? want notified change in position while dragging able update mkpolyline follow pin moves, better reflect how path changing. any ideas? thanks! create subclass of mkannotationview , use subclass annotation dragging. within subclass: - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event { cllocationcoordinate2d location = [_mapview convertpoint:self.center tocoordinatefromview:self.superview]; } u

C: Reading strings from binary file -

i have home assignment says have store information mansion in binary file. on first line of file have keep information how many floors there in building , how many apartments there on floor (size of two-dimensional array). , on next lines have keep info apartments - unique number each apartment, number of rooms in apartment, number of people living there, family name, date when family moved in apartment, monthly rent. so, question is: how should store information , how should read it? if use fread(buf, size, number_of_elements, file *), how know number of elements? example, how read family name when don't know it's lenght? thanks in advance! ps. thank you, claptrap! tried write data first binary file got error :( #define _crt_secure_no_warnings #include <stdio.h> #include <stdlib.h> #define napartments 21 #define tax_adult 3 #define tax_kid 1 #define tax_elevator 2 #define nfloors 7 #define nrooms 3 void main() { file *fp; int i, j; struct

java - How to output binary search method? -

this average binary search, in program use search method allow user book titles. string [] binaryarray = {"4", "6", "10"}; //the chosen binary numbers public static boolean binarysearch(string [] a, int left, int right, string v) { int middle; boolean found = false; while (found == false && left <= right) { //if middle item == 0, returns true middle = (left + right)/2; int compare = a[middle].compareto(v); if (compare == 0) { found = true; } else { if (compare >0) { right = middle -1; } else { left = middle + 1; } } } if (left > right) { return false; } else { return true; } } now choose if statements output correct response, imagine if database real library possibly millions of entries. not work well. way way can find response needed without if statements?

iphone - UIView animate frame of ImageView -

i'm trying add animation uiimageview when button tapped. when button tapped want imageview move right @ same time increasing in size. have tried code, imageview aren't animation correct. - (ibaction)ba:(id)sender { [uiview beginanimations:nil context:null]; [uiview setanimationcurve:uiviewanimationcurvelinear]; [uiview setanimationduration:0.5]; cgrect frame = imageview.frame; frame.origin.x = frame.origin.x + 30; frame.size.hight = frame.size.hight + 20; frame.size.width = frame.size.width + 20; imageview.frame = frame; [uiview commitanimations]; } this code makes imageview move little right, again. wierd behavior, should animate both size , origin @ same time? the problem you've got autolayout turned on. autolayout, cannot change frame of something, because layout comes along , changes again. either turn autolayout off, or else animate changing constraints of view instead of frame.

python - Django 1.5 url redirect with regex? -

i'm trying this: (r'^$', redirectview.as_view(url='^(?p<username>\w+)/$')), but doesn't seem parse regex part actual username... i've done research can find examples redirect exact urls or other regex examples work in django 1.1 anyone have idea how in django 1.5+? subclass redirectview , , override get_redirect_view method. from django.core.urlresolvers import reverse class userredirectview(redirectview): permanent = false def get_redirect_url(self, pk): # better use reverse here return '/myapp/%s/' % self.request.user.username you include userredirectview in myapp.urls.py module follows: url(r'^$', userredirectview.as_view(), name='myapp_index'), it better reverse url instead of hardcoding /myapp/ in url above. example, if redirecting url pattern following url(r'^(?p<username>\w+)/$', 'myapp.view_user', name='myapp_view_user'), then

java - Strange behavior of Eclipse IDE -

i have been working on android app. when create project ide works fine create activity still ide works fine. when change background of screen of android project unable access variables textview,buttons etc. actually, ide behave normal before adding background can access variables activity! after add background unable thing access textview. have declared textview as; textview t=(textview)findviewbyid(r.id.txt); it gives me error variable id in .xml file i.e "txt" (same other components i.e buttons,textfields etc). tried best recover error unable find solution. restarted machine, make project test same thing works fine on adding background gives me error unable detect id! had reinstalled eclipse adt! , more background image adding code is: android:background="@drawable/gameboard" i want add in new activity. ide working right in morning has happen dont know please me in advance! further info: can give any

ember.js - Programatically trigger click event on EmberView -

i have ember application , using three.js , css renderer display array of views in 3d. the problem once three.js thing, can no longer catch click event on view through controller/view or router even. does know how programatically trigger click event on ember view? have access "data-ember-action" value , hoping use find binded event , have run. referring last comment on capturing event in ember view, work defining function/hook on view name of event want capture, like: app.myview = ember.view.extend({ click: function(event) { alert("clicked!"); }, doubleclick: function(event) { alert("double clicked!"); } }); more on handling events in ember can found in ember guides hope helps

c# - List<Info> where Info has Last and First properties map to Dictionary<Last,List<First>> -

if have class of type class info { public info(string first, string last) { this.first = first; this.last = last; } string first { get; private set; } string last { get; private set; } } and list example: var list = new list<info>(); list.add(new info("jon", "doe"); list.add(new info("jane", "doe"); list.add(new info("bason", "borne"); list.add(new info("billy", "nomates"); and want map in sorted list of last name, list of firstnames, i.e. dictionary<string,list<string>> key last name property, , list list of first name properties. in example above { "doe" => { "jon", "jane" }, "borne" => { "jason" }, "nomates" => { "billy" } } . is possible neatly linq , if how go this? you can use groupby , todictionary done: first, make properties in class public, use code: dictiona

blogs - Website font correction -

i changing fonts , line-heights site. forgot original settings , don't know if site's fonts , line-heights fine , relative or not. here sample article blogging earning . can check fonts here h1 h2 , p. please have , let me know if needs set, font size or line height. thanks from website reference have provided, need set font-size , line-height both. below settings h1, h2 , p h1{font-size: 35px; font-weight: 600; line-height: 38px;} h2{font-size: 18px; font-weight: 600; line-height: 28px;} p{font-size: 16px; font-weight: 300; line-height: 25px;} hope helps.

sql - Select row for every key in IN statement even if they are equal -

example question follow: i've got array of id's [ 6230, 206, 4259, 24761, 26736, 219, 281, 281, 516, 495, 10371 ] and want setup select query database.table that: select * `database`.`table` `id` in (6230, 206, 4259, 24761, 26736, 219, 281, 281, 516, 495, 10371); as can see i've got 2 id equal in result of query i'll got 10 rows. want 1 row every id in array. guesseing not posible "in()" statement. can assumption's on how solve proplem. just notice: can't perform different query every element of array. create set 1 record each id, , join on that: select t.* database.table t inner join ( select 6230 id union select 206 union select 4259 union select 24761 union select 26736 union select 219 union select 281 union select 281 union select 516 union select 495 union select 10371 ) x on x.id = t.id

iphone - Protect class from UIAppearance -

Image
i have uipickerview in view inside subclass of uinavigationcontroller . have uiappearance proxy want apply many views contained in uinavigationcontroller subclass, don't want uiappearance operate on uipickerview . is there way have uiappearance proxy apply views inside uinavigationcontroller subclass , protect views inside specific objects effect? without uiappearance, screen looks this: with code: #import "appdelegate.h" @interface appdelegate() @property (nonatomic, strong) uinavigationcontroller *nvcmain ; @end @implementation appdelegate @synthesize window ; @synthesize nvcmain ; - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] ; uistoryboard *sb = [uistoryboard storyboardwithname:@"main_ph" bundle:nil] ; nvcmain = [sb instantiateinitialviewcontroller] ; window.rootviewcontrolle

python - Do I need to name the url when using app.add_url_rule? -

from flask docs: def index(): pass app.add_url_rule('/', 'index', index) it says: endpoint – endpoint registered url rule. flask assumes name of view function endpoint indeed, if app.add_url_rule('/', none, index) seems work fine. (i'm not sure of terminology , "endpoint" is.) some further questions: is there reason specify second argument? is second argument indeed "endpoint"? what benefits/drawbacks of (not) specifying second argument? what if same name used in url rule? first overwritten? intended? in case, endpoint term valid url of application. wikipedia: in service-oriented architecture, endpoint entry point service, process, or queue or topic destination as naming urls - yes, optional. there benefits defining names. when using *url_for*() or redirect () example, can specify url's name shortcut. comes added benefit of allowing change url structure without changing every line of c

c# - Get text from dynamically created TextBox -

i have button when clicked creates textboxes dynamically: (int = 0; < length; i++) { name.add(new textbox()); system.drawing.point locate = new system.drawing.point(137, 158 + * 25); (name[i] textbox).location = locate; (name[i] textbox).size = new system.drawing.size(156, 20); starttab.controls.add(name[i] textbox); } i want text entered in name[i] convert string set labels you can use control.controlcollection.find . updated: textbox txtname = (textbox)this.controls.find("txtnameoftextbox", true)[0]; if (txtname != null) { return txtname.text; }

javascript - JS Change class of element -

all i'm trying toggle class of elements id when clicked on. <script> function selectload(id) { if(document.getelementbyid(id).classname == "load") { document.getelementbyid(id).classname = "loadselected"; } else { document.getelementbyid(id).classname = "load"; } } </script> <div class="load" id=" ... set php per element ... " onclick="selectload(this)"> this returns error... uncaught typeerror: cannot read property 'classname' of null so guess doesn't conditional. i'm new js , need help, in advance. you passing dom element (using this ), not id . you should change code to function selectload(element) { if (element.classname == "load") { element.classname = "loadselected"; } else { element.classname = "load"; } }

python - How to create element pairs of two lists by iterating through them in parallel? -

i want iterate through 2 lists in parallel , create element pairs follows. my code: q_node_roots = ['a', 'b', 'c'] s_node_roots = ['x', 'y', 'z'] q_node_pair, s_node_pair in zip([q_node_roots, q_node_roots[1:]], [s_node_roots, s_node_roots[1:]]): print q_node_pair, s_node_pair expected output: ['a', 'b'] ['x', 'y'] ['b', 'c'] ['y', 'z'] generated output: ['a', 'b', 'c'] ['x', 'y', 'z'] ['b', 'c'] ['y', 'z'] >>> lis1 = ['a', 'b', 'c'] >>> lis2 = ['x', 'y', 'z'] >>> z1 = zip(lis1,lis1[1:]) #use itertools.izip in py2x memory efficiency >>> z2 = zip(lis2,lis2[1:]) >>> x,y in zip(z1,z2): ... print x,y ('a', 'b') ('

postgresql - How do I get alembic to emit custom DDL on after_create? -

i've got couple of custom ddl statements want run after create table: update_function = ddl(""" create or replace function update_timestamp() returns trigger $$ begin new.updated_at = now(); return new; end; $$ language 'pgplsql'; """) update_trigger = ddl(""" create trigger update %(table)s_timestamp before update on %(table)s each row execute procedure update_timestamp(); """) and i've attached them this: event.listen(session.__table__, 'after_create', update_function) event.listen(session.__table__, 'after_create', update_trigger) when create_all , sql expect: create or replace function update_timestamp() returns trigger $$ begin new.updated_at = now(); return new; end; $$ language 'pgplsql'; create tri

IE10 Browser. jQuery Mobile will not change pages via javascript / IE10 -

i'm using jquery mobile. i'm using jqm , javascript change page once save data. want change pages on saving data parse. works fine in browser , win7 / ie9. works everywhere except win8/ie10. win8/ie10, the data gets saved parse.com, page change never happens. url address changes, page displayed never changes. here's code: success: function(object) { $(".success").show(); alert (" new info saved "); //window.location.href = "#showfltinfo"; works, seems reload whole page though window.location.hash = "#showfltinfo"; // same above doesn't seem reload page, ie. it's faster // not work @ $.mobile.changepage ($("#showfltinfo"));

cordova - Changing Application Theme on Android for PhoneGap App (using phonegap Build) -

i using phonegap build, , want change theme android application default dark holo light. any idea how can it? can create plugin changes androidmanifest.xml file maybe? have @ this post , maybe right way go edit: hole theme jquery mobile can downloaded here

image - Android app - generate a non-editable report -

i new android development , advice more experience developers. the app developing form servicing products (i.e. x work, y work etc.. ). once form has been completed "report" of kind needs generated in non-editable format! thinking display confirmation page , when confirmed user screenshot report, realise hacky solution , rather limiting! input on options have implement such feature! clear output file must non-editable... i.e. image file or pdf! also fyi - report file uploaded dropbox/a specified folder. pdf files seem solution you. rather create web service deliver pdf, because devices slow creating pdf, if decide take client approach, take at: http://code.google.com/p/droidtext/ http://sourceforge.net/p/itext/code/5420/tree/tags/itext_2_1_7

metaprogramming - Can a ruby object call super on a "grandparent"? -

if have class salad method chew , use super in it, call next available chew method available going chain of ancestors. if want "reach 2 levels up" (to second available chew method going chain)? there way without adding super first ancestor's method? to make little more concrete, suppose salad class, salad object: class salad < food include almonds include gorgonzola include spinach include dressing def chew super end end salad = salad.new the array of ancestors this: [salad, dressing, spinach, gorgonzola, almonds, food, object, kernel, basicobject] if want salad.chew trigger chew method in spinach without adding super dressing#chew, possible? there way reach 2 levels (in same way super "reaches" 1 level up)? yes, there way describing, , way through methods #method , #instance_method , in method = spinach.instance_method( :chew ) , can bind salad, or metaclasses of salad instances, in method.bind( sal

assembly - Display floating point by printf -

i have problem display floating point value using printf. i'm trying display result of math function, 0.00. could me , tell i'm doing wrong? my gnu code: .text text: .ascii "function result: %4.2f \n" .data x: .float 2.0 one: .float 1.0 result: .float 0.0 format: .ascii "%f" .global main main: push $x push $format call scanf finit flds x fmuls x #x*x fadds 1 fsqrt fsub 1 fsts result xor %eax, %eax push $result push $text call printf pushl $0 call exit in gnu assembler, $ designates literal value (a value encoded instruction). value of label address. $x , $format , $result , , $text addresses of labels; addresses have values labeling. printf not use address %f . must pass value of floating-point number, not address. and, frank kotler notes, must pass 64-bit double , not 32-bit float . the easiest way might insert add $-8, %esp (or add %esp, $-8 , depending on order of operands in assembler

Unable to connect with socket.io using node.js and nginx -

i've set socket.io node.js running behind nginx. main domain running on nginx , sub-domain being proxied node.js. rest apis working fine, when comes socket connections, see handshake in logs, client not able response apparently. below log node.js, , further below configs i'm using. ideas why it's not working? info - handshake authorized 7wtmdkry1tpb97corlj4 debug - setting request /socket.io/1/websocket/7wtmdkry1tpb97corlj4 debug - set heartbeat interval client 7wtmdkry1tpb97corlj4 debug - client authorized debug - websocket writing 1:: debug - clearing poll timeout debug - jsonppolling writing io.j[0]("8::"); debug - set close timeout client jodwovtvlg7sdypnrlj2 debug - jsonppolling closed due exceeded duration debug - setting request /socket.io/1/xhr-polling/7wtmdkry1tpb97corlj4?t=1368925686996 debug - setting poll timeout debug - discarding transport debug - cleared heartbeat interval client 7wtmdkry1tpb97corlj4 debug - setting request /socket.io/1/json

python - Pygame mouse movement failing -

i working through pygame tutorials , @ moment trying figure out how select circle firing ball ball hits ball in turn knocks box down. knocking of box works fine when ball hits box. however, when add mouse movement can select ball again , place in same position can hit again box knocks again. ball rolls backwards without firing second ball knock box.here previous code works 1 ball firing ball without mouse movements i.e without allowing ball selected , dragged. import pygame pygame.locals import * pygame.color import * import pymunk pm pymunk import vec2d import sys random import randint def to_pygame(p): """small hack convert pymunk pygame coordinates""" return int(p[0]), int(-p[1]+600) def draw_ball(screen, ball, colour): r = ball.radius rot = ball.body.rotation_vector p = to_pygame(ball.body.position) p2 = vec2d(rot.x, -rot.y) * r * 0.9 pygame.draw.line(screen, thecolors["red"], p, p+p2) pygame.draw.cir

c# - Convert Unicode string made up of culture-specific digits to integer value -

i developing program in marathi language. in it, want add/validate numbers entered in marathi unicode getting actual integer value. for example, in marathi: ४५ = 45 ९९ = 99 how convert marathi string "४५" actual integer value i.e. 45 ? i googled lot, found nothing useful. tried using system.text.encoding.unicode.getstring() string , tried parse, failed here also. correct way use char.getnumericvalue lets convert individual characters corresponding numeric values , construct complete value. i.e. char.getnumericvalue('९') gives 9. depending on goal may easier replace each national digit character corresponding invariant digit , use regular parsing functions. int32.parse("९९".replace("९", "9"))

How to get values from inner object in the hashmap in java? -

i have hashmap. object contains info name, address, email. able iterate hashmap not able values object. here code if can please show me proper way this. public void getdata(){ // hashmap records<key, object> // object contains properties name, address, email iterator = records.entryset().iterator(); while(it.hasnext()){ map.entry entry = (map.entry) it.next(); object key = entry.getkey(); object val = entry.getvalue(); // gets me through hashmap // how name, address , email object? } } since not using generics, need explicitly cast result of entry.getvalue() class of object name, address, , email. you didn't provide actual class, might like: person val = person.class.cast(entry.getvalue()); name = val.getname(); // , on....

vb.net - Using SyncLock inside a property -

i have variable being used multiple threads, using synclock when getting , setting variable. wondering if can wrap synclock inside property, don't have type synclock statements every time use variable: private _obj new object public property obj() object synclock _obj return _obj end synclock end set(value object) synclock _obj _obj = value end synclock end set end property i unsure block, since end synclock statement after return statement. couldn't find online, wondering if i'm going wrong. thanks.

decimal to binary converter c++? -

int inputnumber=0; int divisionstore=0,modstore=0; vector<int> mainvector; cout << "\nenter number convert binary.\n" << endl; cin >> inputnumber; { modstore=inputnumber%2; inputnumber=inputnumber/2; mainvector.push_back(modstore); }while(inputnumber!=1); (int i=0;i<mainvector.size();i++) { cout<<endl<<mainvector[i]<<endl; } seems there logical error cant find whats wrong it? program not print correct conversion seems loop ends before can push last number. i think need change: }while(inputnumber!=1) to: }while(inputnumber!=0)

html - How to properly place a <div> element in an <a> element -

i know common problem cannot solve it. in table cell have code: <a href="#1" class="nolink"> <div class="a1"></div> <p class="a4"> <span class="big">1.</span> first thing </p> </a> according error: one possible cause message have attempted put block-level element (such " <p> " or " <table> ") inside inline element (such " <a> ", " <span> ", or " <font> "). i understand error , know cannot place neither <div> nor <p> inside <a> . tried set display:block on <a> element, didn't work. how can solve this? solution: declare doctype html5 <!doctype html> a lot of things has been added, changed, tweaked , removed in html5 compared html4. can see list of differences @ w3c. change after among changes introduced content-mode

Editing layout in Android -

i have 2 questions : i developing part of android app , in main activity added 2 text fields , 1 button , trying call them id shown below : send = (button)findviewbyid(r.id.send) // giving error in send studentname=(edittext)findviewbyid(r.id.edittext); // giving error in edittext and added onclicklistener button , shown below : send.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { job = new myjob(); job.execute(); } }); i added both send (my button , textfields) in r.java not accepting them because modification done manually . added import android.r , did not solve problem . my second question : i trying edit layout (graphically) not know how show in eclipse !!! please me , sorry if questions stupid . import android.r android.r resources android package. tyou need import your.package.r

webrtc - Google App Engine. Channel API. The provided token is invalid. -

i've been trying make application calling browser browser using webrtc . wrote simple servlet creating channel: prefclubchannelservletservlet extends httpservlet { public void dopost(httpservletrequest req, httpservletresponse resp) throws ioexception { string channelkey = req.getparameter("userid"); resp.addheader("access-control-allow-origin", "*"); channelservice channelservice = channelservicefactory.getchannelservice(); string token = channelservice.createchannel(channelkey); resp.setcontenttype("text/plain"); resp.getwriter().println(token); } } i've deployed in google app engine. in web application i've got page java script, similar https://apprtc.appspot.com . in code caller calls prepare(1) , , callee – prepare(0). function prepare(ini) { initiator = ini; card = document.getelementbyid("card"); localvideo = document.getelementbyid("localvideo");

php - How to properly include a header file in a webpage -

so have header file: <html> <head> <link href="/design_header.css" rel="stylesheet" type="text/css" /> </head> <body> content </body> </html> and want place header in file <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> meta tags etc. </head> <body> <div id="container_big"> <?php include 'header_login.php'; ?> content </div> </body> </html> the problem have regular <html>, <head>, <body> tags inside <body> tag of webpage. in html validator receive errors like stray start tag html. stray end tag head. body start tag seen element of th e same type open. how properly? btw. place footer bottom of webpage same way. your header file should contain html text want header. inserte

objective c - NSNumber returning different value than the original int -

i quite new objective-c , trying convert int nsnumber can save core-data. i've following piece of code (index nsinteger) - (void) associateornottoaroutine:(nsstring*)exercisename associate:(bool)associate index:(nsinteger)index nslog(@"number w index %d, %d",[nsnumber numberwithinteger:index],index); and returns number w index 170413600, 2 i need int of 2 translated number 2 along other numbers translated correct number... tell me why getting convertion? tried reading on nsnumber manual found nothing try: nslog(@"number w index %@, %d",[nsnumber numberwithinteger:index],index); ^^ the %@ format specifier call [nsnumber description] method, should return value after. original code return address of nsnumber object, not content.

dojo - Inherting dojox.mobile.View and using _TemplatedMixin -

goal: want create dojo widget separate template inherits dojox.mobile.view. //javascript define([ "dojo/_base/declare", "dijit/_templatedmixin", "dijit/_widgetsintemplatemixin", "dojo/text!./templates/myappview.html", "dojox/mobile", "dojox/mobile/devicetheme", "dojox/mobile/compat", "require", "dojox/mobile/listitem", "dojox/mobile/heading"], function (declare, _templatedmixin, _widgetsintemplatemixin, template, mobile, devicetheme, compat, require) { return declare("widgets.myapp.myappview", [dojox.mobile.view, _templatedmixin, _widgetsintemplatemixin], { templatestring: template, widgetsintemplate: true, widgetbase: require.tourl("widgets/myapp/"), constructor: function (params) { params = params || {}; console.log("constructor" + dojo.tojson(params)); }, startup: function () { this.inherited(argu