Posts

Showing posts from August, 2014

javascript - Preserve text selection in contenteditable while interacting with jQuery UI Dialog and text input -

i have jquery dialog making links in contenteditable span. problem clicking button open dialog causes selection lost, text input inside dialog causes selection lost. i can fix button -moz-user-select:none; -webkit-user-select:none doesn't work in chrome. i can fix input wrapping in iframe, that's messy , clicking anywhere else kills selection, example, dragging dialog around. i've seen solution @ how preserve text selection when opening jquery dialog , doesn't work in many browsers in contenteditable element, real inputs. is there nice solution problem? you save , restore selection using simple functions such following when dialog opened , closed. not familiar enough jquery dialogs know mechanism hooking dialog opening , closing. first, saveselection , returns range or textrange object should store in variable later pass restoreselection : function saveselection() { if (window.getselection) { sel = window.getselection(); if (...

sql - When should you use full-text indexing? -

we have whole bunch of queries "search" clients, customers, etc. can search first name, email, etc. we're using statements in following manner: select * customer fname '%somename%' does full-text indexing in scenario? we're using sql server 2005. it depend upon dbms. believe systems not take advantage of full-text index unless use full-text functions. (e.g. match/against in mysql or freetext/contains in ms sql) here article on when, why, , how use full-text indexing in sql server: understanding sql server full-text indexing

Top ten ordering in Excel based on complex team rules -

i have excel spreadsheet in format similar following... | name | club | status | score | | fred | | gent | 145 | | bert | | gent | 150 | | harry | | gent | 195 | | jim | | gent | 150 | | clare | | lady | 99 | | simon | | junior | 130 | | john | b | junior | 130 | : : | henry | z | gent | 200 | i need convert table list of "top ten" teams. rules are each team score taken sum of 4 members of club. these totals should of best 4 scores except... each team must consist of @ least 1 junior or lady for example in table above team score club 625 not 640 take scores harry(190), bert(150), jim(150), , simon(130). not take fred's(145) score give gents. my question is, can done series of excel formula, or need resort using more procedural? ideally solution needs automatic in team selections, don't want have create separate hand crafted formula each team. not have neatly ordered list of each cl...

Need to accept payments from a linked checking account. What packages/frameworks/apis are available? -

i'm building payments tool site ideally able link customer's personal checking account. have ability pay other parties directly checking accounts. when sign financial accounts ing direct or e-trade, able link checking account taking account # , routing #. does know payment framework being used here? i think authorize.net has functionality. know of others?

algorithm - Randomly dividing a 2d complex enclosed region -

first define: region: big stuff manually created want divide. zone: small stuff want generate. i have map. world map in fact. , want divide small zones. size of zones dependent on region zone in. instance small europe (maybe europe have 200 zones) couple of huge ones atlantic ocean. i can manually create points enclose region. create regions each big space want have different size other spaces. instance create enclosed region europe. got butch of (latitude, longitude) points defining limits of europe region. shape of course not regular , there holes in middle of (i don't want create small zones on mediterranean sea big one). got huge 2d shape filled zones. zones n-sized polygons, number of sizes can randomly chosen or subject other constraints. area of each zone limited random (like 50 plus/minus 40%) although constraint again can relaxed (as exception, not rule). zones can not overlap , whole region must divided. the obvious question, algorithm can used solve prob...

wpf - How to bind non-existing IsEmpty property of listbox? -

i have form , button should enabled if listbox not empty. how can binding case? note: avoid creating custom converter. thanks! multiple options, if you're using mvvm pattern - viewmodel expose shouldshowdetails property, checks itemcount (visualized listbox) , returns boolean. bind enabled properties of dependent controls property. (recommended) write trigger on dependent controls - resets enabled property if value of listbox's itemcount property 0. write itemcount boolean converter , bind listbox's itemcount property directly

c++ - Am I misunderstanding assert() usage? -

i taking @ the assert() reference page , got stuck while read given example: /* assert example */ #include <stdio.h> #include <assert.h> int main () { file * datafile; datafile=fopen ("file.dat","r"); assert (datafile); fclose (datafile); return 0; } in example, assert used abort program execution if datafile compares equal 0, happens when previous call fopen not successful. i totally agree if fopen() fails, assert() abort execution. i'm concerned rightness of example: in opinion assert() there detect cases can't happen (like passing null pointer function documentation states forbidden). in example, failing open file not can't happen . in fact, can see dozens of reasons why fail. file couldn't exist, program run without required privileges, , on. i rather have done like: /* not longer assert example */ #include <stdio.h> #include <assert.h> int main () { file * datafile; datafile=...

unit testing - How are Mocks meant to be used? -

when introduced mocks felt primary purpose mock objects come external sources of data. way did not have maintain automated unit testing test database, fake it. but starting think of differently. wondering if mocks more effective used isolate tested method outside of itself. image keeps coming mind backdrop use when painting. want keep paint getting on everything. testing method, , want know how reacts these faked external factors? it seems incredibly tedious way advantage seeing when test fails because screwed , not 16 layers down. have have 16 tests same testing coverage because each piece tested in isolation. plus each test becomes more complicated , more tied method testing. it feels right me seems brutal kind of want know others think. i recommend take @ martin fowler's article mocks aren't stubs more authoritative treatment of mocks can give you. the purpose of mocks unit test code in isolation of dependencies can test piece of code @ "uni...

tinymce - how to load content in tiny mce? -

i'm loading content textarea, initialized instance of tiny mce. works perfect until textarea has paragraph. when try load paragraph image inside it, works strange. content inside original paragraph moved new paragraph , original added empty. why happening. in advance. i'm trying load following :- <p id="paragraph-06c073b3-6ba7-ae52-7bfe-9ca282e448dc" class="textelementclass"><div aria-disabled="true" style="position: relative; z-index: auto;" class="draggableitem imageelement nestedimg ui-draggable-disabled ui-state-disabled" id="element-4c4ac020-0b32-99e9-356e-ccd6470e8294"> <img style="position: relative;" src="images/file-managements.png" class="imageedit ui-draggable ui-draggable-disabled" id="image-4c4ac020-0b32-99e9-356e-ccd6470e8294"></div> lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's sta...

asp.net - What is the best way to rollout web applications? -

i'm trying create standard way of rolling out web applications our company. zip files, vbscript/javascript, , manual steps. for thick client installs generate msi installers using wise/wix. don't create installers websites in general xcopy deploy. have config files need changed, verify handlers registered in iis... list goes on. do people use msi installers web applications well, or other tool/scripting language? do consider msdeploy, direction microsoft investing in future deployment of web applications... know more future direction @ overview post web deployment in vs 2010

css - How to vertically center content with variable height within a div? -

Image
what best way vertically center content of div when height of content variable. in particular case, height of container div fixed, great if there solution work in cases container has variable height well. also, love solution no, or little use of css hacks and/or non-semantic markup. just add position: relative; top: 50%; transform: translatey(-50%); to inner div. what moving inner div's top border half height of outer div ( top: 50%; ) , inner div half height ( transform: translatey(-50%) ). work position: absolute or relative . keep in mind transform , translate have vendor prefixes not included simplicity. codepen: http://codepen.io/anon/pen/zyprdb

.net - Problems running unit test in Visual Studio -

when run release build of (vs 2008 .net) unit tests, following exception: system.io.fileloadexception: not load file or assembly 'arcvegaorm, version=1.0.3856.24327, culture=neutral, publickeytoken=0dd85ae1d99ddbee' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040). i not exception when run debug build tests. the unit test framework copying old version of 'arcvegaorm' assembly testresults\out folder. not know gets old version - not match version in projects bin\release folder. i beginning think there bug vs.net unit test framework, , has old version cached. one thing check gac (global assembly cache). can opening windows explorer , typing in c:\windows\assembly in address bar (assuming os installed on c drive). it may getting assembly gac instead. other things clean solution , rebuild make sure don't have old assembly references. also, if web application, hel...

ColdFusion: Is it safe to leave out the variables keyword in a CFC? -

in coldfusion component (cfc), necessary use qualified names variables-scoped variables? am going myself trouble if change this: <cfcomponent> <cfset variables.foo = "a private instance variable"> <cffunction name = "dosomething"> <cfset var bar = "a function local variable"> <cfreturn "i have #variables.foo# , #bar#."> </cffunction> </cfcomponent> to this? <cfcomponent> <cfset foo = "a private instance variable"> <cffunction name = "dosomething"> <cfset var bar = "a function local variable"> <cfreturn "i have #foo# , #bar#."> </cffunction> </cfcomponent> it won't matter specify "variables" when create variable, because foo placed in variables scope default; matter when access variable. <cfcomponent> <cfset foo = ...

Android Activities and Views -

when developing android app, there rule of thumb when should stop changing layouts , instead switch new activity? factors might influence decision? there no hard , fast rules, i've got few personal ones: i think of how users use button. in optimal app, natural use of "back" go through activities aim for. each time user might want use back, should new activity. of course, rules meant broken , you'll need override button control more complex interface. also, shouldn't tempted call setcontentview() again. if tempted redo entire layout of page, maybe should move new activity instead. i check out this guide .

cocoa touch - Connecting to sqlite in iphone development -

i have used sqlite database in of iphone applications know lot harder other languages such java , php use database. there way use database easier !? found framework in sourceforge here : http://mysql-cocoa.sourceforge.net/ think not cocoa-touch. there other framework ease sqlite pain !? thanx alot try fmdb it's sqlite wrapper , works iphone. or use coredata . it's not database wrapper, object graph persistence framework, may want.

filesize - PHP image resizing not working. Is there a file size limit? -

i'm using simple image manager class , , following code: <?php include('simpleimage.php'); $image = new simpleimage(); $image->load($target_path); if($image->getwidth() > 500) { $image->resizetowidth(500); echo "<p>image resized</p>"; } else echo "<p>image did not need resized.</p>"; $image->save($target_path); echo "<p>image saved</p>"; ?> the image resized when upload image width of 700, when upload big picture (width ~= 2300), doesn't work, , don't see of echo messages. do php image functions have size limit might causing this? you hitting memory_limit setting specified in php.ini. add error_reporting(e_all); script , see output is. use phpinfo() find out current memory limit setting. it can changed using ini_set("memory_limit", xyz) . otherwise, need change php.ini. a 2300 x 2300 pixel image going take @ least 2300 x 2300 x 3 ...

jquery - What are the best strategies for using multiple AJAX libraries? -

what experience can share using multiple ajax libraries? there useful features in prototype, in jquery, yahoo library, etc. possible include libraries , use want each, play nicely name spaces, etc. sake of speed there practical limit size/number of libraries include or negligible? there pairs work particularly (e.g. prototype/scriptaculous) or pairs don't? you use libraries, highly recommend against it. downloading , executing javascript choke browser , slow down user's experience. better user's perspective , developer's pick one. less context/architecture switching , less code maintain. like other answers have said, don't conflict. see yahoo!'s exceptional performance site more info.

.net - Getting started with REST -

i looking links best practices , sample code on creating rest ful web services using .net. also, other input might have regarding rest appreciated. ado.net data servcies makes easy build , consume restful web services in .net world nevertheless understanding concepts important. compared wcf (which added rest support later), ado.net data services built rest. guidelines building restful web services has info on resources need. this useful blog entry : the uniform interface constraints describe how service built web can participant in web architecture. these constraints described briefly follows : 1) identification of resources: resource information item can named , represented (e.g. document, stock price @ given point in time, current weather in las vegas, etc). resources in service should identified using uris. 2) manipulation of resources via representations: representation physical representation of resource , should correspond valid media type. using stan...

asp.net mvc - Where to put master page's code in an MVC application? -

i'm using few (2 or 3) master pages in asp.net mvc application , must each display bits of information database. such list of sponsors, current fundings status etc. so question was, should put these master-page database calling code? normally, these should goes own controller class right? that'd mean i'd have wire them manually (e.g. passing viewdatas) since out of normal routing framework provided mvc framework. is there way cleanly without wiring viewdata passing/action calls master pages manually or subclassing frameworks'? the amount of documentation low... , i'm new including concepts of mvc please share tips/techniques on this. one way put in masterpage view hook viewdata , define basecontroller : controller (or multiple base classes) db calls need. what wanna quite same thing described in this articles. i hope helps! regards

file io - How do I create an in-memory handle in Haskell? -

i want looks file handle backed in-memory buffer use i/o redirects. how can this? it's not possible without modifying compiler. because handle abstract data type, not typeclass.

javascript - Is it possible to make a gradient-transparent/layer masking image using canvas? -

i've been following lessons transparency , gradients on mozilla site: https://developer.mozilla.org/en-us/docs/web/guide/html/canvas_tutorial/applying_styles_and_colors have not been able figure 1 out. i know can achieve these effects png image; however, in program working on gradient change according image moved. here's example of effect i'm looking for. http://home.insightbb.com/~epyonxl1/gradientex.jpg i've aded code here http://code.google.com/p/canvasimagegradient/ adds drawimagegradient function canvasrenderingcontext2d. can draw image linear or radial gradient. doesn't work in ie, excanvas, due lack of getimagedata/putimagedata support. the following code example draw image radial gradient (context retrieve , image load not shown): var radgrad = ctx.createradialgradient( img.width / 2, img.height / 2, 10, img.width / 2, img.height / 2, img.width/2); radgrad.addcolorstop(0, "transparent"); radgrad.addcolorstop(1, ...

c# - Common memory optimization -

what common memory optimizations in csharp, dotnet 2.0. wanted see if there common things people may not doing default in winform app use structs small wrapper objects avoid heap fragmentation think object lifetimes, large objects not end on loh unless intend them to think allocations inside of loop make sure dynamically sized array of reasonable size, otherwise partition problem

python - Dynamically loading two libpython versions -

i have program embeds both python2 , python3 interpreters. libpython shared libraries dlopen() ed respective commands provide access interpreters , each interpreter maintains own state. this works fine if user uses pure python modules or builtins. trying load c extension (like termios) complains "undefined symbol: pyexc_typeerror". happens because c extensions aren't linked against libpython. python upstream doesn't think problem . to around that, can change dlopen() calls in program libpython shared libraries use rtld_global . that, however, trying use both python2 , python3 interpreters in same session of program causes abrt in process of calling py_initialize whichever interpreter invoked second. using 1 of interpreters works fine. any idea how work when c extensions won't linked against libpython, therefore requiring use of rtld_global ? sorry, won't work way want to. solution ordinarily involve linking each extension versioned l...

osx - my eclipse stopped working today -

today running problems eclipse, every time closed project window popped saying "error saving workspace" , complaining apache xerces. i decided download fresh install, , won't start. tried many variants (classic, javase, c++), hoping there distribution issues, nothing worked. eclipse starts saying "an error has occurred, see configurationlog ..." any idea? there cached files in system might have become corrupted? tried doing "find / | grep eclipse" found nothing interesting. thanks lot help, i'm quite in trouble without it regards, nicola montecchio p.s. tried 32 bit jvm nothing changed [edit] here relevant bits of log produced when starting: !entry org.eclipse.osgi 4 0 2010-07-23 21:35:16.835 !message unexpected runtime error has occurred. !stack 0 javax.xml.parsers.factoryconfigurationerror: provider org.apache.xerces.jaxp.saxparserfactoryimpl not found !entry org.eclipse.osgi 4 0 2010-07-23 21:35:16.839 !messa...

asp.net - Getting HTML from a page behind a login -

this question follow previous question getting html aspx page. decided try using webclient object, problem login page's html because login required. tried "logging in" using webclient object: webclient ww = new webclient(); ww.downloadstring("login.aspx?username=&password="); string html = ww.downloadstring("internal.aspx"); but still login page time. know username info not stored in cookie. must doing wrong or leaving out important part. know be? just pass valid login parameters given uri. should out. if don't have login information shouldn't trying circumvent it. public static string httppost( string uri, string parameters ) { system.net.webrequest req = system.net.webrequest.create( uri ); req.contenttype = "application/x-www-form-urlencoded"; req.method = "post"; byte[] bytes = system.text.encoding.ascii.getbytes( parameters ); req.contentle...

.net - Rolling your own message loop, any pitfalls? -

this question related this question exception handling . workaround found there consists of rolling own message loop. so main method looks this: [stathread] static void main() { // needed there'll exception thrown // application.run/application.doevents, instead of threadexception // event being raised. application.setunhandledexceptionmode(unhandledexceptionmode.throwexception); application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); form form = new mainform(); form.show(); // loop here keep app running if non-fatal exception caught. { try { application.doevents(); thread.sleep(100); } catch (exception ex) { exceptionhandler.consumeexception(ex); } } while (!form.isdisposed); } what i'm wondering though, is safe/decent way replace more typical 'application.run(new mainform());' , whether it's used exception handling or whatever else, or should stick using applica...

NHibernate/LINQ - Aggregate query on subcollection -

querying child collections has been recurring issue in our applications use nhibernate (via linq). want figure out how right. tried forever query work efficiently using linq, , gave up. can me understand best way this? model: serviceprovider hasmany->servicesprovided the gotcha here hasmany mapped component, can't directly query servicesprovided. posterity's sake, here's mapping: public serviceprovidermap() { discriminatorvalue(profiletype.service_provider.id); hasmany(p => p.servicesprovided) .table("serviceprovider_servicesprovided") .keycolumn("profileid") .component(spmapping => { spmapping.map(service => service.id) .not.nullable(); }) .asbag(); } the query trying create return collection of count of each service provided. ie: service1 -> 200, service2 -> 465, etc. i ...

What's the best method in ASP.NET to obtain the current domain? -

i wondering best way obtain current domain in asp.net? for instance: http://www.domainname.com/subdir/ should yield http://www.domainname.com http://www.sub.domainname.com/subdir/ should yield http://sub.domainname.com as guide, should able add url "/folder/content/filename.html" (say generated url.routeurl() in asp.net mvc) straight onto url , should work. same answer mattmitchell's modification. checks default port instead. request.url.scheme + system.uri.schemedelimiter + request.url.host + (request.url.isdefaultport ? "" : ":" + request.url.port)

ADO.NET Entity Framework tutorials -

does know of tutorials on ado.net entity framework? there few useful links here @ stack overflow , , i've found 1 tutorial @ jason's dotnet architecture blog , can recommend other tutorials? tutorials available microsoft, either online or part of conference/course material? microsoft offers .net 3.5 enhancements training kit contains documentation , sample code ado.net ef

Getting addresses from all results in a Google Maps query in Android? -

i'm working on android application i'm performing search on businesses in radius around city, , i'm looking way addresses of businesses @ each pin application can work them. can perform search , display on map using mapviews, can't figure out way access list of results. when use http approach output=csv or xml, returns address / geopoint of city centered search around. does know of set of methods or different approach can use addresses of returned businesses query in android application? thanks. this not via maps api, don't know that, there geocoder class in android sdk can use addresses geopoints viceversa geocoder a class handling geocoding , reverse geocoding. geocoding process of transforming street address or other description of location (latitude, longitude) coordinate. reverse geocoding process of transforming (latitude, longitude) coordinate (partial) address. amount of detail in reverse geocoded location description may vary, example 1 ...

iphone - HTTP POST request - sending username and password to the server -

i'm newcomer iphone world. i'm working on application having login page. have send uitext value of username , password server. code appreciated. you can check user_ name , password severer asihttprequest framework it's ex. of code twitter request.m file if ([challenge previousfailurecount] == 0) { nsurlcredential *newcredential; newcredential=[nsurlcredential credentialwithuser:[self username] password:[self password] persistence:nsurlcredentialpersistencenone]; [[challenge sender] usecredential:newcredential forauthenticationchallenge:challenge]; [newcredential release]; } else { [[challenge sender] cancelauthenticationchallenge:challenge]; // inform user user name , password // in preferences incorrect nslog(@"invalid username or password"); }

multithreading - iPhone accessing one resource by two threads -

i want synchronize 1 queue among 2 threads. such 1 thread performs enqueue , other performs dequeue. ideas?? cocoa class nsarray or nsmutablearray non thread safe, have use object nslock class make them thread safe.

Why #' is used before lambda in Common Lisp? -

i know why common lisp code see has things like (mapcar #'(lambda (x) (* x x)) '(1 2 3)) instead of just (mapcar (lambda (x) (* x x)) '(1 2 3)) , which seems work well. beginning learn common lisp, , having background in scheme, intrigues me. edit: know need #' function names because live in different namespace variables. question #' before lambda, lambda returns function object (i think). fact #'-less lambdas work because of macro expansion makes more intriguing... #'foo abbreviation (function foo) reader. in cl, there several different namespaces, #'foo or (function foo) return functional value of foo . you may want search "lisp-1 vs. lisp-2" , check other stackoverflow questions , or read old article py pitman , gabriel in order learn more concept of multiple namespaces (also called slots or cells of symbols). the reason that, in case of lambda #' may omitted is, macro in cl, expands thusly (taken ...

url - Combine websites without hurting SEO -

i have friend i'm helping out web design. basically, guy owns few businesses complementary of each other , wants combine them single site. there's service , b, based on west side of our state; , service , b based on east side. each has own website (eg, eastservicea.com, westservicea.com). the previous web designer maintained separate , unique content, , unique designs, 4 sites. wanting merge single site (statewideservica.com) new design. right 4 sites @ top of searches niche market. last thing want hurt seo. debate how merge these sites without hurting seo. keep existing url's , make content of same. redirect sites new url. set static page on existing urls content, links point new url. any thoughts? not sure best place ask question this, don't know of site more people have opinions on stack overflow. the answer question disgruntledgoat: http://webmasters.stackexchange.com ! or more specifically, answers given there -- it's great info...

Mouseover/mouseout + :not jquery issue -

i trying make simple content-sliding thingy , got stuck writing code simplest stuff - handling hover navigation part of slider. want when 1 of divs slide info has been clicked on, hover doesn't work it, works other 2 divs. i've tried classes , id's clicked div, nothing works when i'm getting hover part. i'm trying use :not filter select other 2 divs, or three, ones have not been #clicked. there isn't selection going on - no matter what, hover works 3 divs. i've tried using :not other functions, hide(), , works fine. css specificity issue? or wrong mouseover/mouseout? or maybe me, being incompetent fool? here's html: <div id="linkswrapper"> <div> <a>slide 1</a> <p>slide info 1.</p> </div> <div> <a>slide 2</a><p>slide info 2.</p> </div> <div> <a>slide 3</a> <p>slide 3 info.</p> </div> </div...

What is your single most favorite command-line trick using Bash? -

we know how use <ctrl>-r reverse search through history, did know can use <ctrl>-s forward search if set stty stop "" ? also, have ever tried running bind -p see of keyboard shortcuts listed? there on 455 on mac os x default. what single favorite obscure trick, keyboard shortcut or shopt configuration using bash? renaming/moving files suffixes quickly: cp /home/foo/realllylongname.cpp{,-old} this expands to: cp /home/foo/realllylongname.cpp /home/foo/realllylongname.cpp-old

wpf - Is it possible to reference control templates defined in microsoft's assemblies? -

i have scenario have provide own control template few wpf controls - i.e. gridviewheader. when take @ control template gridviewheader in blend, agregated several other controls, in cases styled control - i.e. splitter between columns. templates, resources hidden somewhere in system...dll (or somewhwere in themes dll's). so, question - there way reference predefined templates? far, i've ended having own copies of them in resources, don't approach. here sample scenario: have gridviewcolumnheader: <style targettype="{x:type gridviewcolumnheader}" x:key="gridviewcolumnstyle"> <setter property="horizontalcontentalignment" value="stretch"/> <setter property="verticalcontentalignment" value="stretch"/> <setter property="background" value="{staticresource gridviewheaderbackgroundcolor}"/> <setter property="...

compiler construction - Prevent implicit import of units in Delphi packages -

is there way prevent packages in delphi implicitly import units not listed in "contains" list? i'm looking compiler directive makes build fail if tries implicit import. problems occur when install package ide implicitly imports unit , try install package contains unit , ide tells cannot install package because unit contained in first package if shouldn't be! if you're on version of delphi that's older 2009, can make warning cause error using ddevextensions (it's free). once install it, go tools > ddevextensions - options , in "compiler enhancements" section select "active" check box , "treat warnings errors". can add warnings want not treated errors in memo below that. unfortunately, in case, looks want 1 warning treated error, you'll have add pretty every warning except 1 implicit importing list, although it's coding practice resolve compiler warnings anyways, might want have warnings cause errors. ...

Is it possible to print a variable's type in standard C++? -

for example: int = 12; cout << typeof(a) << endl; expected output: int c++11 update old question: print variable type in c++. the accepted (and good) answer use typeid(a).name() , a variable name. now in c++11 have decltype(x) , can turn expression type. , decltype() comes own set of interesting rules. example decltype(a) , decltype((a)) different types (and , understandable reasons once reasons exposed). will our trusty typeid(a).name() explore brave new world? no. but tool not complicated. , tool using answer question. compare , contrast new tool typeid(a).name() . , new tool built on top of typeid(a).name() . the fundamental issue: typeid(a).name() throws away cv-qualifiers, references, , lvalue/rvalue-ness. example: const int ci = 0; std::cout << typeid(ci).name() << '\n'; for me outputs: i and i'm guessing on msvc outputs: int i.e. const gone. not qoi (quality of implementation) issue. ...

When is a language considered a scripting language? -

what makes language scripting language? i've heard people "when gets interpreted instead of compiled". make php (for example) scripting language. criterion? or there other criteria? see also: what’s difference between “script” , “application”? a scripting language language "scripts" other things stuff. primary focus isn't building own apps getting existing app act way want, e.g. javascript browsers, vba ms office.

mysql - How do I restore a dump file from mysqldump? -

i given mysql database file need restore database on windows server 2008 machine. i tried using mysql administrator, got following error: the selected file generated mysqldump , cannot restored application. how working? it should simple running this: mysql -u <user> -p < db_backup.dump if dump of single database may have add line @ top of file: use <database-name-here>; if dump of many databases, use statements in there. to run these commands, open command prompt (in windows) , cd directory mysql.exe executable (you may have around bit it, it'll depend on how installed mysql, i.e. standalone or part of package wamp). once you're in directory, should able type command have above.

url - How to create query parameters in Javascript? -

is there way create query parameters doing get request in javascript? just in python have urllib.urlencode() , takes in dictionary (or list of 2 tuples) , creates string 'var1=value1&var2=value2' . here go: function encodequerydata(data) { let ret = []; (let d in data) ret.push(encodeuricomponent(d) + '=' + encodeuricomponent(data[d])); return ret.join('&'); } usage: var data = { 'first name': 'george', 'last name': 'jetson', 'age': 110 }; var querystring = encodequerydata(data);

language agnostic - Why shouldn't I use "Hungarian Notation"? -

i know hungarian refers - giving information variable, parameter, or type prefix name. seems rabidly against it, though in cases seems idea. if feel useful information being imparted, why shouldn't put right there it's available? see also: do people use hungarian naming conventions in real world? most people use hungarian notation in wrong way , getting wrong results. read excellent article joel spolsky: making wrong code wrong . in short, hungarian notation prefix variable names type (string) (systems hungarian) bad because it's useless. hungarian notation intended author prefix variable name kind (using joel's example: safe string or unsafe string), called apps hungarian has uses , still valuable.

How can I check if the given URL of an image exists using GWT? -

i want check if given url exists , it's image, in order create new image(string url) it. if given url not image should return error. you requestbuilder -- request image url, use response 's getheaders() method content type, , check if it's image.

drupal - How well Users Points Voting API works with FiveStars module -

i'm using "users points voting api" module combine "user points" module , "fivestar" module. it works, not expected. when user rate post, author gains n points. if user removes vote, author loses n points. n fixed number (i set in settings). fixed, , not related number of stars, depends on number of votes 1 receives , not how , how bad these votes (1,2.. or 5 stars). can confirm i've written ? seems module should work differently because allows specify positive , negative votes. maybe has not been developed fivestar module. thanks all votes in fivestar module positive in sense 1 star above zero. problem not integration itself, 2 modules don't mix well. user points react on positive/negative votes, since votes in fivestar positive, 1 star gain same result 5 star vote. you argue bad idea, how designed.

javascript - How does "this" keyword work within a function? -

i came across interesting situation in javascript. have class method defines several objects using object-literal notation. inside objects, this pointer being used. behavior of program, have deduced this pointer referring class on method invoked, , not object being created literal. this seems arbitrary, though way expect work. defined behavior? cross-browser safe? there reasoning underlying why way beyond "the spec says so" (for instance, consequence of broader design decision/philosophy)? pared-down code example: // inside class definition, object literal, have function: onrender: function() { this.menuitems = this.menuitems.concat([ { text: 'group module', rptletdiv: }, { text: 'group status', rptletdiv: }]); // etc } cannibalized post of mine, here's more ever wanted know this . before start, here's important thing keep in mind javas...

PHP/MySQL update a news record in a database problem -

i have php code trying use let user edit news record in form , when hit submit button, update record in database. problem works record not updated in database. could @ code , see problem occur? <?php $title = "edit news"; include("../includes/header.php"); include("../includes/database.php"); $done = false; $expected = array('newstitle', 'newscontent', 'id'); if ($_get && !$_post) { if (isset($_get['id']) && is_numeric($_get['id'])) { $id = $_get['id']; } else { $id = null; } if ($id) { $sql = "select * news id = $id"; $result = mysql_query($sql) or die ("error connecting database..."); $row = mysql_fetch_assoc($result); } // if form has been submitted, update record if (array_key_exists('update', ...

windows - How to test if a file is a directory in a batch script? -

is there way find out if file directory? i have file name in variable. in perl can this: if(-d $var) { print "it's directory\n" } you can so: if exist %var%\nul echo it's directory however, works directories without spaces in names. when add quotes round variable handle spaces stop working. handle directories spaces, convert filename short 8.3 format follows: for %%i in (%var%) if exist %%~si\nul echo it's directory the %%~si converts %%i 8.3 filename. see other tricks can perform for variables enter help for @ command prompt. (note - example given above in format work in batch file. work on command line, replace %% % in both places.)

what are the disadvantages of using ClickOnce Deployment in .Net? -

can tell me disadvantages of clickonce deployment respect other means of deployment? one significant disadvantage clickonce applies user installs it. not shared other users. may or may not problem specific use case. this page lists several differences between clickonce , standard installs.

performance - Best Visual Studio Hardware Upgrade -

i have reasonably modern developer desktop (e6600, asus pn5-e, 2gb ram, 350gb sata2, vista ultimate x32), i'd squeeze more out of it. wondering best bang-for-bucks hardware upgrade be. if limit budget £150gbp (~$300usd), people give me best performance increase when developing? (note have msdn can go x64 if that's going give me anything.) i've been reading jeff atwood's ultimate developer rig series , thinking adding 10,000k rpm raptor , booting off best (presumably run projects off other drive, if matters??). edit 1: sorry, should have said - have dual monitors already, excellent answer one! want machine fast can it. edit 2: okay, i've accepted answer of getting monitor (and loving comment 3 of them!!). hadn't mentioned originally, best upgrade money. however, have 2 monitors (one 1600x1200, 1 1280x1024), going raptor. have happily upvoted both albert's , antic's answers too! have looked @ perfmom whilst working , disk 1 maxes out ...

c# - Does an empty array in .NET use any space? -

i have code i'm returning array of objects. here's simplified example: string[] getthestuff() { list<string> s = null; if( somepredicate() ) { s = new list<string>(); // imagine load data or } return (s == null) ? new string[0] : s.toarray(); } the question is, how expensive new string[0] ? should return null , make caller accept null valid way of indicating "nothing found"? nb: being called in loop gets run hundreds , hundreds of times, it's 1 of few cases think kind of optimiziation not 'premature'. ps: , if premature, i'd still know how works :-) update: initially when asked if used space, thinking of things 'c/c++' point of view, kind of how in c, writing char a[5]; allocate 5 bytes of space on stack, , char b[0]; allocate 0 bytes. i realise not fit .net world, curious if compiler or clr detect , optimize out, non-resizeable array of size 0 shouldn't (as far ca...

Accurate timestamping in Python logging -

i've been building error logging app , after way of accurately timestamping incoming data. when accurately mean each timestamp should accurate relative each other (no need sync atomic clock or that). i've been using datetime.now() first stab, isn't perfect: >>> in range(0,1000): ... datetime.datetime.now() ... datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 609000) datetime.datetime(2008, 10, 1, 13, 17, 27, 609000) datetime.datetime(2008, 10, 1, 13, 17, 27, 609000) etc. the changes between clocks first sec...

ocr - Programmatically recognize text from scans in a PDF File -

i have pdf file, contains data need import database. files seem pdf scans of printed alphanumeric text. looks 10 pt. times new roman. are there tools or components can allow me recognize , parse text? i've used pdftohtml strip tables out of pdf csv. it's based on xpdf , more general purpose tool, includes pdftotext . wrap process.start call c#. if you're looking little more diy, there's itextsharp library - port of java's itext - , pdfbox (yes, says java - have .net version way of ikvm.net ). here's codeproject articles on using itextsharp , pdfbox c#. and, if you're really masochist, call adobe's pdf ifilter com interop. ifilter specs pretty simple, guess interop overhead significant. edit: after re-reading question , subsequent answers, it's become clear op dealing images in pdf. in case, you'll need extract images (the pdf libraries above able easily) , run through ocr engine. i've used modi interactive...

c# - Handle exception on service startup -

i'm writing series of windows services. want them fail if errors thrown during startup (in onstart() method). had assumed merely throwing error in onstart() this, i'm finding instead "starts" , presents me message stating "the service has started, inactive. correct?" (paraphrase). how handle error fails start service? if running .net 2.0 or higher, can use servicebase.stop stop service onstart. otherwise call stop new thread. ref [devnewsgroups] ( http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic50404.aspx ) (news group gone)

C++ compile-time expression as an array size -

i'm not sure if term's "array addition". i'm trying understand following line do: int var[2 + 1] = {2, 1}; how different int var[3] ? i've been using java several years, i'd appreciate if explained using java-friendly words. edit: thousands of helped me out, occam's razor applies here. it's not different. c++ allows expressions (even non-constant expressions) in subscripts of array declarations (with limitations; other initial subscript on multi-dimensional array must constant). int var[]; // illegal int var[] = {2,1}; // automatically sized 2 int var[3] = {2,1}; // equivalent {2,1,0}: not specified 0 int var[3]; // however, no initializer, nothing initialized zero perhaps code reading writes 2 + 1 instead of 3 reminder trailing 0 intentional.