Posts

Showing posts from June, 2010

Java vs. PHP Speed Comparison -

which language faster web, java or php? it difficult 1 answer in theory java should faster: it's precompiled, trivial algorithim run faster in java php , there has been vast amount of work done optimise java improving code, standard libraries, jit compilers, etc. php loaded , interpreted every time if you're not using zend optimiser, objects intialised on every execution, trivial string varaible complex object many methods support. the problem in practice php sites seem run faster using fewer resources. i think because php developers take more straightforward approach design , don't lost trying implement exotic design patterns , implementing endless pointless abstractions.

grails - How do I increase the number of default rows per page? -

grails scaffolding defaults 10 rows per page. increase number without generating views , changing 10 in every file. change default? you have install scaffold templates with: grails install-templates now, edit in src/templates/scaffolding controller.groovy , increase value params.max want

Hibernate: Why does a change of bag lead to strange ADDs and DELETEs in the database? -

i have n:m-association between 2 classes user , role, implemented bag lazy="extra". association stored an association table sind user can have many roles , role can associated many users. now when add new role user, hibernate emmits sql code first removes entries in th eassociation table adds them again plus new association. i'd know why happens , how can rid of behavior. ralf i've found solution myself: hibernate bags first delete alle entreis , rebuild new state. if use set, association maintained. see hibernate manual, improving performance

c++ - Visual Studio Warning C4996 -

i'm getting following warning warning c4996: 'std::_uninitialized_copy0': function call parameters may unsafe - call relies on caller check passed values correct. disable warning, use -d_scl_secure_no_warnings. see documentation on how use visual c++ 'checked iterators' c:\program files\microsoft visual studio 10.0\vc\include\memory 348 i can't seem find information combat warning. looking @ output seems warning has boost.signals2 , auto_buffer. is safe ignore or can remove somehow? first, quite fond of compiler warnings. invoke gcc -wall -wextra. however, msvc warning c4996 fires on valid code. changes proposed in warning text compromise code portability, while never substantially improve code quality. regularly suppress warning in msvc projects (project properties->c++->advanced->disable specific warnings). check this , that discussions.

How do I use a start commit hook in TortoiseSVN to setup a custom log entry? -

i'd automate tortoisesvn part of commit process. i'd dynamically create log entry commit dialog. i know can launch commit dialog either commandline or right clicking on folder , selecting svncommit. i'd use start commit hook setup log entry. thought worked passing entry file name in messagefile variable when add hook script cannot see variable (hook launched after right clicking , choosing svncommit). when try using commandline use /logmsgfile parameter seems have no effect. i'm using tortoisesvn 1.5.3. looks own misunderstanding of the api caused problem. solution: 1) i've added start commit hook script tortoisesvn using hooks gui in settings area of right click menu. 2) script receive 3 pieces of information: path messagefile cwd details see: manual these passed command line arguements script - reason had thought set temporary environmental variables. my script opens file specified second arguement , adds in custom text. ...

static typing - Do you know of any examples of elegant solutions in dynamically typed languages? -

imagine 2 languages (apart type information) have same syntax, 1 statically typed while other 1 uses dynamic typing . then, every program written in statically typed language, 1 can derive equivalent dynamically typed program removing type information. not neccessarily possible other way around, class of dynamically typed programs strictly larger class of statically typed programs. let's call dynamically typed programs, there no mapping of variables types making them statically typed " real dynamically typed programs". as both language families definitly turing-complete, can sure every such real dynamically typed program there exists statically typed program doing same thing, read "experienced programmers able write elegant code in dynamically typed languages". ask myself: there examples of real dynamically typed programs, equivalent statically typed programm more complex / less "elegant" (whatever may mean)? do know of such exampl...

vb.net - Clean up Designer.vb file in Visual Studio 2008 -

i noticed designer.vb file of 1 of forms has a lot of controls aren't used or visible on form. copying controls other forms. there way clean designer.vb file , rid of unused controls? **update: windows form project. the real solution see copy controls new form selecting them in designer. way not created controls should not follow next form.

java - What versions of related technologies apply to J2EE 1.4, 5, and 6? -

so i've had hairpulling experiences lately because of coming onto projects being developed using 1 technology (say tomcat 6) having deploy (say oracle 10g r3). differing application servers aside, multiple times i've had downgrade java ee specs java ee 5 j2ee 1.4 , in doing, had scour web figure out versions of apis should exist in build path ensure compatibility. started compose list hope able fill in or correct. check out: j2ee technology, desc ,1.4, 5, 6 ws, web service api, ?, ?, 1.3 saaj, soap attach, 1.2, ?, ? jaxp, xml processing, 1.2, ?, ? jaxb, xml binding, ?, 2.0, 2.2 stax, streaming api xml, ?, ?, ? jax-ws, xml web services, ?, 2.1, 2.2 jax-rpc, xml remote procedure, 1.1, 1.1, 1.1 jax-rs, xml restful services, x, x, 1.1 jaxr, xml registry, 1.0, ?, ? jsf, java server faces, jsp only, 1.2, 2.0 jsp, java server pages, 2.0, 2.1, 2.2 el, expression lang, 2.0, 2.1, 2.2 jstl, standard tag lib, 1.1, 1.2, 1.2 servlet, servlet api spec, 2.4, 2.5, 3.0 ...

sql server - save DataTable to database -

hi, generating datatable webservice , save whole datatable 1 database table. datatable ds = //get info webservice the datatable getting generated next .i getting stuck .show me syntax.i dont need select statement there either, want insert info datatable blank db table. use bulkcopy, code. , make sure table has no foriegn key or primary key constraints. sqlbulkcopy bulkcopy = new sqlbulkcopy(myconnection); bulkcopy.destinationtablename = table.tablename; try { bulkcopy.writetoserver(table); } catch(exception e){messagebox.show(e.message);}

Alternative to PHP QuickForm? -

i'm playing around html_quickform generating forms in php. seems kind of limited in it's hard insert own javascript or customizing display , grouping of elements. are there alternatives quickform might provide more flexibility? if find hard insert javascript form elements, consider using javascript framework such prototype or jquery . there, can centralize task of injecting event handling form controls. by that, mean won't need insert event handlers html form code. instead, register events somewhere else. example, in prototype able write this: $('myformcontrol').observe('click', myclickfunction) also have @ answers another question . /edit: of course, can insert custom attributes , event handlers form elements using html_quickform. however, above way superior.

Minimun Stable Linux Kernel -

i need compile minimum linux kernel, mean, basic , generic modules work on low resources machines. is there specification of minimum modules kernel must have accomplish needs? the unique requirement must stable. where can find information it? i'm not sure "accomplish needs" means, whenever need real small/quick/easy use: http://www.damnsmalllinux.org/

Is global memory initialized in C++? -

is global memory initialized in c++? , if so, how? (second) clarification: when program starts up, in memory space become global memory, prior primitives being initialized? i'm trying understand if zeroed out, or garbage example. the situation is: can singleton reference set - via instance() call, prior initialization: mysingleton* mysingleton::_instance = null; and 2 singleton instances result? see c++ quiz on on multiple instances of singleton... yes global primitives initialized null. example: int x; int main(int argc, char**argv) { assert(x == 0); int y; //assert(y == 0); <-- wrong can't assume this. } you cannot make assumptions classes, structs, arrays, blocks of memory on heap... it's safest initialize everything.

sql server - Priority of a query in MS SQL -

is there way tell ms sql query not important , can (and should) take time? likewise there way tell ms sql should give higher priority query? not in versions below sql 2008. in sql server 2008 there's resource governor. using can assign logins groups based on properties of login (login name, application name, etc). groups can assigned resource pools , limitations or restrictions i.t.o. resources can applied resource pools

vb.net - How do I locate a Word application window? -

i have vb.net test application clicks link opens microsoft word application window , displays document. how locate word application window can grab text it? you can use word com object open work document , manipulate it. make sure add reference microsoft word first. imports system.runtime.interopservices imports microsoft.office.interop.word public class form1 inherits system.windows.forms.form private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim strfilename string dim wordapp new microsoft.office.interop.word.application dim doc microsoft.office.interop.word.document try doc = wordapp.documents.open("c:\testdoc.doc") doc.activate() catch ex comexception messagebox.show("error accessing word document.") end try end sub end class the doc object handle instance of word have created , can use normal options (save, print etc). can likewise wordapp. trick use macro editor in word ...

rounding - Scaling Up a Number -

how scale number nearest ten, hundred, thousand, etc... ex. num = 11 round 20 num = 15 round 20 num = 115 round 200 num = 4334 round 5000 i guess formula might work? unless have more examples show. power = floor(log10(n)) result = (floor(n/(10^power)) + 1) * 10^power

c# - MySQL - Multiple result sets -

i'm using .net connector connect mysql. in application there few threads using same connection, if mysqldatareader not closed yet , thread trying execute query gives error: there open datareader associated connection must closed first. will there ever support in mysql multiple result sets or it's called? my database management class: public class databaseconnection { private mysqlconnection conn; public void connect(string server, string user, string password, string database, int port = 3306) { string connstr = string.format("server={0};user={1};database={2};port={3};password={4};charset=utf8", server, user, database, port, password); conn = new mysqlconnection(connstr); conn.open(); } private mysqlcommand preparequery(string query, object[] args) { mysqlcommand cmd = new mysqlcommand(); cmd.connection = conn; (int = 0; < args.length; i++) { st...

Python dictionary from an object's fields -

do know if there built-in function build dictionary arbitrary object? i'd this: >>> class foo: ... bar = 'hello' ... baz = 'world' ... >>> f = foo() >>> props(f) { 'bar' : 'hello', 'baz' : 'world' } note: should not include methods. fields. note best practice in python 2.7 use new-style classes (not needed python 3), i.e. class foo(object): ... also, there's difference between 'object' , 'class'. build dictionary arbitrary object , it's sufficient use __dict__ . usually, you'll declare methods @ class level , attributes @ instance level, __dict__ should fine. example: >>> class a(object): ... def __init__(self): ... self.b = 1 ... self.c = 2 ... def do_nothing(self): ... pass ... >>> = a() >>> a.__dict__ {'c': 2, 'b': 1} a better approach (suggested robert in comments) builtin vars ...

preprocessor - Include CSS or Javascript file for specific node in Drupal 6 -

what best method including css or javascript file specific node in drupal 6. i want create page on site has little javascript application running, css , javascript specific page , not want included in other page loads @ all. i'd advise against using hook_nodeapi that. adding css , javascript related layout hook_nodeapi not place it: use themeing. way, can override files when you're going develop new theme. doing nodeapi approach bit harder (you'd have search js/css list files, remove them , replace them own). anyway: need add node preprocess function adds files you. can either in module or in custom theme. module be: function mymodule_preprocess_node(&$variables) { $node = $variables['node']; if (!empty($node) && $node->nid == $the_specific_node_id) { drupal_add_js(drupal_get_path('module', 'mymodule') . "/file.js", "module"); drupal_add_css(drupal_get_path('module', 'my...

Generate Texture in Silverlight imitate leather -

i display textures in different colors pretty having texture. how do in silverlight? thanks! alt text http://a.imageshack.us/img535/5255/leathertexture.png turn texture alpha textue. exact steps depend on image manipulation software. after place texture on top of colored rectangle. make pixel shader better result, overkill in case.

internet explorer - How to view web pages at different resolutions -

i developing web site , need see how @ different resolutions. catch must work on our intranet. is there free solution? for internet explorer there's internet explorer developer toolbar . lets select resolutions quite easily.

Alternative Style(CSS) methods in SAP Portal? -

i overriding lot of sap's portal functionality in current project. have create custom fixed width framework, custom iview trays, custom km api functionality, , more. with of these custom parts, not using lot of style functionality implemented sap's theme editor. create external css, store outside of portal , reference it. storing externally allow easier updates rather storing css within portal application. allow custom pieces have styles in once place. unfortunately, i've not found way gain access head portion of page allows me insert external stylesheet. portal applications can using iresource object gain access internal references, not items on server. i'm looking ideas allow me gain functionality. have x-posted on sap's sdn , suspect i'll better answer here. i'd consider dirty hack, non-portal developer i'd consider using javascript insert new link element in head pointing new css file. of course you'd have flash of un-s...

silverlight - WCF Data Services UpdateObject not working -

i have silverlight client grid getting data wcf data service. works fine. however if want update changed grid row, service data context updateobject not working: dataservicecontext.updateobject(mygrid.selecteditem); foreach (object item in dataservicecontext.entities) { // } dataservicecontext.beginsavechanges(savechangesoptions.batch, onchangessaved, dataservicecontext); i have created loop inspect values entities items , value not updated @ all. beginsavechanges works fine, uses not updated values. any ideas how fix that? thanks right flushed out savechanges show error message if endsavechanges() fails, code sample below. can't use console write out message in silverlight, idea. for instance, when wrote following sample, found getting forbidden error, because entity set had entitysetrights.allread, not entitysetrights.all class program { private static adventureworksentities svc; static void main(string...

reporting - Can I customize a "Date Prompt" in Cognos8? -

i working cognos8 report studio. in report there 2 date prompts: start date , end date . users can select 2 different dates or make them both same date. report has valid data last business date of each month. example, if jan 31 sunday, valid data available jan 29 friday (the last business day of month). can have customized "date prompt" can disable other dates except last business day of each month? users should able select month-end dates , no other dates? if understand correctly users can select different dates each selection can last business day of month. start:29-jan-2008 , end:30-mar-2008 or same date start:29-jan-2008 , end:29-jan-2008. why have days @ all? model data include month/year field e.g. - "jan 2008" , present multi-select list box prompt? sure data source not have gl accounting period field or dictionary can use? if doesn't work you'll have try calculate last day of month may need include business holidays in particular...

Is there a way around coding in Python without the tab, indent & whitespace criteria? -

i want start using python small projects fact misplaced tab or indent can throw compile error getting on nerves. there type of setting turn off? i'm using notepad++. there maybe ide take care of tabs , indenting? i'm using notepad++. there maybe ide take care of tabs , indenting? i liked pydev extensions of eclipse that.

inheritance - How to remove this parallel hierarchy -

i'm trying find best design following scenario - application store results of dance competitions. an event contains multiple rounds, each round contains number of performances (one per dance). each performance judged many judges, return scoresheet. there 2 types of rounds, final round (containing 6 or less dance couples) or normal round (containing more 6 dance couples). each requires different behaviour , data. in case of final round, each scoresheet contains ordered list of 6 couples in final showing couple judge placed 1st, 2nd etc. call these placings "a scoresheet contains 6 placings". placing contains couple number, , place couple is in case of normal round, each scoresheet contains non-ordered set of m couples (m < number of couples entered round - exact value determined competition organiser). call these recalls: "a score sheet m recalls". recall not contain score or ranking for example in final 1st place: couple 56 2nd place: couple...

events - Calling function when program exits in java -

i save programs settings every time user exits program. need way call function when user quits program. how do that? i using java 1.5. you can add shutdown hook application doing following: runtime.getruntime().addshutdownhook(new thread(new runnable() { public void run() { // want } })); this equivalent having try {} {} block around entire program, , encompasses what's in block. please note caveats though!

c# - Programmatically handling the Vista Sidebar -

is there api bring vista side bar front (win+space) programatically , reverse (send ground). probably using setwindowpos can change placed top / bottom of z-order or top-most window. need find handle sidebar using findwindow or application winspy. but after like. sets window on top, not top most. setwindowpos(sidebarhandle, hwnd_top, 0, 0, 0, 0, swp_nomove | swp_noresize); sets window @ bottom. setwindowpos(sidebarhandle, hwnd_bottom, 0, 0, 0, 0, swp_nomove | swp_noresize); this best guess on achieving asked, helps.

string - strpos function issue in PHP not finding the needle -

in php have open .php file , want evaluate lines. when $table_id , $line variables assigned value. within text file have: ... $table_id = 'crs_class'; // table name $screen = 'crs_class.detail.screen.inc'; // file identifying screen structure ... amongst other lines. if statement below never detects occurance of $table_id or $screen (even without $ prepended). can't understand why won't work strpos statement below looking 'require' works fine. so, why isn't if statement getting hit? while ($line=fgets($fh)) { //echo "evaluating... $line <br>"; **if ((($pos = stripos($line, '$table_id')) === true) || (($pos = stripos($line, '$screen'))===true))** { // todo: not evaluating tableid , screen lines correctly fix. // set $table_id , $screen variables task scripts eval($line); } if (($pos=stripos($line, 'require')) === true) { ...

c# - How can I tell if an element matches a PropertyCondition in Microsoft UI Automation? -

i'm trying find automationelement in particular row of gridview (so there many identical elements). i'm iterating on elements in row, , i'd use matcher see if particular element matches condition i'm passing it. i'm starting simple propertyconditions. here's test: [testfixture] public class conditionmatcherbehaviour { [test] public void shouldmatchapropertyconditionbyitsvalue() { var conditionmatcher = new conditionmatcher(); var condition = new propertycondition(automationelement.controltypeproperty, controltype.pane); assert.true(conditionmatcher.matches(automationelement.rootelement, condition)); } } and here's code: public class conditionmatcher : imatchconditions { public bool matches(automationelement element, condition condition) { var propertycondition = (propertycondition) condition; return propertycondition.value.equals(element.getcurrentpropertyvalue(propertycondition.prop...

eclipse - type a simple "©" in STS on a macbook pro -

i have simple realy annoying problem: can't manage type simple "©" in sts (springsource tool suite) on macbook pro. in other editor (even plain eclipse) or application use alt + g shortcut, not work in sts 2.3.3.m2 , not working 2.3.2. idea whats wrong? thanks .domi this caused combination of bug in groovy plugin , keyboard layout (de_ch). bug fixed: http://jira.codehaus.org/browse/greclipse-808

osx - custom list control in cocoa -

i trying in screenshot alt text http://smokingapples.com/wp-content/uploads/2009/12/socialite-hud.jpg in cocoa, mean custom list control. know how kind of things can done? thanks in advance help, regards, update: nstableview supports view-based rows variable heights: - (nstableviewrowsizestyle)rowsizestyle return value row style style. see nstableviewrowsizestyle supported options. discussion row size style can modified on row row basis invoking delegate method tableview:heightofrow: , if implemented. the rowsizestyle defaults nstableviewrowsizestylecustom . nstableviewrowsizestylecustom indicates use rowheight of table, instead of pre-determined system values. generally, rowsizestyle should nstableviewrowsizestylecustom except "source lists". implement variable row heights, set value nstableviewrowsizestylecustom , implement tableview:heightofrow: in delegate. availability available in os x v10.7 , later...

InstallShield: FilterProperty column of ISComponentExtended table? -

anybody has idea custom table used , meaning of column in particular? documentation silent , info on net scarce. i'm trying same installshield project. have been successful figuring out how generate values in filterproperty column in iscomponentextended table? many thanks! charles updates: the filterproperty string of guid "-" replaced " _ ", beginning "_" , ending "_filter". wrote simple tool import files project , project compiles fine.

utf 8 - How to remove u'' from python script result? -

i'm trying write parsing script using python/scrapy. how can remove [] , u' strings in result file? now have text this: from scrapy.spider import basespider scrapy.selector import htmlxpathselector scrapy.utils.markup import remove_tags googleparser.items import googleparseritem import sys class googleparserspider(basespider): name = "google.com" allowed_domains = ["google.com"] start_urls = [ "http://www.google.com/search?q=this+is+first+test&num=20&hl=uk&start=0", "http://www.google.com/search?q=this+is+second+test&num=20&hl=uk&start=0" ] def parse(self, response): print "===start=======================================================" hxs = htmlxpathselector(response) qqq = hxs.select('/html/head/title/text()').extract() print qqq print "---data--------------------------------------------------------" ...

c# - Best way to randomize an array with .NET -

what best way randomize array of strings .net? array contains 500 strings , i'd create new array same strings in random order. please include c# example in answer. if you're on .net 3.5, can use following ienumerable coolness (vb.net, not c#, idea should clear...): random rnd=new random(); string[] myrandomarray = myarray.orderby(x => rnd.next()).toarray(); edit: ok , here's corresponding vb.net code: dim rnd new system.random dim myrandomarray = myarray.orderby(function() rnd.next) second edit, in response remarks system.random "isn't threadsafe" , "only suitable toy apps" due returning time-based sequence: used in example, random() thread-safe, unless you're allowing routine in randomize array re-entered, in case you'll need lock (myrandomarray) anyway in order not corrupt data, protect rnd well. also, should well-understood system.random source of entropy isn't strong. noted in msdn documentation , sh...

regex - How does this regular expression work? -

from this article , /^1?$|^(11+?)\1+$/ checks whether number(its value in unary) prime or not. using this, perl -l -e '(1 x $_) !~ /^1?$|^(11+?)\1+$/ && print while ++$_;' returns list of prime numbers. i not have enough experience perl, understand regular expression true number not prime. so, if print numbers not produce true expression, have list of prime numbers. thats perl query trying do. about regex part, ^1?$ part counting 1 not prime ^(11+?)\1+$ matching not prime numbers starting 4. what not understand why ? in regex needed @ all. according me /^1$|^(11+)\1+$/ should fine , actually perl -l -e '(1 x $_) !~ /^1$|^(11+)\1+$/ && print while ++$_;' gives me same set of prime numbers. is there flaw in understanding of regular expression? why ? s needed? isn't ? supposed match 0 or 1 occurrence of expression preceding it? the first ? matching empty string (i.e. 0) non-prime. if don't care whether ...

objective c - Use CLLocationManager and MKReverseGeocoder to get name of city -

i trying name of city of user's current location using mkreversegeocoder has errors cannot recognize. here details: it has errors cannot recognize undefined symbols: ".objc_class_name_cllocationmanager", referenced from: literal-pointer@__objc@__cls_refs@cllocationmanager in mapviewcontroller.o "_kcllocationaccuracynearesttenmeters", referenced from: _kcllocationaccuracynearesttenmeters$non_lazy_ptr in mapviewcontroller.o ld: symbol(s) not found collect2: ld returned 1 exit status here;s code: mapviewcontroller.m // // mapviewcontroller.m // map // // created ashutosh tiwari on 7/23/10. // copyright isu 2010. rights reserved. // #import <mapkit/mapkit.h> #import "mapviewcontroller.h" @implementation mapviewcontroller // implement viewdidload additional setup after loading view, typically nib. - (void)viewdidload { cllocationmanager *locationmanager = [[[cllocationmanager alloc] init] autorelease]; locat...

c# - DataReader, DataColumn - Can These Show Me Columns In Schema Such as SomeSchema.SomeColumn? -

i have database table columns in multiple schemas. example: sometable someschema.column1 someschema.column2 anotherschema.columna anotherschema.columnb i have code using datatable.rows[r][c].tostring() syntax , looks column1 or columna part being returned. need full name someschema.column1 right seems code throwing sql exception column1 not found. i'm assuming if can reference someschema.column1 correct exception. can using datatable or datacolumn or there approach need take this? ideas? have searched google , site such keywords "c# datatable datacolumn schema table dbo" , have not had luck. lmao, i've been working on long without break think... it's not columns have schema, table, think can tweak query table name schema think feed right in existing code , good... i'll post after it's done , tested... sigh...

architecture - HTTP method to represent "fire and forget" actions in RESTful service -

thinking rest, it's relatively easy map http methods crud actions: post create, read, etc. "fire , forget" actions? http method best represent fire , forget action such triggering batch job (in no response sent caller)? post spring mind, think appropriate method because 99% of time supply bunch of parameters these types of actions. think? post spring mind, think more appropriate method because 99% of time supply bunch of parameters these types of actions. think? external state i think number of parameters use has nothing verb use. key issue changing externally visible state? batchjob resources in example, if batch job not affect externally visible state of object implement batch job. model batch job resource associated resource container. you use post create new batchjob resource , allow user see progress of job far. on resource container list of running batch jobs, possibly calling delete kill one.

html - Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"? -

the following 2 methods of building link has sole purpose of running javascript code. better, in terms of functionality, page load speed, validation purposes, etc.? function myjsfunc() { alert("myjsfunc"); } <a href="#" onclick="myjsfunc();">run javascript code</a> or function myjsfunc() { alert("myjsfunc"); } <a href="javascript:void(0)" onclick="myjsfunc();">run javascript code</a> i use javascript:void(0) . three reasons. encouraging use of # amongst team of developers inevitably leads using return value of function called this: function dosomething() { //some code return false; } but forget use return dosomething() in onclick , use dosomething() . a second reason avoiding # final return false; not execute if called function throws error. hence developers have remember handle error appropriately in called function. a third ...

iphone - Take screenshots of a UIView including 3 UITableView(visible+invisible) part -

i have uiview having 3 uitableview , need take screen shot. problem invisible part of 3 tables . can find way take screen shot of whole view including complete scrolled contents of tables. this helps contents of layer (ie. , uiview) uigraphicsbeginimagecontext(tableview.frame.size); cgcontextref ctx = uigraphicsgetcurrentcontext(); [tableview.layer renderincontext:ctx]; uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();

clr - How do I embed iron ruby into a c# program? -

i want embed iron ruby mud creating , reason i'm having trouble finding correct examples started. all want create game 'you' player program bots in iron ruby , interperet code in c# , make bots want them to. also, want make code can parsed string iron ruby code use control bots. i understand fact dlr , clr 2 different things can't find sample. actual game classic telnet server coded in c# scratch , connects via strict telnet protocol. it can found here: pttmud.the-simmons.net : 4243 via telnet client , should work. look @ post: http://www.ironshay.com/post/make-your-application-extendable-using-the-dlr.aspx . shows how call ironruby/ironpython code c#.

sql - SQLite multiple table INNER JOIN with USING (...) Errors -

i trying run query on sqlite database inner join s 2 additional tables: select usages.date date, usages.data data, stores.number store, items.name item usages inner join stores using (store_id) inner join items using (item_id) however, error sql error: cannot join using column item_id - column not present in both tables i know can use explicit inner join stores on usages.store_id = stores.store_id (and works), but: why using query throw error in sqlite? it doesn't on mysql... i should note: isn't problem me, using on syntax, know why happening. so have: inner join items using (item_id) ...and error says: sql error: cannot join using column item_id - column not present in both tables that's got 1 of least cryptic error messages i've seen. don't it's not clear me table being compared items.item_id - stores or usages ? why refrain using or natural join syntax...

C++ performance vs. Java/C# -

my understanding c/c++ produces native code run on particular machine architecture. conversely, languages java , c# run on top of virtual machine abstracts away native architecture. logically seem impossible java or c# match speed of c++ because of intermediate step, i've been told latest compilers ("hot spot") can attain speed or exceed it. perhaps more of compiler question language question, can explain in plain english how possible 1 of these virtual machine languages perform better native language? generally, c# , java can fast or faster because jit compiler -- compiler compiles il first time it's executed -- can make optimizations c++ compiled program cannot because can query machine. can determine if machine intel or amd; pentium 4, core solo, or core duo; or if supports sse4, etc. a c++ program has compiled beforehand mixed optimizations runs decently on machines, not optimized as single configuration (i.e. processor, instruction set, other h...

c# - Applying a Condition to an Eager Load (Include) Request in Linq to Entities -

i have table product. product related productdescription in one-to-many relationship. productdescription can have more 1 row each product. have multiple rows if there multiple translations description of product. product has many-to-one relationship language. language has language code (en, es, etc.) languageid (found in productdescription well). i want give users ability request product , further tell application return descriptions in specific language. i having bear of time accomplishing in linq entities. want generate sql this: select * product p join productdescription pd on p.productid = pd.productid join (select * language alternatecode = 'es') l on pd.languageid = l.languageid (alternatecode field name language code) does know how this? i'm left right pulling down languages, filtering them out linq objects less ideal sure. language codes per product in loop require multiple sql round trips don't want. appreciate help! use projection , no...

What is the best way to list a member and all of its descendants in MDX? -

in olap database work there 'location' hierarchy consisting of levels company, region, area, site, room, till. particular company need write mdx lists regions, areas , sites (but not levels below site). achieving following mdx hierarchize({ [location].[test company], descendants([location].[test company], [location].[region]), descendants([location].[test company], [location].[area]), descendants([location].[test company], [location].[site]) }) because knowledge of mdx limited, wondering if there simpler way this, single command rather four? there less verbose way of achieveing this, or example real way of achieving this? descendants([location].[test company],[location].[site], self_and_before)

How to upload multiple files to FTP Server without blocking in C#? -

how upload multiple files ftp server without blocking in c# ? dont want block other code snippet highly appreciated. in advance. use threadpool . threadpool.queueuserworkitem(ftpupload, "path/to/file1.txt"); threadpool.queueuserworkitem(ftpupload, "path/to/file2.txt"); threadpool.queueuserworkitem(ftpupload, "path/to/file3.txt"); ... private static void ftpupload(object state) { var filepath = (string)state; ... upload here ... }

c++ - More concise way to write the following statement -

is there more concise way write following c++ statements: int max = 0; int u = up(); if(u > max) { max = u; } int d = down(); if(d > max) { max = d; } int r = right(); max = r > max ? r : max; specifically there way embed assignment of functions return inside if statement/ternary operator? assuming that: the idea remove local variables (i.e. don't need u , d , r later on) evaluation order doesn't matter ... can use std::max : int m = max(max(max(0, up()), down()), right()); if return value of function: return max(max(max(0, up()), down()), right()); note that can evaluate functions in order, rather string up, down, right order in original code.

javascript - What is the best way to add options to a select from as JS object with jQuery? -

what best method adding options select json object using jquery? i'm looking don't need plugin do, interested in plugins out there. this did: selectvalues = { "1": "test 1", "2": "test 2" }; (key in selectvalues) { if (typeof (selectvalues[key] == 'string') { $('#myselect').append('<option value="' + key + '">' + selectvalues[key] + '</option>'); } } a clean/simple solution: this cleaned , simplified version of matdumsa's : $.each(selectvalues, function(key, value) { $('#myselect') .append($('<option>', { value : key }) .text(value)); }); changes matdumsa's: (1) removed close tag option inside append() , (2) moved properties/attributes map second parameter of append(). same other answers, in jquery fashion: $.each(selectvalues, function(key, value) { $('#myselect') ...

Running an exe from windows service that interacts the the user's desktop -

i've created windows service in c# , windows server 2003. service able run exe file windows forms application. when start service - runs other application cannot see it. when open task manager - can see application running cannot see it. have checked "allow service interact desktop" nothing happens. please help. possible run , exe within windows service , see exe running in widnows server 2003? showing ui windows service problematic because service may running on different desktop user (and on vista/server 2008 in fact run on different desktop). the easiest solution run ui not directly service application running on user's desktop (maybe set run @ login) communicate service somehow. just remember: there may no logged in user there may multiple logged in users using fast user switching or remote desktop the application on user desktop running in user's security context, not service's

javascript - How do I check if an element is hidden in jQuery? -

it possible toggle visibility of element, using functions .hide() , .show() or .toggle() . how test if element visible or hidden? since question refers single element, code might more suitable: // checks display:[none|block], ignores visible:[true|false] $(element).is(":visible"); same twernt's suggestion , applied single element; , matches algorithm recommended in jquery faq

Query a list in another list in C# -

i have class that public class tbl { public list<row> rows {get; set;} } public class row { public string name {get; set;} public value {get; set;} } //using class //add rows tbl tbl t = new tbl(); t.rows.add(new row() {name = "row1", value = "row1value"}; t.rows.add(new row() {name = "row2", value = "row2value"}; t.rows.add(new row() {name = "row3", value = "row3value"}; //now want select row2 in list, usually, use way public row getrow(this tbl t, string rowname) { return t.rows.where(x => x.name == rowname).firstordefault(); } row r = t.getrow("row2"); //but use way row r = t.rows["row2"]; how can that. thanks every comments. extension properties not exist, use wrapper around list<row> , add indexer property it. public class rowlist : list<row> { public row this[string key] { { return this.where( x => x.name == key ).firstorde...

language agnostic - Defining a security policy for a system -

most of literature on security talks importance of defining security policy before starting workout on mechanisms , implementation. while seems logical, quite unclear defining security policy means. has here had experience in defining security policy, , if so: 1) outcome of such definition? form of such policy, distributed system, document containing series of statements on security requirements (what allowed , not) of system? 2) can policy take machine readable form (if makes sense) , if how can used? 3) how 1 maintain such policy? policy maintained documentation (as rest of documentation) on system? 4) is necessary make references policy document in code? brian you should take 1 of standard security policies , work there. 1 common pci compliance (payment card industry). it's thought out , except few soft spots, good. i've never heard of machine readable policy except microsoft active directory definition or series of linux iptables rules. https:/...

java - Eclipse reading stdin (System.in) from a file -

Image
is possible eclipse read stdin file? pure java you can redirect system.in single line of code: system.setin(new fileinputstream(filename)); see system.setin() . eclipse config in eclipse 4.5 or later, launch configuration dialog can set system.in read file. see the announcement here .

make default application in android? -

if more 1 application supports open specified file format. need make application default application code.how possible make default code?? can me? on regular phone user get's choice between alternatives, while on newer os (not sure if started 2.1 or earlier) versions, can check 'use default' can done user himself. cannot code-wise.

Is there a simple way to convert C++ enum to string? -

suppose have named enums: enum myenum { foo, bar = 0x50 }; what googled script (any language) scans headers in project , generates header 1 function per enum. char* enum_to_string(myenum t); and implementation this: char* enum_to_string(myenum t){ switch(t){ case foo: return "foo"; case bar: return "bar"; default: return "invalid enum"; } } the gotcha typedefed enums, , unnamed c style enums. know this? edit: solution should not modify source, except generated functions. enums in api, using solutions proposed until not option. you may want check out gccxml . running gccxml on sample code produces: <gcc_xml> <namespace id="_1" name="::" members="_3 " mangled="_z2::"/> <namespace id="_2" name="std" context="_1" members="" mangled="_z3std...

How to use sftp from within an MS Access database module? -

i have requirement create simple database in access collect user data loaded database further reporting. there module in access db when invoked user (probably clicking button) output query delimited file. user needs mechanism (for example form button) transfer file remote server, using sftp. have idea of how accomplish this? you can write call sftp command line client via batch file if want accomplish that. check out shell() function in vba. under click event of button on form add in code: mysftpcall = "sftp <insert options here!>" call shell(mysftpcall, 1) i've used before copy files straight across network shares etc. share data in-house access db. of course more fancy if necessary.

jquery - How do I format a Microsoft JSON date? -

i'm taking first crack @ ajax jquery. i'm getting data onto page, i'm having trouble json data returned date data types. basically, i'm getting string looks this: /date(1224043200000)/ from totally new json - how format short date format? should handled somewhere in jquery code? i've tried jquery.ui.datepicker plugin using $.datepicker.formatdate() without success. fyi: here's solution came using combination of answers here: function getmismatch(id) { $.getjson("main.aspx?callback=getmismatch", { mismatchid: id }, function (result) { $("#authmerchid").text(result.authorizationmerchantid); $("#sttlmerchid").text(result.settlementmerchantid); $("#createdate").text(formatjsondate(date(result.appenddts))); $("#expiredate").text(formatjsondate(date(result.expiresdts))); $("#lastupdate").text(formatjsondate(date(result.lastupdatedts))); $("#la...

How to modify silverlight combobox data display -

i have combobox defined follows: <combobox x:name="cbodept" grid.row="0" margin="8,8,8,8" horizontalalignment="left" verticalalignment="top" width="120" itemssource="{binding source={staticresource cvscategories}}"> <combobox.itemtemplate> <datatemplate> <stackpanel orientation="vertical" width="auto" height="auto"> <sdk:label content="{binding categoryid}" height="20" /> <sdk:label content="{binding categoryname}" height="20" /> </stackpanel> </datatemplate> </combobox.itemtemplate> </combobox> it works fine. however, once select item in list, want different template applied combobox selected item being shown us...

shell - Hidden features of Bash -

shell scripts used glue, automation , simple one-off tasks. of favorite "hidden" features of bash shell/scripting language? one feature per answer give example , short description of feature, not link documentation label feature using bold title first line see also: hidden features of c hidden features of c# hidden features of c++ hidden features of delphi hidden features of python hidden features of java hidden features of javascript hidden features of ruby hidden features of php hidden features of perl hidden features of vb.net insert preceding line's final parameter alt - . useful key combination ever, try , see, reason no 1 knows one. press again , again select older last parameters. great when want else used moment ago.

Will Google Android ever support .NET? -

now g1 google's android os available (soon), android platform ever support .net? update : since wrote answer 2 years ago, productized mono run on android. work included few steps: porting mono android, integrating visual studio, building plugins monodevelop on mac , windows , exposing java android apis .net languages. available @ http://monodroid.net getting started: http://monodroid.net/welcome documentation: http://monodroid.net/documentation tutorials: http://monodroid.net/tutorials mono on android based on mono 2.10 runtime, , defaults 4.0 profile c# 4.0 compiler , uses mono's new sgen garbage collection engine, our new distributed garbage collection system performs gc across java , mono. the links below reflect mono on android of january of 2009, have kept them historical context mono works on android work of koushik dutta , marc crichton. you can see video of running here: http://www.koushikdutta.com/2009/01/mono-on-android-with-gratuitous...

assemblybinding - ASP.NET MVC 2: Why does my app reference both versions (1 and 2)? -

i opened dll asp.net mvc 2 project of mine in reflector, , noticed there 2 references system.web.mvc - 1 version 1.0.0.0, , 1 2.0.0.0. don't seem references v1 anywhere in csproj file, nor in web.config file, when try run app error could not load file or assembly 'system.web.mvc, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. where dependency on v1 coming from? you have indirect reference v1 through different assembly.

c# - How do I format to only include decimal if there are any -

what best way format decimal if want decimal displayed if not integer. eg: decimal amount = 1000m decimal vat = 12.50m when formatted want: amount: 1000 (not 1000.0000) vat: 12.5 (not 12.50) decimal 1 = 1000m; decimal 2 = 12.5m; console.writeline(one.tostring("0.##")); console.writeline(two.tostring("0.##"));

java - EJB 3.1 application deployed as WAR-only: What about ejb-jar.xml? -

i have javaee6 application, consisting of web stuff , ejbs , deployed war-only (using ejb3.1). build based on maven. read new possibility order module initialization in java ee 6 here need application. also, have option define ejb properties in xml. since example deployed ear-project order defined in application.xml. in war-deployed project, there no application.xml. wonder can define such informations? or possible use application.xml somehow in war-deployed-app? edit: oops didn't read module-order-example right, in first moment thought in order ejbs in app loaded. of course have 1 module in war-app, ordering makes no sense. ok, i'm @ it, 1 big question remains (also altered question title reflect change): ejb-jar.xml? can somehow define stuff ejbs in xml (as useful settings, avoid recompilation)? in short, not possible war based deployment. the module initialization feature of java ee 6 meant initializing different modules of application in specific or...

javascript - jQuery dragging (reordering) table rows between multiple tbodies -

i'm great css largely suck @ jquery. have our limitations... ok admission out of way i'll begin. have "favourite products" table, can sectionalize categories (eg, booze, sheep, spoons). each category . each row (excluding ) product. i want enable user drag , drop (reorder) table rows, between tbodies. i've looked @ table drag , drop (dnd) plugin jquery disappointed find doesn't support dragging between tbodies - , hasn't been updated quite time. here basic table structure: <table> <thead> <tr> <th>favourite</th> </tr> </thead> <tbody> <tr> <th>spoons</th> <!-- secion title, not draggable --> </tr> <tr> <td>wooden spoon</td> </tr> <tr> <td>metal spoon</td> </tr> <tr> <td>plastic spoon</td> </tr> </tbody> <tbod...

dojo.hitch scope issue in onsubmit dojo/method -

i have onsubmit dojo/method within custom templated widget so: try { if (this.validate()) { //console.debug(this); submitform(dojo.hitch(this, this.send)); } } catch (e) { console.debug(e); } return false; when call this, scope within dojo/method dijit.form. how go getting scope of template widget instead? i solved doing this: dojo.connect(dojo.byid(this.form.id), "onsubmit", dojo.hitch(this, function(e) { e.preventdefault(); if (this.getform().validate()) { submitform(dojo.hitch(this, this.send)); } }) );

Using JavaScript with JSF and Facelets -

i use javascript manipulate hidden input fields in jsf/facelets page. when page loads, need set hidden field color depth of client. from facelet: <body onload="setcolordepth(document.getelementbyid(?????);"> <h:form> <h:inputhidden value="#{login.colordepth}" id="colordepth" /> </h:form> when jsf processes page, of course changing ids of elements. what's best way reference these elements javascript code? you'll want set id of form you'll know is. you'll able construct actual element id. <body onload="setcolordepth(document.getelementbyid('myform:colordepth');"> <h:form id="myform"> <h:inputhidden value="#{login.colordepth}" id="colordepth" /> </h:form> if don't want set form's id field, find @ runtime, so: <body onload="setcolordepth(document.getelementbyid(document.forms[0].id + ':colordepth...

agile - Where to find the best user story template? -

i want implement user stories in new project can find template or other ones used in agile development? see 9 boxes technique elaborate user stories. it's not template per se, leads filling " as user, want ... ... " template, efficient. mike cohn explaining better would . it allows discover non-functional requirements (the ilities ). edit: original link nine-boxes page cybersquatted page available on internet archive .

database - How to check/update a row of values based on a single column header?(Access) -

i have database many tables. in first table, have field called status . table 1 idno name status 111 hjghf yes 225 hjgjj no 345 hgj yes other tables have same idno different fields. i want check status each id no , if yes id number in tables null , blank fields want update them 111111. i looking sample vba code can adapt. thanks here largely untested code. give start. sub updatenulls() dim strsql string dim rs dao.recordset each tdf in currentdb.tabledefs if left(tdf.name, 4) <> "msys" , tdf.name <> "table1" strsql = "select * [" & tdf.name & "] inner join " _ & "table1 on a.idno = table1.idno table1.status = 'yes'" set rs = currentdb.openrecordset(strsql) while not rs.eof = 0 rs.fields.count - 1 if isnull(rs.fields(i)) rs.edit rs.fields(i) = 111111 ...

dynamics crm - Creating or Updating Custom Entites in MS CRM 4.0 -

for requirement asked export information custom entity created in ms crm 4.0. trying programmatically , have not found single code accomplishes this. wrote code check if value field exists in entity creating new entity seems little bit of puzzle me. on appreciated. to create custom entity code, need use metadataservice web service. 'createentity' method used create custom entities. the crm sdk v4.0 shows how: createentity message (metadataservice)

c++ - How do I test at compile time the current version of GCC? -

i include different file depending on version of gcc. more precisely want write: #if gcc_version >= 4.2 # include <unordered_map> # define ext std #elif gcc_version >= 4 # include <tr1/unordered_map> # define ext std #else # include <ext/hash_map> # define unordered_map __gnu_cxx::hash_map # define ext __gnu_cxx #endif i don't care gcc before 3.2. note: pretty sure there variable defined @ preprocessing time that, can't find again. there number of macros should defined needs: __gnuc__ // major __gnuc_minor__ // minor __gnuc_patchlevel__ // patch the version format major.minor.patch, e.g. 4.0.2 the documentation these can found here .