Posts

Showing posts from April, 2015

graphics - RaphaelJs : How to add some text to an area defined by a path? -

i have svg image of united states i've drawn little bit of raphaël js: http://jsfiddle.net/zcrkg/2/ what want place text right of each state when hover on it. problem that, since each state path, quite difficult determine x & y coordinates place label. so, know way of calculating centre of path using raphaël? if failing know how given array of vectors? what you're looking getbbox function in raphaël . give bounding box object can use calculate central point of path: var bbox = st.getbbox(); var text = r.text(bbox.x + bbox.width/2, bbox.y + bbox.height/2, "foo"); i forked fiddle , made show static text in middle of each state on hover. picking state name data left exercise.

windows - How to get the missing DLL name after when GetLastError() returns ERROR_MOD_NOT_FOUND -

my application loads dll using loadlibrary() suppressing standard critical-error-handler message box. when loadlibrary() fails , getlasterror() returns error_mod_not_found (0x7e) i'd retrieve missing dll name. error code set not when requested dll missing, but when dll depends on missing . it's worth noting standard message box (which suppressed) displays correct missing dll name, , question how can within code. thanks i'm not sure there's easy way of getting missing dll's name. can find stepping through loadlibrary() in debugger , seeing function fails filename in parameters. depends.exe can show dependencies. also, might worth try firing process monitor , using appropriate filters see i/o errors there in process , files.

When to open and when to close the mysql connection while using Java servlets? -

is ok open connection in init method , close in destroy method? what's best way open connection mysql database. i'm using this: class.forname("com.mysql.jdbc.driver"); connection connect = drivermanager.getconnection("jdbc:mysql://" + ipaddress + "?user=" + user + "&password=" + pass); but read somewhere inefficient , should use connection pool. how that? i suggest using connection pool, either explicitly (such c3p0 ) or 1 provided servlet container. open database connection when need it, close can - connection pool take care of real network connection. unless this, you'll end 1 connection whole application - means can process 1 query @ time, , code needs synchronize around database queries. surely want multiple entirely-independent queries able execute simultaneously? can't single connection. as best way of opening connection having configured appropriate connection pool - may still end using driverm...

depth first search - Java: Trouble randomizing a DFS run to build a maze -

i'm having trouble randomizing visit node neighbors, whole graph (a mxn array, in test 4x4) visited, don't i'm doing wrong here. import java.util.arraylist; class ij { int i; int j; ij (int i,int j){ = this.i; j= this.j; } } class graph { int m; int n; int adjacencymatrix[][]; arraylist <ij> orderofvisits; graph(int m,int n){ this.m=m; this.n=n; adjacencymatrix=new int[m][n]; (int i=0; i<m; i++) (int j=0;j<n;j++){ adjacencymatrix[i][j]=-1; //mark vertices not visited } orderofvisits = new arraylist<ij>(); } string northoreast () { double lottery = math.random(); if (lottery>0.5d) {return "north";} else {return "south";} } string southoreastornorth() { double lottery=math.random(); if (lottery<=0.33d){ return "...

java - Red-Black tree rebalance problem? -

is there constraint onto compareto method orders objects put standard java treeset (i.e. collection implemented red-black tree)? have public class ruletuple implements comparable { string head; string[] rhs; public string tostring() { stringbuffer b = new stringbuffer(); b.append(head+":"); for( string t: rhs ) b.append(" "+t); return b.tostring(); } public int compareto(object obj) { ruletuple src = (ruletuple)obj; int cmp = head.compareto(src.head); if( cmp!=0 ) return cmp; if( rhs.length != src.rhs.length ) return rhs.length - src.rhs.length; for( int i=0; i<rhs.length; i++ ) if( rhs[i].compareto(src.rhs[i]) != 0 ) return rhs[i].compareto(src.rhs[i]); return 0; } ... } i assumed method mapping object linear order fine, long meets partial order criteria: reflexivity, asymmetry, , tr...

html - Add a css link to xhtml files that I cannot modify using an XSLT? -

according programming supervisor should able link css file xhtml file cannot touch using xslt. how achieved? have ideas? how "run" xslt? open in browser? i need format xhtml page fits onto mobile device, cannot control or modify xhtml page coming in (its basic xhtml). how link these xhtml pages .css? sorry if sounds confusing, clarification questions happy answer. thanks in advance. xslt transforming xml html/xhtml. because xml data. there many different ways access or display data xml, php , xslt. so clear xslt can not "run". can think of css xml. xslt supported major browsers, there shouldn't problems. you can transform xml html/xhtml linking @ begining of xml file. best right after <?xml version="1.0" encoding="utf-8"?> you link link code <?xml-stylesheet type="text/xsl" href="file.xsl"?> you can learn xslt @ link. doesn't take long through. http://www.w3schools.com/xsl ...

jquery - javascript PRINT functionality -

Image
i doing image zoom , pan modal. all working fine, use floor plans. add print button ( same style ) viewer. see example: http://test.dpetroff.ru/jquery.iviewer/test/ need appear next [ 200% ] button. any suggestions ? the js here: http://test.dpetroff.ru/jquery.iviewer/jquery.iviewer.js my html code: var $ = jquery; $(document).ready(function(){ $("#viewer").iviewer( { src: "images/floorplan.gif", update_on_resize: false, zoom: 200, initcallback: function () { var object = this; $("#in").click(function(){ object.zoom_by(1);}); $("#out").click(function(){ object.zoom_by(-1);}); $("#fit").click(function(){ object.fit();}); ...

mouseevent - How do I properly intercept and forward mouse events with Xlib? -

i'm working on simple xlib program want intercept mouse events (motion, button pressing, button releasing). might want data @ point, right now, want "forward" these mouse events proper windows (as if wasn't intercepting them @ all). at moment, general approach follows: grab pointer root window xgrabpointer() upon receiving event, find child window pointer on xquerypointer() forward event child window xsendevent() there more details, basic idea. i've been testing program on ubuntu linux, , seems work in many scenarios (for instance, clicking on minimize, maximize, , close buttons works properly). however, doesn't work in scenarios, such clicking on menu bar items. in summary, want able intercept mouse events , forward them appropriate windows if hadn't intercepted them @ all. proper way xlib?

r - adding another dimension/variable to a ggplot2 dotplot -

this should easy driving me crazy. i have data of form: categories, retailcpc, advertisercpc flowers, 0.2, 0.25 shoes, 0.4, 0.1 i trying show dotplot 2 dots per row , ordered retailcpc using ggplot2. i able graph 1 dimension (by mean retailcpc data) so: mydf$categories <- reorder(mydf$categories, mydf$retailcpc) require(ggplot2) p1 <- qplot(retailcpc, categories, data = mydf) p1 + geom_point(colour = "red", size = 2) how can add advertisercpc dots? do mean this: ggplot(melt(mydf), aes(value, categories, colour=variable)) + geom_point() note ggplot has high affinity "long" format "wide" format, , melt helps convert "wide" "long" format.

python - Django syncdb error -

i have django.contrib.auth in installed apps , was working 10 minutes ago. deleted existed database because had problems south migrations. when try rebuild error. error: django.db.utils.databaseerror: no such table: auth_user traceback (most recent call last): file "manage.py", line 11, in <module> execute_manager(settings) file "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() file "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) file "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 219, in execute self.validate() file "/usr/lib/python2.7/site-packages/django/...

Is there a PHP configuration setting that would prevent use of variable before it's set? -

Image
i have following code: <?php if ($foo) { echo $foo; } ?> however, page throwing 500 internal server error (i know means there's error being logged , page aborting prematurely) not have access error log (as host logging syslog). i can fix doing following: <?php if (isset($foo) && $foo) { echo $foo; } ?> but that's not question. there server setting kill page attempting use unset variable? afaik, logs 'notice', not enough kill page. here first bit of phpinfo() output (disclaimer: have no windows + fastcgi setup experience) update added custom error handler , output $errno , $errstr. expected, e_notice (8) message 'undefined variable'. i'm guessing 500 internal error has how it's logging syslog. implement custom error handler , can you'd (mostly)!

Does there exist an established standard for testing command line arguments? -

i developing command line utility has lot of flags. typical command looks this: mycommand --foo=a --bar=b --jar=c --gnar=d --binks=e in cases, 'success' message printed still want verify against other sources external database ensure actual success. i'm starting create integration tests , unsure of best way this. main concerns are: there many many flag combinations, how know combinations test? if math 10+ flags can used together... is necessary test permutations of flags? how build framework capable of automating tests , verifying results. how keep track of large number of flags , providing order easy tell combinations have been implemented , has not. the thought of manually writing out individual cases , verifying results in unit-test format daunting. does know of pattern can used automate type of test? perhaps software attempts solve problem? how did people working on gnu commandline tools test software? i think specific application. first,...

Are there any commerical or open source IDEs that have built-in support for compiling ILASM files? -

are there ides out there apart (from visual studio) let build il assembler files right out of ide? monodevelop supports building .net languages using mono compiler, , available on linux, mac os, , windows. according package description , many .net languages supported, including ilasm: monodevelop gnome ide designed c# , other cli (.net) languages. it supports following languages: c, c++, c# (1.0, 2.0 , 3.0), vala, boo, java, nemerle, ilasm, asp.net , vb.net. features: debugger integration (mono debugger , gnu debugger), class browser, assembly browser, built-in help, monodoc integration, code completion (also known intellisense), code folding, color schemes, code refactoring, on-the-fly error underlining, xml editing, embedded html viewer, gettext support, gtk# designer, msbuild project support , makefile generation.

silverlight - WCF RIA Services deleting related data -

say have one-to-many relation between entities customer-order. if delete customer want delete related order's. if try on client side: foreach (order order in cusomter.orders) { context.orders.remove(order); } context.customers.remove(customer); context.submitchanges(); it calls customer delete domain operation on server first, fails because of relational constraint in database. how can delete orders first? submitchanges before removing customer, , fix issue. edit: you'll have submitchanges twice.

iphone - How can we remove Noise from audio that comes out of Remote IO? -

i using remote io capture voice real time , playback through headphone. when test device(iphone or ipad), hear continuous noise in background . how can remove these noise audio? can use voice processing io cancel noise , make audio out noises?

How can I change the position of an item in ListView dynamically in android -

i want change position of item in listview dynamically.how can that? the listview backed data structure (e.g. list<string> ). can do pseudocode: list<string> list = ... listview lv = .. adapter = new adapter(..., list); lv.setonclicklistener(this); onitempressed(..., int position, ...) { tmp = list.get(0); list.set(0, list.get(position)); list.set(position,tmp); a.notifydatasetchanged(); }

Error merging arrays in PHP -

i have nested arrays , want append content of 1 array when keys match. here function instead of appending replacing. function mergearrays($arr, $ins) { if(is_array($arr)) { if(is_array($ins)) foreach($ins $k=>$v) { if(isset($arr[$k])&&is_array($v)&&is_array($arr[$k])) { $arr[$k] = mergearrays($arr[$k], $v); } else { // new loop :) // while (isset($arr[$k])) // $k++; // here want append instead of add $arr[$k] = $v; } } } else if(!is_array($arr)&&(strlen($arr)==0||$arr==0)) { $arr=$ins; } return($arr); } any recommendations? thanks you can merge entries either adding arrays together, or using array_merge merge arrays new one. any reason you...

android - Is there a better way to do this ? Checking periodically hot spot creation status -

in android application creating(code shown below) hot spot(access point) on load of application purpose has remain active throughout life cycle of application(i know has disadvantages), now, how can make sure remains active throughout ? idea have run timer checks method.getname().equals("setwifiapenabled") status , determines if inactive ? there better way indication when ap disabled ? intentfilter filter = new intentfilter(); filter.addaction(wifimanager.supplicant_connection_change_action); filter.addaction(wifimanager.supplicant_state_changed_action); filter.addaction(wifimanager.extra_new_state); filter.addaction(wifimanager.extra_supplicant_connected); registerreceiver(wifieventreceiver, filter); private broadcastreceiver wifieventreceiver = new broadcastreceiver() { private boolean enabled = false; @override public void onreceive(context context, intent intent) { system.out.println ("wifi event broadreceiver:onrec...

css - Toggle height of div using jQuery -

i trying toggle height of div can vary in height. want toggle 10% of it's original height when user clicks button , 100% when clicked open. need change class of arrow reflect current toggle state. haven't been able nail down second part. whelp appreciated. here got far... function togglepracticedrills() { $("#drillhelpslide").animate({height:"10%"}); $(".arrow").addclass("minimized"); }; thanks! function togglepracticedrills() { var origheight = $('#drillhelpslide').data('origheight'); if (origheight) { $('#drillhelpslide').removedata('origheight'); $('#drillhelpslide').animate({height: origheight}); } else { origheight = $('#drillhelpslide').height(); $('#drillhelpslide').data('origheight', origheight); $('#drillhelpslide').animate({height: origheight * 0.1}); } $(".arrow...

javascript - Align Vertical text in Tooltip -

i trying vertical-align text inside tooltip cannot. i'm usign jquery tools http://flowplayer.org/tools/tooltip/index.html based on link provided see tooltips use following css. <div class="tooltip" style="visibility: visible; position: absolute; left: 465px; display: block; opacity: 1; top: 253px; "> tooltip text </div> this blog has great article on vertically centering content http://blog.themeforest.net/tutorials/vertical-centering-with-css/ based on , assuming don't have support ie7 think display: table-cell method. apply tooltip class. have wrap cell content first though. div.tooltip {display:table;} div.tooltip > span {display:table-cell; vertical-align:middle;} //if can't wrap content in span use jquery $('div.tooltip').wrap('<span />'); //the new html <div class="tooltip" style="visibility: visible; position: absolute; left: 465px; display: block; opacity: 1; to...

sql - How to select sum of values in a given range from huge tables quickly (Derby) -

i got , b table like: table a a b mount a0 b0 0.0001 a0 b1 0.0002 table b c d weight c0 d0 0.99998 c0 d1 0.99996 each table has 10,000 - 100000 records. i want combination mount+weight >= 0.9998 , mount+weight <= 0.9999 , example: a b c d sum a0 b0 c0 d0 0.9999 a0 b1 c0 d1 0.9998 but if takes lot of time when try these ways: method 1 select b c d mount+weight a,b mount+weight >= 0.9998 , mount+weight <= 0.9999 a table have index of mount, b table have index of weight method 2 create a+b table, takes more time method 1. is there ways improve? try select a, b, c, d, mount+weight mw a,b mount+weight between 0.9998 , 0.9999 this may produce different execution plan edit: realised derby. not sure if between available in derby

PHP - SOAP 1.1 request and response handling in php -

i trying integrate netforum. needs soap requests. following sample soap 1.1 request , response, don't know how implement in php. request: post /xweb/netforumxmlondemand.asmx http/1.1 host: nftpsandbox.avectra.com content-type: text/xml; charset=utf-8 content-length: length soapaction: "http://www.avectra.com/ondemand/2005/newindividualinformation" <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:header> <authorizationtoken xmlns="http://www.avectra.com/ondemand/2005/"> <token>string</token> </authorizationtoken> </soap:header> <soap:body> <newindividualinformation xmlns="http://www.avectra.com/ondemand/2005/"> <onode>xml</onode> ...

css - How do I right align div elements? -

the body of html document consists of 3 elements, button, form, , canvas. want button , form right aligned , canvas stay left aligned. problem when try align first 2 elements, no longer follow each other , instead next each other horizontally?, heres code have far, want form follow directly after button on right no space in between. <!doctype html> <html lang = "en"> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <script type="text/javascript" src="timeline.js"></script> <link rel="stylesheet" href="master.css" type="text/css" media="screen" /> </head> <body bgcolor="000" text="ffffff"> <div id="button"> <button onclick="showform()" type=...

performance - ASP.NET MVC site takes too much time to load probably because of a Windows service running on the same server -

i have dedicated windows 2008 server several websites , 1 windows service running. the service runs every 30 seconds , pretty cpu intensive. sites loaded fast except 1 closely connected service. website project dll referenced service, , think reason slow. has had experience this? how can improve loading time of site? update here's more information: only first time load slow. subsequent loads fast. website , service access same mongodb database. service references website's dll , uses lot of classes including usersrepository. stopping service makes application run normal. yes, service's fault. solved problem making clone of bin folder used service only.

text to speech - Google "Listen" button API code -

in google translate can find "listen" button converts text speech. want able use button in own site can't find code in google translate api. want able listen whatever write in simple input field or text area. thank you! what language using? this example in vb: dim sapi object sapi = createobject("sapi.spvoice") sapi.speak("enter text here") now, depending on os user has, different narrators speak. if using xp sam(default) speak. , think user can change different narrator. in windows 7, woman narrator, , can't changed. don't know vista though. hope helps.

ios - The view is “jumping” when I add it to UIWindow as subview (via rootViewController property) and do a flip -

i have 2 simple uiviewcontrollers, views 320 x 460 status bars. in appdelegate self.window.rootviewcontroller = [[[simplecontroller alloc] init] autorelease]; [self.window makekeyandvisible]; in simplecontroller have button does - (ibaction) switchtoverysimplecontroller { [uiview transitionwithview: [[uiapplication sharedapplication] keywindow] duration: 0.5 options: uiviewanimationoptiontransitionflipfromleft animations:^{ [[uiapplication sharedapplication] keywindow].rootviewcontroller = [[[verysimplecontroller alloc] init] autorelease]; } completion: null]; } the new view (verysimplecontroller.view) filled blue color. after animation new view shown tiny white stripe (with size of status bar) @ bottom , jumps down place. why happening , how avoid that? suppose status bar blame, , tried set statusbar = unspecified in ib both views, doesn't help. update: when hide statusbar (thru setting i...

jquery - How to launch the beforeShowDay of DatePicker from another function -

i have datepicker following code. have dropdownbox , upon change in dropdown box want launch datepicker beforeshowday function. how can this? var freedate; part of code follows: $("#mydiv").datepicker({ showothermonths: true, selectothermonths: true, dateformat: "yy/mm/dd", onselect: function(datetext, inst) {}, onchangemonthyear: function(year, month, inst) { $.ajax({ contenttype: "application/json; charset=utf-8", datatype: "json", url: '@url.action("listdates", "party")', data: { date: new date(year, month - 1, 1).tostring("yyyy/mm/dd"), userid: userid }, success: function(data) { freedate = eval(data); }, error: function(request, status, error) {} }); }, beforeshowday: function(datetoshow) { var retu...

c++ - Using Koolplot without creating a new window for graphing -

i have been experimenting koolplot plotting library. have managed set linking , includes compiles nicely. wondering if possible plot graph within current window. whenever plot(x, y); called, creates new pop-up window graph in it. have graph integrated current window instead of opening new window graph. example have simple win32 window , graph displayed on it. i using c++ win32 api (not mfc or vc++) on windows 7 gnu compiler. if there other graphing libraries better koolplot , have api can used, let me know. (i don't want binary gnuplot.exe has called program.)

Animation in objective C -

-(ibaction)nextbuttonaction:(id)sender{ uiview *newview=[[uiview alloc]initwithframe:cgrectmake(0.0f,0.0f,320.0f,416.0f)]; uiimageview *newimageview=[[uiimageview alloc]initwithframe:cgrectmake(0.0,0.0, 320.0,416.0 )]; uiimageview *upperimageview=[[uiimageview alloc]initwithframe:cgrectmake(0.0, 0.0, 320.0,416)]; if(pagecount == 72){ backbarbutton.title=@"about us"; if(img){ [newimageview setimage:[uiimage imagenamed:@"splashscreenhsd.png"]];} else{ [newimageview setimage:[uiimage imagenamed:@"splashscreen.png"]]; } [titlebaritem settitle:@"0/72"]; [newview addsubview:newimageview]; pagecount=0; } else { pagecount++; nsstring *page=[nsstring stringwithformat:@"pagehsd%d.png",pagecount]; nsstring *pagestring=[nsstring stringwithformat:@"page%d.png",pagecount]; if(img){ [upperima...

Scala: map with two or more Options -

basically i'm looking scala-like way following: def sum(value1: option[int], value2: option[int]): option[int] = if(value1.isdefined && value2.isdefined) some(value1.get + value2.get) else if(value1.isdefined && value2.isempty) value1 else if(value1.isempty && value2.isdefined) value2 else none this gives correct output: sum(some(5), some(3)) // result = some(8) sum(some(5), none) // result = some(5) sum(none, some(3)) // result = some(3) sum(none, none) // result = none yet sum more 2 options i'd have use way many if s or use sort of loop. edit-1: while writing question came sort of answer: def sum2(value1: option[int], value2: option[int]): option[int] = value1.tolist ::: value2.tolist reduceleftoption { _ + _ } this 1 looks idiomatic inexperienced eye. work more 2 values. yet possible same without converting lists? edit-2: i ended solution (thanks ziggystar ): def sum(values: option[int]*): option[...

iphone - can't see when using UINib -

been confused on 2 hours, maybe can point me @ right direction... i have navigation bar tableviewcontroller under it. once first row selected pushing new tableviewcontroller loads custom table cells new , shiny uinib object. cellforrowatindexpath called , allocated new row, set values of it's 2 uilabel correctly, , return cell. however - table view empty. if replace custom cell regular table cell, see cell. hell going on here? some code: in viewdidload: self.cellnib = [uinib nibwithnibname:@"detailcell" bundle:nil]; in cellforrowatindexpath: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"detailcell"; detailcell* cell = (detailcell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { [self.cellnib instantiatewithowner:self options:nil]; cell = tmpcell; self.tmpcell = nil...

html - Using non-standard font in web pages? -

i have been told create website using non standard font. client has supplied font file (in .otf format). there way can have text on webpage show in specified font (non-web standard) ? is there other alternative other using sifr ? edit : how apply @font-face particular div ? you can use css @font-face declaration this. however, beware: not browsers support otf format. can use tool such fontsquirrel's font-face generator convert font different formats you'll need. it'll generate css you, you'll copy , paste project.

mysql - How do I create a SQL query that groups in certain percent range -

i create sql query groups increase price of items in percentage range. example 2 items increased between 0 10 % 4 items increased between 10 20% 2 items increased between 20 30% ... target server: mysql select sum(case when percentchange >= 0 , percentchange <= 10 1 else 0) end zeroten, sum(case when percentchange > 10 , percentchange <= 20 1 else 0) end tentwenty, sum(case when percentchange > 20 , percentchange <= 30 1 else 0) end twentythirty magicchangetable note: magicchangetable may in fact subquery calculate percent change.

ruby on rails - Posting comments to the feed with facebooker2 -

does know how post comments feed facebooker2? used facebook_session.user.comment_on previous version of facebooker(v1). i use facebooker2 + mogli gem: post = mogli::post.new post.message = "just message" me = mogli::user.find("me", current_facebook_client) me.feed_create(post)

wpf - Injecting view from one module into another view in a second module -

i need figuring out how inject view 1 module view in second module, using prism library. i have createorderview inside order module. view gets injected region in shell. need display personcardview inside createorderview. personcardview view phonebookmodule. the view model personcardview takes person argument in constructor contains data view display. in createorderview, how can define "placeholder" "inject" personcardview? don't think appropiate define region here since it's single view, , nothing else. if 2 views in same module, include this: <personcardview datacontext="{binding personcardviewmodel}"/> createorderviewmodel of course hold property called personcardviewmodel containing viewmodel personcardview. but can't see how way unless create reference between 2 modules , avoid that. any ideas? how have approached issue? you have 2 options, can see. your first option use regions . regions fine 1 control: ...

.NET WCF - Update client GUI while server is processing -

i'm newbie when comes client/server app. (i programmed asp.net apps) i want create application contains of multiple winform clients , .net server (i'm thinking wcf). communication between client , server should on http (port 80). application scenario: the client pass keyword server, example 'books'. the server start 1sec - 10mins process of search matching data based on keyword. the server find list of results (from 1 result n results). i client update gui found results while server searching. (not wait until server finished). my questions are: is wcf right choice server side? what kind of wcf protocol? duplex, polling, msmq based? any links related example code , starter-kit ,etc welcome :) if you're using wcf, msmq transport layer ("binding" use wcf terminology) , not relevant you're trying here (you choose between netmsmqbinding vs. wshttpbinding vs. nettcpbinding , name few). use either polling or duplex binding...

c++ - eof() bad practice? -

possible duplicate: why iostream::eof inside loop condition considered wrong? so i've been using eof() function in lot of programs require file input, , professor said fine use few people on have said shouldn't use without specifying reason. wondering, there reason? you can use eof test exact condition reports - whether have attempted read past end of file . cannot use test whether there's more input read, or whether reading succeeded, more common tests. wrong: while (!cin.eof()) { cin >> foo; } correct: if (!(cin >> foo)) { if (cin.eof()) { cout << "read failed due eof\n"; } else { cout << "read failed due other eof\n"; } }

c# - Voip Application Made With Asp.Net -

i have make application make pc-phone , pc - pc call asp.net. examples see on web made windows application. can give me refference, examples, documents voip , asp.net? you can't make voip call pure asp.net application. problem http stateless protocol drops connections data transfer has occurred. voip real time application need have constant connection between various parties (client-pbx-destination, usually). as result, need extend asp.net application either clickonce .net windows forms application or other component runs local application on user's machine.

linux - How to limit the size of core dump file when generating it using GDB -

i running embedded application on arm9 board, total flash size 180mb only. able run gdb , when do (gdb) generate-core-dump i error warning: memory read failed corefile section, 1048576 bytes @ 0x4156c000. warning: memory read failed corefile section, 1048576 bytes @ 0x50c00000. saved corefile core.5546 program running. quit anyway (and detach it)? (y or n) [answered y; input not terminal] tamper detected **********outside ifelse 0********* length validation failed i set ulimit -c 50000 still core dump exceeds limit. when ls -l check file size on 300 mb. in case how should limit size of core dump? gdb not respect 'ulimit -c', kernel does. it's not clear whether run gdb on target board, or on development host (and using gdbserver on target). should use latter, allow collect full core dump. truncated core dumps pain anyway, not contain info need debug problem.

bash - extract file name from full file name -

#!/bin/bash files=src/*.erl shopt -s nullglob f in $files echo "processing $f file..." # ??? done how can extract file name full path? , mean - "pathfilename=${f%.*}"? i'll copy help-output, since has examples , everything. ~$ basename --help usage: basename name [suffix] or: basename option print name leading directory components removed. if specified, remove trailing suffix. --help display , exit --version output version information , exit examples: basename /usr/bin/sort output "sort". basename include/stdio.h .h output "stdio".

javascript - Custom jQuery Functions -

i trying understand how write custom functions in jquery. i have code: <head> . . <script src="js/jquery.js"></script> <script> $(document).ready(function(){ $("createaccountbtn").click(function(e){ e.preventdefault(); alertme(); }); }); (function( $ ) { $.fn.alertme = function() { alert("hello world!"); }; })( jquery ); </script> </head> <body> <h1>create account</h1> <div id = "wrapper"> <form name = "createaccountform" action = "php/createaccount.php" method = "post"> <p>first name<input name = "fname" type="text" size="25"/><label id ="fnamestatus"></label></p> <p>last name<input name = "lname" type="text" size="25"/><label id =...

php - Two-part MySQL question: Accessing specific MySQL row, and column performance -

i have table 150 websites listed in columns "site_name", "visible_name" (basically formatted name), , "description." given page on site, want pull site_name , visible_name every site in table, , want pull 3 columns selected site, comes $_get array (a url parameter). right i'm using 2 queries this, 1 says "get site_name , visible_name sites" , says "get 3 fields 1 specific site." i'm guess better way is: select * site_list; thus reducing 1 query, , doing rest post-query, brings 2 questions: the "description" field each site 200-300 characters. bad performance standpoint pull 150 sites if i'm using 1 site? how reference specific row mysql result set site specificed in url? example, if url "mysite.com/results?site_name=foo" how do post-query equivalent of select * site_list site_name=foo; ? i don't know how data "site_name=foo" without looping through entire result array , che...

textview - How can I make my Android LinearLayout weights work with values of 1 and 2? -

i'm trying make linearlayout has 3 rows, each of equal height. making using 3 linearlayouts inside main one, each layout_weight of 1. the middle linearlayout should contain imageview, textview, imageview, weights of 1,2,1. this, inside middle linearlayout created 3. i want textview double size of each imageview. if see code below, when layout_weight 1 inner linearlayouts have no problems, 3 appear of equal size. when set middle 1 (with id=textlayout) layout_weight=2, disappears (as seen in eclipse graphical layout viewer) , 2 others visible. i have no idea why is... pointers? thanks <linearlayout android:id="@+id/layouttop" android:orientation="horizontal" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"> </linearlayout> <linearlayout android:id="@+id/layoutmid" android:orientation="horizontal" android...

c# - Exception while import from excel using openXML -

i deserialize data excel file list. i using code class excelimport { workbook workbook; sharedstringtable sharedstrings; ienumerable<sheet> worksheets; worksheetpart custsheet; worksheetpart ordersheet; string filepath; excelstorage provider; stiker[] ans; list<stiker> stikerlist; public excelimport(string fp) { filepath = fp; } public list<stiker> dothejob() { using (spreadsheetdocument document = spreadsheetdocument.open(filepath, true)) { stikerlist= new list<stiker>(); workbook = document.workbookpart.workbook; worksheets = workbook.descendants<sheet>(); sharedstrings = document.workbookpart.sharedstringtablepart.sharedstringtable; stikerlist = stiker.loadstiker(custsheet.worksheet, sharedstrings); return stikerlist; } } but reson exception in line: sharedstrings = ...

php - Decoding HTTP chunked + gzipped content -

how 1 decode server response 1) transfer-encode: chunked 2) content-type: gzip i need manually , can't use curl send request. need decode raw $string. here's function supposed unchunk http reponse (php): function unchunkhttpresponse($str=null) { if (!is_string($str) or strlen($str) < 1) { return false; } $eol = "\r\n"; $add = strlen($eol); $tmp = $str; $str = ''; { $tmp = ltrim($tmp); $pos = strpos($tmp, $eol); if ($pos === false) { return false; } $len = hexdec(substr($tmp,0,$pos)); if (!is_numeric($len) or $len < 0) { return false; } $str .= substr($tmp, ($pos + $add), $len); $tmp = substr($tmp, ($len + $pos + $add)); $check = trim($tmp); } while(!empty($check)); unset($tmp); return $str; } but seems not work gzipped content (gzinflate not in snippet). tried doing gzinflate on returned content doesn't work @ all. any ideas? or how gzip + transfer encoding chunked work together? thanks ...

java - Scenario where one should use Read committed or Serializable as Isolation level? -

i trying figure out isolation level (among serializable , read committed )is better in scenarios..at link http://download.oracle.com/docs/cd/b14117_01/server.101/b10743/consist.htm#i17894 , going thru topic choice of isolation level , got clarity , questions based on statements in article. satement :- read committed isolation can provide considerably more concurrency increased risk of inconsistent results due phantoms , non-repeatable reads transactions. question1:- how read committed isolation provides more concurrency serializable?as per myunderstanding serializable transactions not restrict concurrent transactions. statement:- queries in oracle serializable transaction see database of single point in time question:- think mean here , when serializable transaction begin @ time t1 data presented state of database @ time t1. right? not sure when call transaction begins. is when connection or when first query fired? statement:- oracle's serializable isolation s...

Killing abandoned process on Heroku -

i killed irb prompt in not-so-graceful manner (started heroku run irb ), , i've got zombie process can't seem kill: process state command ------------ ------------------ ------------------------------ run.3 2h irb -r ./init.rb web.1 0s thin -p $port -e $rack_env -r $her.. i've tried: heroku restart heroku ps:scale run=0 heroku ps:restart run.3 anyone know how can force quit it? i noticed new ps:stop command added heroku command line client few days ago: https://github.com/heroku/heroku/commit/a6d9eb7f314bf2c5f162a508e8d764286fb577bb i'm not sure if change made version 2.9.0 worth try. update this in heroku toolbelt . run: heroku ps:stop <process id heroku ps> example: heroku ps:stop run.8729

Android DatePicker question -

i'm trying implement datepicker , have set in xml activity. can read year, month, , day it, here's interesting thing, if user uses arrow buttons above , below the date fields, works great, if user taps number , enters number via input method, , have ok button reads datepicker getyear(), getmonth(), , getdate(), numbers aren't updated or , think need implement listener of sort, i'm bit stuck. suggestions? chris try setting ondatechangedlistener via datepicker's init() method, shown below: // member variables, initialize today's date int myear = 2011; int mmonth = 4; int mday = 30; // following goes inside activity's oncreate method datepicker dp = (datepicker) findviewbyid(r.id.your_date_picker); ondatechangedlistener listener = new ondatechangedlistener() { @override public void ondatechanged(datepicker view, int year, int monthofyear, int dayofmonth) { myear = year; mmonth = monthofyear; mday = dayofmonth; ...

PHP: Array > Sum all the numeric elements? -

i found reference in php manual, interpretation pretty wrong: $total = (sum ( array $_session['list'][$item]['price'] )); i want sum price of items in array session. please check screenshot: http://img684.imageshack.us/img684/6070/20110430010324.jpg this code i'm using: <?php session_start(); //getting list $_session['list'] = isset($_session['list']) ? $_session['list'] : array(); //stock $products = array( 'pineaple' => 500, 'banana' => 50, 'mango' => 150, 'milk' => 500, 'coffe' => 1200, 'butter' => 300, 'bread' => 450, 'juice' => 780, 'peanuts' => 800, 'yogurt' => 450, 'beer' => 550, 'wine' => 2500, ); //saving stuff $new_item = array( 'item' => $_post['product'], 'quant...

iphone - How can an iOS app keep a TCP connection alive indefinitely while in the background? -

an iphone app, connecting remote server via tcp. use scenarios are: app (user) sends data server , server responds data back. server might send data app while nothing. assume if app not send data server 30 minutes, server close connection. want keep connection alive 120 minutes if user nothing. case 1: if app in foreground, can use timer send do-nothing data server. no problem. case 2 : if user pressed home , app went background, do? don't wan show alert or interrupt user(he away or playing games). wanna keep connection alive longer period , when user comes app, found out connection still alive , happy that. i have read documentations background execution, multitasking, , local notifications of iphone apis. i'm not sure whether if can achieve case 2 . only use legal apis, no jailbreaking. tapbots solved problem pastebot prompting user run silent background audio track @ times. note apple frowns on using hacks employing background audio or voip api...

Jquery sortable element should move only up-down not left or right -

i using jquery sortable function li within ul tag, when dragging , dropping elements within ul, wanting can not dragged left or right within ul. should dragged , down. try this: $( ".selector" ).sortable({ axis: 'y' }); from docs: if defined, items can dragged horizontally or vertically. possible values:'x', 'y'.