Posts

Showing posts from May, 2015

php - jQuery simple form submission without reload -

could provide me simple code form submission jquery. on web sorts of gizmo coding. $('#your_form_id').submit(function(){ var datastring = $("#your_form_id").serialize(); $.ajax({ type: "post", url: "submit.php", data: datastring, success: function() { alert('sent!'); } }); return false; });

Are there any 3rd party chatting apps available for android,BB and iPhone? -

i have client has requirement chatting app. app should make communication possible on android , blackberry. wonder if technically feasible? if yes how? clue? yes, need chat server , clients on both mobile devices utilize server. these frameworks support web services, quite easy create web-service handle on server you. you can skip server , let them talk directly each other.

algorithm - Calculating similarity between drawn lines -

Image
i need algorithm calculate, numerically, degree of similarity between 2 drawn lines. lines drawn using mouse, , stored set of cartesian coordinates before being filtered , smoothed using separate algorithms. for example, within following diagram: lines , b similar, b , c not. algorithm should reflect this. additionally, 'direction' of line, indicated start , end points, matters. such algorithm exist? a naive approach can taking sum of distances between corresponding points on 2 lines.so lets assume both of lines of same length , number of points on lines approximately same , equidistant. 1.translate line 2 start point same line 1's starting point. 2. calculate sum of distances between corresponding points between line 1 , line2. 3. if average distance (i.e. sum/number_of_points) lesser threshold lines similar otherwise different. can extended support lines different sizes. in case, enlarge smaller line match longer line, rest can similar above approach. ap...

java - Is iterating ConcurrentHashMap values thread safe? -

in javadoc concurrenthashmap following: retrieval operations (including get) not block, may overlap update operations (including put , remove). retrievals reflect results of completed update operations holding upon onset. aggregate operations such putall , clear, concurrent retrievals may reflect insertion or removal of entries. similarly, iterators , enumerations return elements reflecting state of hash table @ point @ or since creation of iterator/enumeration. not throw concurrentmodificationexception. however, iterators designed used 1 thread @ time. what mean? happens if try iterate map 2 threads @ same time? happens if put or remove value map while iterating it? what mean? that means each iterator obtain concurrenthashmap designed used single thread , should not passed around. includes syntactic sugar for-each loop provides. what happens if try iterate map 2 threads @ same time? it work expected if each of threads uses it's own iterator. ...

javascript - playing audio on a web page without interruption by page reload -

i want create web page contains (flex/flash) audio player doesnt reloaded when page reloads. currently, popping out player in new window. please check http://www.paadal.com see in action. what want achieve have player in same window, shouldnt reload. sure many of use ajax prevent reloading of page songza.fm. problem search engines cannot index ajax applications. true full fledged flex app well. is there way have player in same window? not reload. thanks no, cannot have single element exempt page-reload, not without loading portions of page via asynchronous calls server. when window refreshes, flushes dom out, including mp3 player.

c# - Cast using is twice, or use as once and create a new variable -

in previous question today these 2 different approaches given question answers. we have object might or might not implement idisposable . if does, want dispose it, if not nothing. 2 different approaches these: 1) if(todispose idisposable) (todispose idisposable).dispose(); 2) idisposable disposable = todispose idisposable; if( disposable != null ) disposable.dispose(); mainly, comments sounds consensus 2) best approach. but looking @ differences, come down this: 1) perform cast twice on todispose. 2) perform cast once, create new intermediate object. i guess 2 marginally slower because has allocate new local variable, why regarded best solution in case? solely because of readability issues? my rules of thumb around casting: if it's error/bug value not of right type, cast otherwise use as , in second case if you're dealing value type, can either use as nullable type (for consistency) or use is , direct cast note second form doesn...

css - Progressive Enhancement with box-shadow -

i use webkit's box-shadow css property little drop-down. code like: .drop_down{ -webkit-box-shadow: 1px 1px 4px #888; box-shadow: 1px 1px 4px #888; } however, browsers not have capability, use borders approximate drop shadow, so: .drop_down{ border-top: 1px solid #bbb; border-left: 1px solid #bbb; border-right: 2px solid #bbb; border-bottom: 2px solid #bbb; } the problem is, don't want border-based shadow show browsers support box-shadow. avoid browser sniffing because assume it's hard cover cases. simplest way this? prefer javascript-less solution, consider simple javascript-based ones too. modernizr feature detection. code be: .drop_down{ border-top: 1px solid #bbb; border-left: 1px solid #bbb; border-right: 2px solid #bbb; border-bottom: 2px solid #bbb; } .boxshadow .drop_down{ border: 0px none; -webkit-box-shadow: 1px 1px 4px #888; box-shadow: 1px 1px 4px #888; } you need include modernizr javascript library work. ...

Return all values from IN Clause on SQL Server 2000 -

is there way retrieve data in clause? let's assume table got (id,name): 0 banana 1 mango 2 papaya 3 lemon and query: select * fruits name in (banana,mango,orange) i want 'orange' return, empty id (since there's no register). how this? you can't use in clause this. need target fruits table can outer join against. select ... (select 'banana' fruit union select 'mango' union select 'orange') f left join fruits on fruits.name = f.fruit or option 2 (as long list <= 8000 characters). create udf like 1 here (but using varchar(8000) instead of varchar(max) ). use follows. select ... dbo.fnsplitstringlist('banana,mango,orange') f left join fruits on fruits.name = f.stringliteral

cocoa - Methods to render a PDF into a very high resolution NSImage bitmap file -

i have render pdf high resolution image (say , on 100,000 * 80,000 pixels). i managed without going out of ram splitting render several slices , rendering each 1 using nsoperationqueue, drawing nsimage pdf representation new nsimage using drawinrect:fromrect:operation:fraction: , saving tiffrepresentation file. all , multicore , fast , i'm happy. anyway i'd need join slices again after rendered them, obtain single tiff file. i try merge files using nsinputstream , nsoutputstream since each file complete tiff representation, merging raw bytes result in unreadable picture file. there way merge image files without loading them ram, i.e. without using nsimage methods? otherwise save raw pixel bytes instead of tiff representations , join them nsinputstream/nsoutputstream, how transform whole bytes file recognizable tiff without, again, loading huge thing ram? this technique won't work extreme demands (see end of message more on that), other people higher res...

tsql - Comparing Query Changes. Is there a better way -

when writing queries, in steps. sometimes, in process realize i've made "mistake" such ending or losing records. so, typically compare 2 queries so: (select blah blah blah ) mine inner join ((select blah blah blah ) orig mine.pk <> orig.pk or if i'm looking missing or records use left join instead , nulls. is there better way figure out why 2 queries returning different numbers of records? you need full join start with. inner join show records in mine not in orig. full join show in orig , missing in mine. a quick , dirty way check differences compare result of checksum_agg(checksum(*))

How to derive a website absolute file path from a WCF service hosted in IIS? -

how can 1 determine absolute filepath of wcf service root folder that's hosted in iis? i've investigated system.servicemodel.operationcontext , discovered various relative uri paths, no absolute paths contain service root folder. after little digging around .net framework discovered: system.web.hosting.hostingenvironment.applicationphysicalpath this gets physical path on disk application's directory, i.e. in case of wcf service hosted iis, virtual folder's absolute file path.

asp.net - SQL Server 2008 Express - sample database download? -

is there sample database sql server 2008 can download practice learning how develop/use sql server...i have downloaded sql server 2008 express edition, visual studio 2008, ms web dev 2008, asp.net 3.5..... ...don't think can download else before start learning how use stuff. thanks guys... p.s. rookie coming ms access/vba adventure works new sample databases sql 2008 database. if you're using express version might want downloading adventure works lt version, has many fewer tables full blown adventure works database. you can use northwind , pubs databases used old sql 2000 databases. still used many examples , demos. hope helps some.

drupal - How do I authorize users on Telligent Community Server 2008.05 into another site? -

i have group of users accounts on community server 2008.5 installation, , them able log in on site , automatically logged drupal installation (on separate machine). i believe i'll able figure out drupal site using many external authorization tutorials, haven't been able find information cs 2008.5 side of it. have ideas? there single sign-on module enables authenication across sites, add-on. have used on asp.net forms authentication, looks possible using cookies: http://telligent.com/support//communityserver/community_server_2008/w/cs20085docs/installing-cookie-authentication-extension.aspx

python - i have '__contains__' ,why error -

class a(object): def a(self): return true __contains__=a b=a() print 2 in b#why error __contains__ meant take argument. a doesn't accept argument. the following example working __contains__ : >>> class a(object): ... def a(self, item): ... return true ... __contains__=a ... >>> b=a() >>> print 2 in b true

jquery - $.ajax() joining two data objects -

lets want join 2 data sets in $.ajax call such: updatedata: function(datadetails) { $.ajax({ url: './example.php', data: { lets:"get", real:"funky" }, type: "post", datatype: "json", }); } datadetails in function argument contains set of data, such as... { a:"1", b:"2", c:"3" } how should declare in data: area of $.ajax() if want join these sets? i believe $.extend() utility should work here: data: $.extend({ lets:"get", real:"funky" }, datadetails)

css - New CSS3 selectors doesn't work for me? -

ok, have code this: <div id="header"> (yeah, have use div instead of header tag, don't ask me why) <a href="link"><img src="image1.png" alt="image1" /></a> <a href="link"><img src="image2.png" alt="image2" /></a> <a href="link"><img src="image3.png" alt="image3" /></a> </div> and want select first image after div (first link image) , 2 last links in css. i know nth-child or first/last child selectors. want use "+" , "~". doesn't seem work! for example: #header + { border: solid 1px red; } gives border to... nothing! this 1 doesn't seem work: #header + img { border: solid 1px red; } what's wrong? same effect "~". tested in major browsers.... you've got wrong. selector you're looking #header > a:first-child ...

Set android screen resolution -

i'm trying alter default screen resolution of android emulator (and extension, android device) work @ 1700x1200. in other words, need screen able display unique points on range. i have set dimensions in layout file, yet device still defaults 320x480. i've set different dpi densities, no avail. any great, direction explore. edit: 2 responses. guess question wasn't clear - understand top resolution device fixed, need scale screen display finer granularity 640x850 (which believe highest resolution). understand can set dpi density 120-240, need know how set scaling functionality simulate screen of 1700x1200. guess have done code, prefer platform auto-scale down me. may not possible, wanted check. using android sdk 2.0 or 2.1 can create avd custom resolution. if want can run emulator -skin argument, instance emulator -skin 1700x1200 , you'll want.

php - How do i assign values to the Select Box or hidden value retrived from function -

iam calling php custom function different parameters returns different arrays based on parameters . //array1 array(1) { ["index_name"]=> array(1) { ["xerox print "]=> string(8) "xerox value" } } //array2 array(1) { ["index_name"]=> array(2) { ["xerox print"]=> string(8) "test2" ["xerox print1"]=> string(8) "test1" } } iam using zf framework iam calling custom function in controller , assigning values view variable details $arr['index_name'] = get_list_values('a','b','g'); $view->details = $arr; how assign details hidden variable if array count 1 , if array count more 1 have assign select box <?php if (is_array($this->details['index_name']) && count($this->details['index_name'])==1) { ?> <input type="hidden" name="sel_printq" id="...

c# - Disabling "print" button in .net print preview dialog -

i'm working on c# / .net app. want user able print preview, don't want user able print print straight preview dialog. the print preview dialog has little printer button on sends previewed pages straight printer. question is, there way rid of / disable / intercept button click? the printpreviewdialog class wrapper around printpreviewcontrol class , supplying buttons in toolbar. form can host printpreviewcontrol have host printpreviewcontrol in dialog form create: public partial class previewdialog : form { public previewdialog() { this.printpreviewcontrol1 = new system.windows.forms.printpreviewcontrol(); this.suspendlayout(); // // printpreviewcontrol1 // this.printpreviewcontrol1.dock = system.windows.forms.dockstyle.fill; this.printpreviewcontrol1.location = new system.drawing.point(0, 0); this.printpreviewcontrol1.name = "printpreviewcontrol1"; this.printpreviewcontrol...

c# - Reporting Services is slow -

ok, have report in reporting services 2005 backed sql server 2005. i use c# code generate 10 records. maybe 12 columns. there 6500 records in table. i record records database , display them. reporting server isn't doing calculations or intense can tell. the records created in db @ 3:57pm today. it's 4:11pm now. it's consistently taking 15 - 30 minutes run. now, server hardware pretty (12 gigs, 4 cores, etc). under pretty heavy load. i'm guessing part of problem. but there can speed process? sits on "report being generated" circle forever. thanks. edit: forgot mention have indexes setup on column rs uses fetch. problem solved. moved faster server. found existing server being brought down other services.

iphone - Customized UITableViewCell dissappears -

i've seen number of people having similar issue, either solution did not help, or different. my problem is, have customized uitableviewcell, custom size, image , content. when scroll or down , again, text within of cells disappears. seems happening randomly. i have read "dequeue"-issue either got wrong or doesnt fall case.... anyways, heres code cells: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; } cell.selectionstyle = uitableviewcellselectionstylenone; cell.imageview.image = [[uiimage alloc] initwithcontentsoffile: [[nsbundle mainbundle] pathforresource: [[shopitems...

counter - google analytics can not see the code on the site -

ga code placed before </head> tag, more 3 days still "code not installed" here code <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-18367xxx-1']); _gaq.push(['_trackpageview']); (function() { var ga = document.createelement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(ga, s); })(); </script> probably there special settings on server?? (in robots.txt example - nothing special) the code works fine, sends data ga fine itself. you need supply more info c/p of code generated, in general.... 1) data sent ga going , viewing page in browser. doesn't matter in robots.txt. if not on page g...

asp.net - The HTTP verb HEAD is unrecognized and unsupported -

after attaching of great dotnetopenauth project site, have got lot of unhandled exceptions below. please me this? event message: unhandled exception has occurred. event time: 1/9/2010 5:59:04 event time (utc): 1/9/2010 11:59:04 event id: fa8b51280ff94c52b24658def6e0a530 event sequence: 9 event occurrence: 1 event detail code: 0 process information: process id: 3568 process name: w3wp.exe account name: nt authority\network service exception information: exception type: system.argumentexception exception message: http verb 'head' unrecognized , unsupported. parameter name: httpverb request information: request url: http://www.amiproject.com/ request path: / user host address: xxx.xxx.xxx.xxx user: authenticated: false authentication type: thread account name: nt authority\network service thread information: thread id: 8 thread account name: nt authority\network service impersonating: false stack trace: @ dotnetopenauth....

python - Threading in a django app -

i'm trying create call scrobbler. task read delicious user queue, fetch of bookmarks , put them in bookmarks queue. should go through queue, parsing , store data in database. this calls threading because of time spent waiting delicious respond , bookmarked websites respond , passed through api's , silly wait that. however having trouble threading , keep getting strange errors database tables not being defined. appreciated :) here's relevant code: # relevant model # class bookmark(models.model): account = models.foreignkey( delicious ) url = models.charfield( max_length=4096 ) tags = models.textfield() hash = models.charfield( max_length=32 ) meta = models.charfield( max_length=32 ) # bookmark queue reading # def scrobble_bookmark(account): try: bookmark = bookmark.objects.all()[0] except bookmark.doesnotexist: return false bookmark.delete() tags = bookmark.tags.split(' ') user = bookmark.account.user concept in concepts.extract( bookma...

Ruby's "foo = true if !defined? foo || foo.nil?" won't work -

i thought in following, foo should true $ irb ruby-1.9.2-p0 > foo = true if !defined? foo || foo.nil? => nil ruby-1.9.2-p0 > foo => nil because foo @ first not defined, foo = true part make temporarily has nil value, !defined didn't catch it, foo.nil? should catch it, , make true... why still nil? this related ruby's "foo = true if !defined? foo" won't work expected be careful when skipping parenthesis. meant: foo = true if !defined?(foo) || foo.nil? as per other question, defined?(foo) true , want write: foo = true if foo.nil?

dependency injection - How to inject event handlers into events with Unity -

how can inject (attach) event handlers .net events of instances created unity ioc container? example: have class reports errors via standard .net event: class cameraobserver { public event action<exception> unhandledexception; [...] } i have class reponsible handling events: class crashmonitor { public static void handleexception(exception x) { ... } } what automatically inject handler crashmonitor every instance of cameraobserver in pseudocode: unitycontainer container = new unitycontainer(); container.registerinstance<action<exception>>(crashmonitor.handleexception) .registertype<cameraobserver>(new injectionevent(unhandledexception)); var observer = container.resolve<cameraobserver>(); // crashmonitor.handleexception attached observer.unhandledexception is there way unity? can think of ugly workaround deriving cameraobserver special constructor intendend dependency injection or or method injection. make sys...

javascript - window.location.href but where the address bar changes -

for reason, using window.location.href doesn't change url in user's address bar. there reason why i'm getting behavior? code earlier, posted code here. see i'm in frame. happens have same issue, window.top.location.href = 'page.htm'; trick. ps. apologies not mentioning frame aspect. tiny, subtle use of frames. had known, wouldn't have asked question :) thanks all! you can frameset , adress bar won't change, no matter users navigate to. but mentioned, internet explorer -since ie7- focuses on user prevent stuff that, user has right know surfing - security issue. imagine come website looks clean , friendly , site redirects array of phishing sites without or browser security noticing it. site owner private info, e.g. clipboard content or geolocation data , while @ ease, site owner empties bank account. example. in addition below answer tried window.location.href on firefox 3.6 , works expected. <!doctype html> <htm...

jquery - Problem with :contains selector in IE8 -

i'm working on following selector in jquery: $("div[id^=webpartwpq]:has(table.ms-sitedirresultssort) td:contains(' : ')").closest('div') in other words: select div id starting webpartwpq has table class ms-sitedirresultssort has td containing text : . @ end of question html rendered sharepoint. the selector works under firefox 3.5, not under internet explorer 8. i'm testing using hide() function. i've narrowed down td:contains(' : ') part of selector. running $("td:contains(' : ')") in firebug lite dumps out whole list of functions isn't valid. other selectors work fine in fb lite. i've tried using jquery 1.3.2 , jquery 1.4rc1 without success. bug in jquery , if there ticket (i can't find one)? ideas on how best around this? html: <div style="" helpmode="1" helplink="/_layouts/help.aspx" allowdelete="false" class="ms-wpbody" width=...

c# - How do I capture the mouse move event -

i capture mouse move event in main form. although able wire mouseeventhandler main form, event no longer fires when cursor on usercontrol or other control. how ensure have mouse position. you use low level mouse hook. see this example , check wm_mousemove mesage in hookcallback. you use imessagefilter class catch mouse events , trigger event position (note: position on window, not outside of it): using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; namespace globalmouseevents { public partial class form1 : form { public form1() { globalmousehandler gmh = new globalmousehandler(); gmh.themousemoved += new mousemovedevent(gmh_themousemoved); application.addmessagefilter(gmh); initializecomponent(); } void gmh_themousemoved() { point cur_pos = system.windows.forms.cursor.posit...

collaborative filtering - What are some ways for a recommendation engine to deal with one time, novel and potentially important content? -

say built recommendation engine recommend live tv shows watch. regular shows, pretty job using collaborative filtering , like. 1969 moon landing. it's important event, want recommendation engine handle case. can't rely on past behavior since value of recommendation drops 0 once show over. what effective methods deal problem in recommendation space? the problem in cf opposite: new items no clicks / ratings yet can't recommended cf algorithm , have trouble getting in front of users. old, famous item ought recommendable. there's opposite problem: recommender system algorithms tend favor famous items knows rather more long-tail, lesser-known items may better recommendations in sense. sounds have notion item extra-good in sense. that's side information include crudely boosting estimated rating value amount. think effective approach that.

java - Cannot be dereferenced -

the following code: age.equals( otherperson.age ); produces compile error like: cannot dereferenced. how fix this? it's hard tell minimalistic question, i'll guess age primitive , therefore doesn't have methods. try using age == otherperson.age instead.

RTTI ?? create multiple object at runtime wxwidgets? -

hi sorry stupid question what right way create multiple control object list of array of label of object ...? thank the function wxcreatedynamicobject can used construct new object of given type, supplying string name. if have pointer wxclassinfo object instead, can call wxclassinfo::createobject. you must include implement_dynamic_class macro in every class want able dynamically create objects. implement_dynamic_class macro not initialises static wxclassinfo member, defines global function capable of creating dynamic object of class in question. example in header file: class wxframe : public wxwindow { declare_dynamic_class(wxframe) private: wxstring m_title; public: ... }; in c++ file: implement_dynamic_class(wxframe, wxwindow) wxframe::wxframe() { ... }

javascript - Reading querystring param with jQuery returns null -

i'm trying read querystring parameter ("ssip") via jquery , query plugin, seems return null instead of actual value. here's code: <script src="jquery-1.3.2.min.js" language="javascript"></script> <script src="jquery.query-2.7.1.js" language="javascript"></script> <script language="javascript" type="text/javascript"> function getstreamingserverip() { return $.query.get('ssip'); } </script> i'm calling method flex via externalinterface. does spot problems above code? i'm having same problem. i believe query plugin version 2.1.7 compatible jquery 1.2.x. on plugin download page, checkout api version select box, click apply , see there no releases jquery 1.3 or 1.4.

What is the correct way to refer to HTML elements via JavaScript? -

i making colour-picker using pure javascript , html. consists of 3 html selects (drop downs boxes) , 1 div background-colour of changed javascript. trying "correctly" possible. means no javascript code in html. my code far looks this: var red = document.getelementbyid('red'); red.onchange = update(); var green = document.getelementbyid('green'); green.onchange = update(); var blue = document.getelementbyid('blue'); blue.onchange = update(); var thebox = document.getelementbyid('colourbox'); function d2h(d) {return d.tostring(16);} function h2d(h) {return parseint(h,16);} function update(){ finalcolor = '#' + d2h(red.value) + d2h(green.value) + d2h(blue.value) thebox.style.background = finalcolour; } and html looks this: <div id="colourbox"></div> <form name="myform" action="colour.html"> <select name=...

Multiple MYSQL queries vs. Multiple php foreach loops -

database structure: id galleryid type file_name description 1 `artists_2010-01-15_7c1ec` `image` `band602.jpg` `red umbrella promo` 2 `artists_2010-01-15_7c1ec` `image` `nov7.jpg` `cd release party` 3 `artists_2010-01-15_7c1ec` `video` `band.flv` `presskit` i'm going pull images out 1 section of application, videos on another, etc. better make multiple mysql queries each section so: $query = mysql_query("select * galleries galleryid='$galleryid' && type='image'); ...or should building associative array , looping through array on , on whenever need use result set? thanks thoughts. it depends what's more important: readability or performance. i'd expect single query , prefilling php arrays faster execute, since database connections expensive, simple query each section more readable. unless know (and not hope) you're going huge amount of traffic i'd go separate quer...

css - Simple PHP Sessions Error -

i have discovered problem want know why issue. had 2 pages form1.php started session on page , hit submit. had link session2.php started session , able pull information form1.php. learning sessions , simple exercise learn session can do. here lies issue, had stylesheet link in head , had blank href href="#" , when there session2.php not start session form1.php , grab info form. without href="#" in style tag worked fine, , worked fine if fake styletag href="something.css" href="" doesn't work either. why this? have in because template made workflow, maybe cant include css link in template anymore prevent future issues. you can see site working here , if haven't explained myself. form1.php <?php session_start(); $_session['name'] = $username; ?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html> <head> <ti...

c# - horizontally center vertically maximized WPF window -

i have wpf window has maxwidth set, when hit maximize button, maximizes vertically not horizontally. expected behavior. however, window docks left side of screen (windows 7, if matters) , want centered horizontally when maximized. tried adding following statechanged event handler, doesn't seem anything: private void wdw_mainwindow_statechanged(object sender, eventargs e) { switch (windowstate) { case windowstate.maximized: var windowwidth = (double)getvalue(widthproperty); left = (systemparameters.primaryscreenwidth / 2) - (windowwidth / 2); break; } } i set breakpoint on switch statement , code gets hit when hit maximize button in app. however, after left gets set, window remains firmly stuck left side of screen. what's going on? aero snap on windows 7 interfering attempt center window. try turning off aero snap , see if still have problem. http://www.sevenforums.com/tutorials/3069-aero-snap-tur...

php - help with array -

what doing wrong here? username string less 2 chars still dont set error[]? register: $errors = array(); $username = "l"; validate_username($username); if (empty($errors)) { echo "nothing wrong here, inserting..."; } if (!empty($errors)) { foreach ($errors $cur_error) $errors[] = '<li class="warn"><span>'.$cur_error.'</span></li>'; } function validate_username($username) { $errors = array(); if (strlen($username) < 2) $errors[] = "username short"; else if (strlen($username) > 25) $errors[] = "username long"; return $errors; } change validate_username($username); $errors = validate_username($username); your function affecting local variable named errors , not global errors may have been expecting. further, code can cleaned little bit follows $username = "l"; $errors = validate_username($username); // no errors if (...

Create Comma Seperated List from MySQL PHP -

i have list of users in table. how go taking list , returning 1 php variable each user name separated comma? you generate comma-separated list query: select group_concat(username) mytable or else fetch rows , join them in php: $sql = "select username mytable"; $stmt = $pdo->query($sql); $users = array(); while ($username = $stmt->fetchcolumn()) { $users[] = $username; } $userlist = join(",", $users);

Are you explicitly unit testing a private method when you use your knowledge of the private method to choose test cases -

it seems though general consensus of testing community not test private methods. instead, should test private methods testing public methods invoke them . however, doesn't feel right me. let's take method example: /** * returns base name of output generator class. if class named * reno_outputgenerator_html, return "html". * * @return string */ protected function getname() { $class = get_class($this); $matches = array(); if (preg_match('/^reno_outputgenerator_(.+)$', $class, $matches)) { return $matches[1]; } else { throw new reno_outputgenerator_exception('class name must follow format of reno_outputgenerator_<name>.'); } } this particular function used in couple of places in class. i'd test both branches of if statement in function, mean each public function i'd have test 2 situations plus whatever else public method does. this feels weird me. if i'm testing see if get...

ruby on rails - Dragonfly question -

i tried switching gem rails 3.0.0.rc rails 3.0.0 in gemfile , when doing got problem dragonfly when starting server. error message says: /library/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing': uninitialized constant dragonfly::config::herokurailsimages (nameerror) from /users/erikostling/spatziba/config/initializers/dragonfly.rb:4 switching rc doesn't help. have idea on wrong? my dragonfly.rb looks this: require "dragonfly" app = dragonfly::app[:images] app.configure_with(dragonfly::config::herokurailsimages, "static.my-app-domain.com") app.parameters.default_format = :jpg dragonfly.active_record_macro(:image, app) any appreciated! e make sure follow rails 3 installation instructions .

php - warning problem: expects parameter 1 to be mysqli_result -

possible duplicate: mysql_fetch_array() expects parameter 1 resource, boolean given in select i following warning listed below , wondering how fix it warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given on line 65 the code around section of php code listed below. can list full code if needed. // function retrieve average , votes function getratingtext(){ $dbc = mysqli_connect ("localhost", "root", "", "sitename"); $sql1 = "select count(*) articles_grades users_articles_id = '$page'"; $result = mysqli_query($dbc,$sql1); $total_ratings = mysqli_fetch_array($result); $sql2 = "select count(*) grades join grades on grades.id = articles_grades.grade_id articles_grades.users_articles_id = '$page'"; $result = mysqli_query($dbc,$sql2); $total_rating_points = mysqli_fetch_ar...

winforms - JSON in C#; Sending and receiving data -

i trying make desktop client request , response application. i able requests easily. wondering whether me work out how json request , response. , parse string, there can workout how slit up json.net ubiquitous in .net world.

javascript - canvas data out of range? problem in FF -

i run code every frame, works great in chrome data[index + 0] = bgdata[dis + 0]; data[index + 1] = bgdata[dis + 1]; data[index + 2] = bgdata[dis + 2]; data[index + 3] = 255; but firefox gives error: an invalid or illegal string specified" code: "12 unless add -1 each line below: data[index + 0] = bgdata[dis + 0] -1; data[index + 1] = bgdata[dis + 1] -1; data[index + 2] = bgdata[dis + 2] -1; data[index + 3] = 255; any ideas why might happen? trying optimize code as possible, , understand! data shouldn't out of range obtained by: bgdata = backgroundcanvasctx.getimagedata(mx, 0, 320, 400).data; update line causes error is: overlayimagecanvasctx.putimagedata(imgdata, 0, 0);

Difference between database drivers and database dialects -

what difference between database drivers , database dialects? a database driver program implements protocol (odbc, jdbc) connecting database. adaptor connects generic interface specific vendors implementation, printer drivers etc. a database dialect configuration setting platform independent software (jpa, hibernate, etc) allows such software translate generic sql statements vendor specific ddl, dml. it appears "database dialect" may used other types of database programs mean different broadly similar have written. is, "database driver" acknowledged industry term 1 single concrete meaning whereas "database dialect" not recognised , refers different concepts in different contexts.

iphone - simply add a row to tableview -

nsstring *ref = [item stringbymatching:myregex1 capture:2]; nsstring *value = [item stringbymatching:myregex1 capture:3]; i need add ordertable uitableview, how hell do it:p. cannot find simple way of doing please :) i in uitableview this (@"%@ :: %@", ref, value) thanks you'll have add datasource , [ordertable reloaddata];

iphone - Passing URL, via UIWebView click, incorrectly -

okay, have tabbarcontroller 5 tabs. each of these tabs uinavigationcontrollers. each of views associated tabs link xib file contains view uiwebview. want happen when link clicked in uiwebview new navigation view (with button) pushed onto stack , content filled link clicked, happens close no cigar. loads original page left from, example: i'm on www.example.com , click link , new view loads (with button) , reloads www.example.com :( also, have check in viewdidload method determine tab selected in turns tell content needs present. here code: - (void)viewdidload { // allows webview clicks captured. webview.delegate = self; // places statsheet image centered top nav bar. uiimage *image = [uiimage imagenamed: @"header.png"]; uiimageview *imageview = [[uiimageview alloc] initwithimage: image]; self.navigationitem.titleview = imageview; [imageview release]; // loads webpage according tab selected. if (self.tabbarcontroller.selectedindex == 0) { [webview loadre...

Can I set up a default method argument with class property in PHP? -

i'm using php 5.2.6. want have default value argument in method, seems i'm getting bit clever. the class property blnoverwrite defaulted , settable elsewhere in class. have method want have settable again, not override existing value. error when try this: public function place( $path, $overwrite = $this->blnoverwrite ) { ... } must this? public function place( $path, $overwrite = null ) { if ( ! is_null($overwrite) ) { $this->blnoverwrite = $overwrite; } ... } yes, have way. cannot use member value default argument value. from php manual on function arguments: ( emphasis mine ) a function may define c++-style default values scalar arguments. […] php allows use of arrays , special type null default values. […] the default value must constant expression, not (for example) variable, class member or function call. […] note when using default arguments, defaults should on right side of non-default arguments; otherwise, thing...

ajax - JQuery Dialog: How to do partial page refresh and get new dialogs each time -

i'm having workflow issue jquery dialogs when trying create dialogs , doing partial page render. i'll try go through sample scenario, , apologies in advance long problem description: the page loads, html turned jquery dialogs. dialogs created on document.ready (using .dialog() ), autoopen property set false. when jquery creates dialogs (if i'm using firebug inspect page), dialog html stripped normal location , stuck @ end of document, wrapper classes around it. user opens dialogs clicking link $dialogdiv.dialog('open') . so works fine. problem there times when doing partial page reload using ajax (using asp.net mvc renderpartial). part of page i'm refreshing happens have of dialog html in it, gets re-written out. remember dialog (with of jquery wrapper classes, etc) there bottom of document. html wasn't part of page refresh, i'm stuck 2 sets of dialog html. giving me sorts of problems because have duplicate id's on page, , jquery behavior on ...

Difference between C++ and Java compilation process -

possible duplicate: why c++ compilation take long? hi, i searched in google differences between c++ , java compilation process, c++ , java language features , differences returned. i proficient in java, not in c++. fixed few bugs in c++. experience, noticed c++ took more time build compared java minor changes. regards bala there few high-level differences come mind. of generalizations , should prefixed "often ..." or "some compilers ...", sake of readability i'll leave out. c/c++ compilation doesn't read information binary files, reads method/type definitions header files need parsed in full (exception: precompiled headers) c/c++ compilation includes pre-processor step can wide array of text-replacement (which makes header pre-compilation harder do) the c++ syntax lot more complex java syntax the c++ type system lot more complex java type system c++ compilation produces native assembler code, lot more complex produce rela...

php - Doctrine - How to print out the real sql, not just the prepared statement? -

we're using doctrine, php orm. creating query this: $q = doctrine_query::create()->select('id')->from('mytable'); and in function i'm adding in various clauses , things appropriate, this $q->where('normalisedname = ? or name = ?', array($string, $originalstring)); later on, before execute() -ing query object, want print out raw sql in order examine it, , this: $q->getsqlquery(); however prints out prepared statement, not full query. want see sending mysql, instead printing out prepared statement, including ? 's. there way see 'full' query? doctrine not sending "real sql query" database server : using prepared statements, means : sending statement, prepared (this returned $query->getsql() ) and, then, sending parameters (returned $query->getparameters() ) and executing prepared statements this means there never "real" sql query on php side — so, doctrine cannot display it. ...

Proper folder location when creating virtual directories in IIS 6.0? -

when creating new web sites visual studio .net, projects created @ default web site location, e.g. c:\inetpub\wwwroot\myapp. likewise, when creating msi packages such applications using visual studio web deployment project, custom action used determine folder location of default web site , files installed location. when @ other virtual directories in current iis installation, see these logical paths: iishelp: c:\windows\help\iishelp reports: c:\program files\microsoft sql server\mssql.3\reporting services\reportmanager reportserver: c:\program files\microsoft sql server\mssql.3\reporting services\reportserver crystalreportviewers12: c:\program files\business objects\common\4.0\crystalreportviewers12 my question is: c:\inetpub\wwwroot correct location use, if virtual directory created under default web site? not more appropriate install files c:\program files\myapp, create virtual directory, , point virtual directory folder (making sure proper permissions have been assigned fo...

render - DrawToDC fails on IE9 web browser control -

i have been using following code metafile vector image content of iwebbrowser2 control following: ihtmlelement* pdocbody; ihtmldocument2* pdoc; ... ... pdoc->get_body(&pdocbody); // body element ihtmldocument2 pdocbody->get_parentelement(&peleparent); peleparent->queryinterface(iid_ihtmlelement2,(void**)&prenderele2); // element render from prenderele2->queryinterface(iid_ihtmlelementrender,(void**)&prender); // render interface hdc hmetadc=::createenhmetafile(hrefdc,pictfile,&metarect,null); // dc hr = prender->drawtodc(hmetadc); the code above had worked beautifully ie6, ie7, ie8 provide vector image browser content. drawtodc call above fails beta release of ie9 (testing on windows 7, 32 bit) error code: 0x8007000e . i have tried use wm_print , other draw methods able bitmap image, not vector image. any idea why drawtodc fail ie9 in code above, , if there other method of getting vector image ie9. thanks,...

c# - How to change Rectanlge Left/Top/Right/Bottom -

i have 2 rectangles innerrectangle , outerrectangle. want verify if 4 corners of innerrectangle i.e, lett, top, right, bottom inside of outerrectangle. if outside want change ones outside. if change left/top/right/bottom, how should change width or height? please let me know how implement this. if (innerrectangle.left < outerrectangle.left) { // should put here } if (innerrectangle.top < outerrectangle.top) { // should put here } if (innerrectangle.right < outerrectangle.right) { // should put here } if (innerrectangle.bottom < outerrectangle.bottom) { // should put here } appreciate help.. to check whether rectangle innerrectangle contained inside outerrectangle : if (outerrectangle.contains(innerrectangle)) { // ... } to fix innerrectangle inside outerrectangle : innerrectangle = innerrectangle.intersect(outerrectangle);

c# - Flickr Automation For Actions Not in Available in Flickr API (Like Adding Contacts) -

edit: added bounty, if me figure out doing wrong, yours. also, don't care how gets done. if there library can out, or of sort great. since there no captcha involved, should theoretically able log flickr , add contact through code similar following...correct? when run code , many many variants of when place supposed submit form verify adding contact, asks me log in. thing failure collect right cookie? i have iehttpheader ie @ whats happening , trying best emulate it. can't find going wrong unless don't understand something. flickr api can't this all want login , add predefined contact. //this kicks off process private void button2_click(object sender, eventargs e) { string user = "adampeditto"; //some random guy cookiecontainer cookies = new cookiecontainer(); cookies = loginyahoo(cookies, user); cookies = getcookies(cookies, user); cookies = clickfli...

c++ - Easy way find uninitialized member variables -

i looking easy way find uninitialized class member variables. finding them in either runtime or compile time ok. currently have breakpoint in class constructor , examine member variables 1 one. if use gcc can use -weffc++ flag, generates warnings when variable isn't initialized in member initialisation list. this: class foo { int v; foo() {} }; leads to: $ g++ -c -weffc++ foo.cpp -o foo.o foo.cpp: in constructor ‘foo::foo()’: foo.cpp:4: warning: ‘foo::v’ should initialized in member initialization list one downside -weffc++ warn when variable has proper default constructor , initialisation wouldn't necessary. warn when initialize variable in constructor, not in member initialisation list. , warns on many other c++ style issues, such missing copy-constructors, might need clean code bit when want use -weffc++ on regular basis. there bug causes give warning when using anonymous unions, can't work around other switching off warning, can done ...

c# - Wpf: How can I know if TreeView is Updated? -

i using wpf treeview, in can add treeviewitems dynamically. there way know when tree updated? tried collectionchanged event of observablecollection binded treeview didn't work. edit: my code in this: class temp { public void load() { derivea d1 = new derivea(); deriveb d2 = new deriveb(); deriveb d3 = new deriveb(); derivec d4 = new derivec(); derivec d5 = new derivec(); d1.items.add(d2); d1.items.add(d3); d2.items.add(d4); d2.items.add(d5); list = new observablecollection<object>(); list.add(d1); tree.itemssource = list; derivec d6 = new derivec(); d3.items.add(d6); //at point, want know list got updated } public observablecollection<object> list { get; set; } } class base { observablecollection<base> items = new observablecollection<base>(); } class derivea : base { } class deriv...

security - Very simple password generation scheme; is this secure? -

edit/clarification: mean password generation in "deterministically generate passwords own use (e.g. sign web services), based on secret , on site-specific data" i take md5 digest of concatenation of master password , (non-secret) site-specific string. take first 16 digits of hex representation. the advantages of such simplistic scheme are: usable anywhere md5 available don't have trust firefox extension or whatever generate password you does have hidden vulnerabilities? obviously, if master compromised, i'm out of luck. (side note: of course using hex digits suboptimal entropy per character, cares if password longer make it?) #!/bin/bash master=mymasterpassword echo "$master$1" | md5sum | head -c16 there systems use this, such supergenpass . in general, assuming hash function secure against preimage attacks (for purpose suggest using other md5), you're okay. there is, however, better construct purpose: hmac . it's cons...

algorithm - Java 2D Shading / Filling -

i have created "blob" bezier curves (screenshot below) , shade in such way appears pseudo-3d, darker shading on "left" edges , lighter on "right" edges, , perhaps pure white "light spots" on surface itself. example: i'd interested in how achieve shading used in this video . can recommend way achieve this? guessing standard graphics2d.fill , setpaint methods may not sophisticated enough. also, can recommend resources (preferrably free / online) learning more on this? edit some additional information: achieve flat fill effect below i'm creating area object , adding individual ellipse2d shape s using add(new area(ellipse)) , adding central polygon area avoid leaving white space in middle. alt text http://www.freeimagehosting.net/uploads/bc8081cbf2.png the iphone apps have access opengl-es allows significant latitude in shading , rendering coloured iso-surface emissive lighting. java2d not sophisticated enough un...