Posts

Showing posts from March, 2010

c# - Building a report from a runtime generated datatable -

i have datatable data have read csv file (you helped me yesterday that, thanks). now, want show report columns of datatable. it easier if see fields , select them report designer: i'd have drag them columns. problem datatable generated in runtime, can't use designer. how that? how make report data generated in runtime, , visualize in reportviewer? thanks in advance!

vb.net - UnhandledException handler in a .Net Windows Service -

is possible use unhandledexception handler in windows service? normally use custom built exception handling component logging, phone home, etc. component adds handler system.appdomain.currentdomain.unhandledexception far can tell doesn’t achieve win windows service end pattern in 2 (or 4) service entry points: protected overrides sub onstart(byval args() string) ' add code here start service. method should set things ' in motion service can work. try myservicecomponent.start() catch ex exception 'call our exception handler myexceptionhandlingcomponent.manuallyhandleexception (ex) 'zero default exitcode successfull exit, if set non-zero exitcode = -1 'so, use environment.exit, seems appropriate thing use 'we pass exit code here well, in case. system.environment.exit(-1) end try end sub is there way custom exc...

.net - Combining Enums -

is there way combine enums in vb.net? i believe want flag type enum. you need add flags attribute top of enum, , can combine enums 'or' keyword. like this: <flags()> _ enum combinationenums integer hasbutton = 1 titlebar = 2 readonly = 4 etc = 8 end enum note: numbers right twice big (powers of 2) - needed able separate individual flags have been set. combine desired flags using or keyword: dim settings combinationenums settings = combinationenums.titlebar or combinationenums.readonly this sets titlebar , readonly enum to check what's been set: if (settings , combinationenums.titlebar) = combinationenums.titlebar window.titlebar = true end if

java - Are there any code analysis tools that will make my job easier? -

i have inherited program written in managed c++ guy retired. after spending time digging through it, can @ least 95% of belongs on thedailywtf . however, tasked modifying , porting on language i'm comfortable with. the program takes in many many parameters (50+) read in file , performs series of calculations , spits out report. once i'm done plowing way through pages of 3 letter variables (many of them reused totally unrelated purposes), need come way test code make sure comes same answers previous code. this wishful thinking, there automated code analysis tools out there can aid me in task in way or form? i porting on java. i need come way test code make sure comes same answers previous code. unit testing since mentioned program takes parameters in file , outputs report, generate few inputs give sufficient coverage portions want unit test against output old code. if breaks don't forget there chance have discovered bug in old code. htt...

vb.net - how to start new thread as soon as previously thread gets finished? -

i have develop windows service copy files different servers. have task using multi-theading. have start 3-4 threads. whenever 1 threads finished have start new thread count of thread should remain 3 or 4. how apply check on ? please provide information on it. this might give starting point. idea use blocking queue block on dequeue operation until item available. worker threads spin around infinite loop waiting items appear in queue. main thread enqueue items queue. following example uses blockingcollection class .net 4.0 bcl. if not available can implementation of blocking queue stephen toub's blog . module example private m_queue blockingcollection(of string) = new blockingcollection(of string) sub main() dim threads(4) thread integer = 0 threads.length - 1 threads(i) = new thread(addressof consumer) threads(i).isbackground = true threads(i).start() next dim files ienumerable(of string)...

Can I perform database specific operation using android.preference package? -

i need database in can store data , data whenever need. possible android.preference package. not want use sqlite database regards according shared preferences | android developer tutorial (part 13) sai geetha m n, many applications may provide way capture user preferences on settings of specific application or activity. supporting this, android provides simple set of apis. preferences typically name value pairs. can stored “shared preferences” across various activities in application (note cannot shared across processes). or can needs stored specific activity. shared preferences: shared preferences can used components (activities, services etc) off applications. activity handled preferences: these preferences can used in activity , can not used other components of application. shared preferences: the shared preferences managed of getsharedpreferences method of context class. preferences stored in default file(1) or can specify file name...

firefox - How can I specify a browser that GWT tests should be run on? -

i writing gwt project uses html5 canvas. to test application use gwttestcase. for firefox functions supported since gecko 1.9. while testing, firefox 3.0.1 being used , errors occur. how can set gwt tests launched on firefox 3.6? (in eclipse using gwt plugin or using build.xml ant) measuretext wasn't there until gecko 1.9.1. the workaround run tests runstyle=manual:1 gives me link can paste browser want tests run in. -dgwt.args="-runstyle manual:1"

.net - How Do I Load an Assembly and All of its Dependencies at Runtime in C# for Reflection? -

i'm writing utility myself, partly exercise in learning c# reflection , partly because want resulting tool own use. what i'm after pointing application @ assembly , choosing given class select properties should included in exported html form fields. form used in asp.net mvc app beginning of view. as i'm using subsonic objects applications want use, should reasonable , figured that, wanting include things differing output html depending on data type, reflection way done. what i'm looking for, however, seems elusive. i'm trying take dll/exe that's chosen through openfiledialog starting point , load it: string filepath = path.getdirectoryname(filename); system.reflection.assembly o = system.reflection.assembly.loadfile(filename); that works fine, because subsonic-generated objects full of object types defined in subsonic.dll, etc., dependent objects aren't loaded. enter: assemblyname[] referencedassemblies = o.getreferencedassemblies(); that, ...

c# - How can i get NON contains data from list? -

i have "contains" method need "not contains" method. suggestions? var resultsofmpd = (from m in engmpdmultiselect engmpdmultiitems.select(o => o.eng_mpd_mytechnic_task_no). contains(m.eng_mpd_mytechnic_task_no) select m); is there method that? var resultsofmpd = (from m in engmpdmultiselect engmpdmultiitems.select(o => o.eng_mpd_mytechnic_task_no). notcontains(m.eng_mpd_mytechnic_task_no) select m); use ! operator, this: var resultsofmpd = m in engmpdmultiselect !engmpdmultiitems.select(o => o.eng_mpd_mytechnic_task_no). contains(m.eng_mpd_mytechnic_task_no) select m; by way, don't need select() call. instead, can write var resultsofmpd = m in engmpdmultiselect !engmpdmultiitems.any(o => o.eng_mpd_mytechnic_task_no == m.eng_mpd_my...

jsp - Reloading JSTL Tag files in Tomcat development mode -

the application inherited defines .tag files - ie jstl tags written in jsp , other jstl tags. possible tomcat pick on changes .tag files , recompile/reload them without restart, in same manner of "development" mode jsps? edit should have noted context marked "reloadable" in tomcat, , i'm hot-deploying class files , jsps. it's not picking on .tag files. "development" mode jsps applies tag files ... unless tag files being packaged in jar file (e.g. in /meta-inf/tags/ of jar file in /web-inf/lib ). if tag files being deployed jsps (e.g. in /web-inf/tags/ ) checked modification , reloaded on each access if "development" mode true . shouldn't have set explicitly it's true default in tomcat 5.5/6. if check $catalina_base/conf/web.xml , "development" isn't explicitly set false you're still getting issues reload of .tag files (assuming these aren't jar-packaged) try turning off tag pools (for...

python - How complicate can a Django application go? -

i'm tasked create simple crud mvc application, , thought it's opportunity learn python. because of great documentation, i'm thinking i'll go django. now, simple crud mvc application become quite complicated in future. might have receive , issue jms messages, display charts updated periodically (i'm thinking ajax) , not. given i'm little worried, since while i'm told it's easy call java code python (i'm java developer), i'm told django best content based web application, , can restrictive. do think okay go django in case? simple crud mvc application django "out of box" admin interface simple, crud, mvc application. don't programming make happen. create model. that's it. use django admin crud application. done. i might have receive , issue jms messages, display charts updated periodically (i'm thinking ajax) , not. that's point. since didn't waste time writing crud application...

html - In PHP is it possible to use a function inside a variable -

i know in php can embed variables inside variables, like: <? $var1 = "i\'m including {$var2} in variable.."; ?> but wondering how, , if possible include function inside variable. know write: <?php $var1 = "i\'m including "; $var1 .= somefunc(); $var1 = " in variable.."; ?> but if have long variable output, , don't want every time, or want use multiple functions: <?php $var1 = <<<eof <html lang="en"> <head> <title>aaahhhhh</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head> <body> there <b>alot</b> of text , html here... want <i>functions</i>! -somefunc() doesn't work -{somefunc()} doesn't work -$somefunc() , {$somefunc()} doesn't work of course because function needs strin...

php - In PHP5, should I use Exceptions or trigger_error/set_error_handler? -

what pros/cons of doing either way. there 1 right way(tm) ? if want use exceptions instead of errors entire application, can errorexception , custom error handler (see errorexception page sample error handler). downside method non-fatal errors still throw exceptions, fatal unless caught. basically, e_notice halt entire application if error_reporting settings not suppress them. in opinion, there several benefits using errorexception: a custom exception handler let display nice messages, errors, using set_exception_handler . it not disrupt existing code in way... trigger_error , other error functions still work normally. it makes hard ignore stupid coding mistakes trigger e_notice s , e_warning s. you can use try / catch wrap code may generate php error (not exceptions), nice way avoid using @ error suppression hack: try { $foo = $_get['foo']; } catch (errorexception $e) { $foo = null; } you can wrap entire script in single try / catch bloc...

Python import inconsistent behavior -

i have py file this, errors out. from world import acme def make_stuff_happen(): acme.account.foo() # works acme.subscription.bar() # fail: "module 'object' has no attribute 'subscription'" make_stuff_happen() but works! from world import acme world.acme import subscription def make_stuff_happen(): acme.account.foo() # works subscription.bar() # works. make_stuff_happen() all can wtf, causing this? behavior should @ least consistent both acme.account , acme.subscription . thanks! update- folder structure of acme folder: acme |-- __init__.py |-- account.py |-- catalog.py |-- core.py |-- proxy.py |-- subscription.py `-- utils.py and __init__.py blank. submodules referenced in __init__.py file in module folder. appears subscription not referenced in acme 's __init__.py . however, when import world.acme.subscription , knows go digging in folder without talking __init__.py . according descriptio...

javascript - How to fix position an element but keep the height relative to browser window? -

you noticed web sites have feedback feature created http://uservoice.com . display's badge on left or right of screen. but, how badge positioned? looks position depends on height of browser.... can me how create sort of badge this, functionality redirect me other url? tnx in adv! it uses position: fixed on a tag. using top: 45% "move" window height.

ruby on rails - Why would Paperclip be failing to find the geometry key when on my server? -

i'm getting error in thumbnail.rb saying :geometry empty here's condensed version of stack: nomethoderror in pagescontroller#create undefined method `[]' nil:nilclass rails_root: ... application trace | framework trace | full trace .../vendor/plugins/paperclip/lib/paperclip/thumbnail.rb:18:in `initialize' .../vendor/plugins/paperclip/lib/paperclip/processor.rb:33:in `new' .../vendor/plugins/paperclip/lib/paperclip/processor.rb:33:in `make' .../vendor/plugins/paperclip/lib/paperclip/attachment.rb:295:in `post_process_styles' .../usr/lib/ruby/1.8/erb.rb:719:in `inject' .... the thing find rather weird works fine on local machine, , not sporadically on server. my has_attached_file looks so: has_attached_file :foreground, :storage => :s3, :s3_credentials => "#{rails_root}/config/amazon_s3.yml", :bucket => 'recurse', :path => "...

How to work around a very large 2d array in C++ -

i need create 2d int array of size 800x800. doing creates stack overflow (ha ha). i'm new c++, should vector of vectors? , encapsulate 2d array class? specifically, array zbuffer in graphics program. need store z value every pixel on screen (hence large size of 800x800). thanks! you need 2.5 megs, using heap should fine. don't need vector unless need resize it. see c++ faq lite example of using "2d" heap array. int *array = new int[800*800]; (don't forget delete[] when you're done.)

telephony - What is the best way to get started using Asterisk? -

i'm interested in learning more asterisk (open source pbx) thought try building "hobby" system home. play around getting juiced voicemail system going family. is, until found out tdm11b kit digium costs on $500(!) if want fxo/fxs card echo cancellation. my question(s) are: what's best way go learning asterisk? moreover, if want souped version of voicemail going @ home there way can without having buy expensive card hook pstn? thanks, john you shouldn't need card hardware echo cancellation - home use should able standard tdm11b approx £115 , use software echo cancellation. alternatively can similar 'copycat' products cheaply off ebay or standard online stores ( openvox 1 of these). another way go separate adapter such spa-3000 1 fxs & 1 fxo. probably advice ditch tdm altogether though , sip account provider of choice, , either pure sip phone or adapter such linksys pap2 if you're interested in learning asterisk i'...

dynamic html watcher -

hi want create program can read url , when conditions met, me, sort of bot. how read html of webpage , how can tell me. there programs out there? selenium i assume want write integration tests.

How to save jpg image to database and then load it in Delphi using FIBplus and TImage? -

how save jpg image database , load in delphi using fibplus , timage? var s : tmemorystream; begin s := tmemorystream.create; try tblobfield(adoquery1.fieldbyname('imagefield')).savetostream(s); s.position := 0; image1.picture.graphic.loadfromstream(s); s.free; end; end; if using jpeg images, add jpg unit uses clause of unit file.

iphone - why and where to use a delegate in objective c -

i’m new iphone programmer i have created small views without delegates.... if program can run without delegate, why use them. need them, have seen programs on net having delegates. i’m confused, please answer. delegates pattern allows object notify object when stuff happens. lots of delegate methods start "will" or "did" called before , after event occurs, respectively. let's have uitableview , , want know when user taps cell can process choice. assign delegate table view implements delegate method tableview:didselectrowatindexpath: . the nice things approach table view doesn't have know or care other delegate object or how works. allows object generating events stay focused , clean, dealing it's own state. when noteworthy, send message it's delegate. , delegate object doesn't need know internal state of other object @ all. needs know did important. and fits model/view/controller (mvc) approach of iphone sdk well. v...

Get mac address for remote computer under NT4 in C -

is possible determine mac address of originator of remote connection under windows nt 4? remote pc opens socket connection application , can ip address. need determine mac address information available socket such ip address of remote device. i have tried using sendarp doesn't seem supported in windows nt4. try getipnettable. function documented supported of nt 4.0 sp4.

iphone - Why is my multi-component UIPickerView crashing? -

i'm trying create simple pickerview 2 components, drawing label data small mutablearray , output data simple matrix. purpose of wheel select value 0 1000, , spit out number in label , value rest of application's functions. some specific info i'm doing: (skip down last paragraph problem) the left wheel spins "hundred's" column, , right wheel spins "ten's" column, you're creating 1 value 2 wheels. want let user create value of 0, 10, 20, 30... 990, 1000 (every ten units 1000).the first component easy label, have 2 arrays populate second component's row's labels. first array second component creates 00 - 90 label, second array (for when 1000 selected) has 00 value. when user wants select 1000, 10 on first wheel , 00 on second. change row count second wheel component when first wheel component @ row 10. second component shows "00". didselectrow method uses matrix values of 0 - 990 , works great. , make string , convert n...

How do I use calculated value date in Sharepoint lists field to find a date+30 days? -

i have list i've built in sharepoint, 1 of fields date user enters. want add field, calculated value field needs date provided user + 30 days. formula need pass calculated value field achieve that? try this: create new calculated column in forumla box, enter this: =text([existing date column]+30,"yyyy-mm-dd") can use date format string instead of "yyyy-mm-dd" make data type "date , time" make date , time format "date only"

save php variables permanently without database -

in admin area of site there form hostname, username , password mysql database site uses. these values hardcoded php class. can link form can edit variables in php class (and keep results on server, in other words variables hardcoded). i'd keep things in database can't done. keep values in config file. , make sure not accessible web. the easiest solution keep values in configuration array - user enters values, generate array it, file_put_contents("config.php", "<?php $config = " . var_export($config)) . method whenever need config array, need include config.php , it's there. this untested code, example purposes only. depending on situation, may need solve race conditions, file_put_contents not enought that. main point of above code is: var_export returns valid php code, can eval (if you're evil enough) or echo file , include later.

vtk java voxel rendering -

hi guys, does knows, why code in java compiles, error appears: "an unrecoverable stack overflow has occurred. # # fatal error has been detected java runtime environment: # # exception_stack_overflow (0xc00000fd) @ pc=0x5d05b377, pid=4576, tid=4888 # # jre version: 6.0_20-b02 # java vm: java hotspot(tm) client vm (16.3-b01 mixed mode windows-x86 ) # problematic frame: # c [vtkvolumerendering.dll+0x2eb377] # # error report file more information saved as: # d:\programme\eclipse-workspace\bachelorarbeit_01\hs_err_pid4576.log # # if submit bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # crash happened outside java virtual machine in native code. # see problematic frame report bug." here java source code copied c++ code here: http://permalink.gmane.org/gmane.comp.lib.vtk.user/35844 import vtk.vtkimagedata; import vtk.vtkunstructuredgrid; import vtk.vtkpolydatamapper; import vtk.vtkactor; import vtk.vtkrenderwindow; import vtk.vtkrender...

jsp - Calculate total sum of all numbers in c:forEach loop -

i have java bean this: class person { int age; string name; } i'd iterate on collection of these beans in jsp, showing each person in html table row, , in last row of table i'd show total of ages. the code generate table rows this: <c:foreach var="person" items="${personlist}"> <tr><td>${person.name}<td><td>${person.age}</td></tr> </c:foreach> however, i'm struggling find way calculate age total shown in final row without resorting scriptlet code , suggestions? note: tried combining answers make comprehensive list. mentioned names appropriate give credit due. there many ways solve problem, pros/cons associated each: pure jsp solution as scarcher2 mentioned above, easy , simple solution problem implement directly in jsp so: <c:set var="agetotal" value="${0}" /> <c:foreach var="person" items="${personlist}"> <c:set...

javascript - PHP/JS - Create thumbnails on the fly or store as files -

for image hosting web application: for stored images, feasible create thumbnails on fly using php (or whatever), or should save 1 or more different sized thumbnails disk , load those? any appreciated. save thumbnails disk. image processing takes lot of resources and, depending on size of image, might exceed default allowed memory limit php. less of concern if have own server application running still takes lot of cpu power , memory resize images. if you're considering creating thumbnails on fly anyway, don't have change - upon first request, create thumbnail source file, save disk , upon subsequent requests read off disk.

How to use the explode function in PHP using 2 delimeters instead of 1? -

suppose have following: $string = "(a) (b) (c)"; how explode contents inside parenthesis. if string's contents separated 1 symbol instead of 2 have used: $string = "a-b-c"; explode("-", $string); but how when 2 delimiters used encapsulate items exploded? you have use preg_split or preg_match instead. example: $string = "(a) (b) (c)"; print_r(preg_split('/\\) \\(|\\(|\\)/', $string, -1, preg_split_no_empty)); array ( [0] => [1] => b [2] => c ) notice order important.

Retrieve data Mysql / Php where date -

hey, i'm wondering how retrieve data database using php top songs today. right i'm getting top songs using $result = mysql_query("select tag, count(*) the_tags tags group tag order the_tags desc limit 16"); i storing date in tags table aswell, in format 07-25-2010 so month - day - year how can have limit results tags date of today? thanks :) another way it: "select tag, count(*) the_tags tags `date` = '" . date('m-d-y') . "' group tag order the_tags desc limit 16" but prefer use mysql's date (so see artefacto's post)

c# - File-size format provider -

is there easy way create class uses iformatprovider writes out user-friendly file-size? public static string getfilesizestring(string filepath) { fileinfo info = new fileinfo(@"c:\windows\notepad.exe"); long size = info.length; string sizestring = size.tostring(filesizeformatprovider); // class magic... } it should result in strings formatted " 2,5 mb ", " 3,9 gb ", " 670 bytes " , on. i use one, web public class filesizeformatprovider : iformatprovider, icustomformatter { public object getformat(type formattype) { if (formattype == typeof(icustomformatter)) return this; return null; } private const string filesizeformat = "fs"; private const decimal onekilobyte = 1024m; private const decimal onemegabyte = onekilobyte * 1024m; private const decimal onegigabyte = onemegabyte * 1024m; public string format(string format, object arg, iformatprovider formatprov...

What is your favourite MATLAB/Octave programming trick? -

i think agree matlab language not pretty, or particularly consistent. nevermind! still have use things done. what favourite tricks making things easier? let's have 1 per answer people can vote them if agree. also, try illustrate answer example. using built-in profiler see hot parts of code are: profile on % lines of code profile off profile viewer or using built in tic , toc quick timings: tic; % lines of code toc;

excel lookup returning reference -

excel has "lookup" function finds specified value in row or column , returns corresponding value column. but there lookup returns reference of found cell? have case have column of dates, , want search list given date , return reference -- a23 or whatever -- of cell. i believe you're looking find method in vba? .find(what, after, lookin, lookat, searchorder, searchdirection, matchcase, matchbyte, searchformat) http://msdn.microsoft.com/en-us/library/aa195730(office.11).aspx

c++ - Customize the buttons in a QWIzard? -

qwizard have options related buttons follows: nodefaultbutton nobackbuttononstartpage nobackbuttononlastpage disabledbackbuttononlastpage havenextbuttononlastpage havefinishbuttononearlypages nocancelbutton cancelbuttononleft havehelpbutton helpbuttononright now these options not enough me, there way customization?? for example, after setting qwizardpage final page, "next" button still there since page have next page. what want change "next" "finish" instead of 1 more "finish" button. another example @ first page, want "back" button shows disabled. how can control these buttons in more flexible way? want make buttons disappear , disabled. if call follwing function: qabstractbutton * qwizard::button ( wizardbutton ) const with following argument: qwizard::nextbutton then should pointer "next" button. the thing left call setvisible(bool) function of butt...

windows - Programmatically change keyboard to Dvorak -

does know api call can use change keyboard layout on windows machine dvorak? doing through ui easy i'd have script can run on new vm's automate process. i may 4 years late party, did ever find this: intlcfg command-line options i don't have windows vista (very bad habit, windows), looking @ page , @ available language packs , default input locales reckon command want might be: intlcfg.exe -inputlocale:0409:00010409 for english (united states) language united states dvorak input locale.

C# code from desktop to the web -

if develop desktop app using c#, , later want turn webapp don't want use asp.net, options? i did bit of searching , looks there doesn't appear solution integrate c# code scripting language other running web service , making soap calls. any other ideas? why make things difficult yourself? best thing put of code assembly, , use winforms app display purposes. then, later, can reimplement display logic in asp.net. so, guess answer no.

vba - Can Generic Type Mapper (MSSOAP toolkit) be persuaded to handle empty arrays -

i'm having problem described here: http://groups.google.com/group/microsoft.public.xml.soap/browse_thread/thread/029ee5b5d4fa2440/0895d73c5c3720a1 i consuming web service using office 2003 web services toolkit . generates classes data returned web service: 1 of classes has property array may empty. when call web service, generic type mapper raises error: array dimensions not match definition does know of solution problem allows me keep using generated classes (i know consume raw xml)? since there no takers, i'll describe i've done date in case else has similar issue. on client (using office 2003 web services toolkit) want receive collection of objects have property collection of objects. example, collection of customer objects c# web service customer class looks like: public class customer { public string name { get; set; } public collection<address> addresses { get; } } the problem have addresses property can empty collection,...

iis - .NET web application automatic update pull-style -

i have several .net web applications use same cms-like framework. when add new feature core framework want each application updated feature. need following steps: put app_offline.htm in application root copy files have changed update server run sql update scripts if needed remove app_offline.htm i read cruisecontrol , other continuous integration tools, have features similar need. problem use push-style update integration server builds source , copies files production servers. can't use approach because clients can't give me access production servers. need have "update" button in iis manager or anywhere else client can click , pulls data update server. knows if there solution achieve this? thanks the approach took create script pulls latest deployment version git, stops iis, copies new version over, starts iis. crude if thing in git repository latest deployable version work. i setup publish button in visual studio copy local git deployment...

windows mobile - using SqlCEResultSet.Seek with composite keys in SQL Server CE -

can show me how can use sqlceresultset.seek method composite index? i trying seek on orderno+product code . my sql server ce table has following index: create index orderline_idx on orderlines (orderno, item) my seek code is public bool seekdeliveryline(string delnote,string item) { bool isfound = false; cmd = new sqlcecommand(); cmd.connection = conn; cmd.commandtype = commandtype.tabledirect; cmd.commandtext = "orderlines"; cmd.indexname = "orderline_idx "; try { //cmd.setrange(dbrangeoptions.match, new object[] { delnote }, null); deliveryrs = cmd.executeresultset(resultsetoptions.scrollable | resultsetoptions.updatable); isfound = deliveryrs.seek(dbseekoptions.firstequal, new object[] { delnote, item }); if (isfound) { deliveryrs.read(); currentrowdata = this.retrieverecord(); } ...

c# - Can I specify a generic type in XAML (pre .NET 4 Framework)? -

in xaml can declare datatemplate template used whenever specific type displayed. example, datatemplate use textblock display name of customer: <datatemplate datatype="{x:type my:customer}"> <textblock text="{binding name}" /> </datatemplate> i'm wondering if it's possible define datatemplate used time ilist<customer> displayed. if contentcontrol's content is, say, observablecollection<customer> use template. is possible declare generic type ilist in xaml using {x:type} markup extension? not out of box, no; there enterprising developers out there have done so. mike hillberg @ microsoft played in this post , example. google has others of course.

c# - Get the index of the nth occurrence of a string? -

unless missing obvious built-in method, quickest way n th occurrence of string within string? i realize loop indexof method updating start index on each iteration of loop. doing way seems wasteful me. that's need - or @ least, it's easiest solution. you'd "wasting" cost of n method invocations - won't checking case twice, if think it. (indexof return finds match, , you'll keep going left off.)

security - Could I make dynamic render rely User Permissions in MVC 2? -

i make security system in mvc application. in mvc must done authorizeattribute , roles string via actions methods. could make stuff: instead of action resolve want make view html parts hidden depend on current user permission set (for example: save button not visible if user not administrator). within views, can conditional checks, such as: <% if (user.isinrole("admin")) { %> <a href="#">an admin-only link</a> <% } %> in partial views, user property not exposed, can still it: <% var user = httpcontext.current.user; %> <% if (user.isinrole("admin")) { %> <a href="#">an admin-only link</a> <% } %>

java - Skip creating file in FileOutputStream when there is no data in Inputstream -

this logging function logs error stream execution of external program. works fine. not want generate log file when there no data in error stream. creating 0 size file. please help. fileoutputstream fos = new fileoutputstream(logfile); printwriter pw = new printwriter(fos); process proc = runtime.getruntime().exec(externalprogram); inputstreamreader isr = new inputstreamreader(proc.geterrorstream()); bufferedreader br = new bufferedreader(isr); string line=null; while ( (line = br.readline()) != null) { if (pw != null){ pw.println(line); pw.flush(); } } thank you. simply defer creating of fileoutputstream , printwriter until need it: printwriter pw = null; process proc = runtime.getruntime().exec(externalprogram); inputstreamreader isr = new inputstreamreader(proc.geterrorstream()); bufferedreader br = new bufferedreader(isr); string line; while ( (line = br.readline()) != null) { if (pw == null) { pw = new printwriter(new fileoutp...

javascript - jQuery Ajax call No element found issue -

i getting javascript error on firefox 3.5, when trying call ajax method. please find error below: xml parsing error: no element found location: moz-nullprincipal:{1a2c8133-f48f-4707-90f3-1a2b2f2d62e2} line number 1, column 1: ^ this javascript function: function update(id) { $.ajax({ type: "get", url: root_url + "/sevice/udates.svc/update?id=" + id, success: function(response) { }, async: false }); } the ajax call expects xml ( perhaps due bad guessing ) , tries parse , fails if nothing returned or not valid xml.. use datatype option specify format of response. from comments looks browsers cannot handle no-content response. so, workaround such cases might return service ( even single space ).

How do you control architecture in an agile project? -

how ensure project build "good" design decisions enabling flexible software architecture? how balance between leaving architecture teams on 1 side, , let architecture control few individuals on other side? do have "architecture group", "architecture label" or things that? a prerequisite agile approaches architecture know how use. if architecture not well-defined , understood, can't take agile approach. you need have technical spikes show how architecture works, , how various pieces fit together. can these preliminary sprints, won't lead directly release users. they're special case, required architecture can use. once you're past "understand architecture" effort, can start execute sprints lead directly releases users.

android ndk - compiling a driver -

i require convert linux driver android. can me kernel twiking ? there change driver makefile ? source files of kernel ? can use insmod/mknod in adb shell load driver dynamically ? any hint welcomed... noam lots of questions... yes, need change makefiles in kernel. example, if driver source in drivers/net, you'll need change makefile there builds sources. you need add new configuration option in kconfig file build process knows if needs build sources, if needs built module, etc. you'll need run 'make oldconfig' or similar include new option in kernel .config. kernel sources available in same way android sources (see http://source.android.com ); have add .repo/local_manifest.xml file such as: <?xml version="1.0" encoding="utf-8"?> <manifest> <project path="kernel" name="kernel/omap" revision="refs/heads/android-omap-2.6.29"/> </manifest> and yes, if build driver module...

c# - Encoding trouble with HttpWebResponse -

here snippet of code : httpwebrequest webrequest = (httpwebrequest)webrequest.create(request.rawurl); webrequest.defaultwebproxy = null;//ensure not loop going again in proxy httpwebresponse response = (httpwebresponse)webrequest.getresponse(); string charset = response.characterset; encoding encoding; if (string.isnullorempty(charset)) encoding = encoding.default; else encoding = encoding.getencoding(charset); streamreader resstream = new streamreader(response.getresponsestream(), encoding); return resstream.readtoend(); the problem if test : http://www.google.fr all "é" not displaying well. have try change ascii utf8 , still display wrong. have tested html file in browser , browser display html text pretty sure problem in method use download html file. what should change? removed dead imageshack link update 1: code , test file changed firstly, easier way of writing code use streamreader , readtoend: httpwebrequest webrequest = (httpwebrequest)web...

How to write this Lisp / Scheme code? -

a lambda expression takes function (of 1 argument) , number, , applies function twice number. applying function twice number: (lambda (f x) (f (* 2 x))) applying function number twice (which may have intended ask): (lambda (f x) (f (f x)))

java - Convenient way to parse incoming multipart/form-data parameters in a Servlet -

this question has answer here: how upload files server using jsp/servlet? 12 answers is there convenient way read , parse data incoming request. e.g client initiate post request urlconnection connection = new url(url).openconnection(); connection.setdooutput(true); connection.setrequestproperty("content-type", "multipart/form-data; boundary=" + boundary); printwriter writer = null; try { outputstream output = connection.getoutputstream(); writer = new printwriter(new outputstreamwriter(output, charset), true); // true = autoflush, important! // send normal param. writer.println("--" + boundary); writer.println("content-disposition: form-data; name=\"param\""); writer.println("content-type: text/plain; charset=" + charset); writer.println(); writer.println(param); i’m not...

c# - How do I use reflection to call a generic method? -

what's best way call generic method when type parameter isn't known @ compile time, instead obtained dynamically @ runtime? consider following sample code - inside example() method, what's concise way invoke genericmethod<t>() using type stored in mytype variable? public class sample { public void example(string typename) { type mytype = findtype(typename); // goes here call genericmethod<t>()? genericmethod<mytype>(); // doesn't work // changes call staticmethod<t>()? sample.staticmethod<mytype>(); // doesn't work } public void genericmethod<t>() { // ... } public static void staticmethod<t>() { //... } } you need use reflection method start with, "construct" supplying type arguments makegenericmethod : methodinfo method = typeof(sample).getmethod("genericmethod"); methodinfo generic = m...

c++ - Static or dynamic linking the CRT, MFC, ATL, etc -

back in 90s when first started out mfc used dynamically link apps , shipped relevant mfc dlls. caused me few issues (dll hell!) , switched statically linking instead - not mfc, crt , atl. other larger exe files, statically linking has never caused me problems @ - there downsides other people have come across? there reason revisiting dynamic linking again? apps stl/boost nowadays fwiw. there downsides: bigger exe size (esp if ship multiple exe's) problems using other dll's rely on or assume dynamic linking (eg: 3rd party dll's cannot static libraries) different c-runtimes between dll's independent static linkage (no cross-module allocate/deallocate) no automatic servicing of shared components (no ability have 3rd party module supplier update code fix issues without recompiling , updating application) we static linking our windows apps, because allows xcopy deployment, not possible installing or relying on sxs dll's in way works, since proces...

.net - Indexing into a String in C# as an L-Value -

i have following intentionally trivial function: void replacesome(ref string text) { stringbuilder sb = new stringbuilder(text); sb[5] = 'a'; text = sb.tostring(); } it appears inefficient convert stringbuilder index , replace of characters copy ref'd param. possible index directly text param l-value? or how else can improve this? c# strings "immutable," means can't modified. if have string, , want similar different string, must create new string. using stringbuilder above easy method any.

osx - How to change the Mac OS X Keyboard Layout programmatically? -

my qt app supports changing input language on linux , windows. want add support changing input language in mac osx, too. unfortunately don't have information mac sdk. (my first , last work os x compiling qt , compiling app!) i googling problem , found need use text input source services , found these codes: tisinputsourceref isref; isref = tiscopycurrentkeyboardinputsource(); cfdataref uchr = (cfdataref)tisgetinputsourceproperty(isref, ktispropertyunicodekeylayoutdata); uckeyboardlayout * keylayoutptr=(uckeyboardlayout*)cfdatagetbyteptr(uchr); is keylayoutptr pointer current keyboard layout? if answer above question "yes", should compare keylayoutptr ? in other words, how can check if current keyboard layout (for example) "english"? (or lang_english in win api or us in xlib.) i think you'd pass isref tisgetinputsourceproperty , using key ktispropertyinputsourcelanguages , , check whether first language code in array "en...

php - Speed up forum conversion -

i'm converting forum mybb ipboard (the conversion done through php script), have on 4 million posts need converted, , take 10 hours @ current rate. have unlimited ram , cpu, want know how can speed process up? there way can allocate huge amount of memory 1 process? help! you're not going script run faster. giving more memory, might able have more posts @ 1 time, though. change memory_limit in php.ini file change how memory can use. you might able tell script 1 forum @ time. run several copies of script @ once. limited how talks database table , whether script has been written allow -- might daft things lock target table or insanely long read on source table. in case, unlikely more 3 or 4 running @ once without slowing down, anyway. it might possible improve script, several days' hard work learning insides of both forums' database formats. have asked on forums ipboard? maybe there has experience @ you're trying do.

iphone - How to save tab bar order when app is terminated? -

the following example: http://www.raddonline.com/blogs/geek-journal/iphone-sdk-uitabbarcontroller-how-to-save-user-customized-tab-order/ doesn't work in ios4. i able save order of tabs when application shut down. you can set application delegate uitabbarcontroller delegate, , when tab selected, can record selection [nsuserdefaults standarddefaults] integer (selected index of tab bar controller). do in: - (void)tabbarcontroller:(uitabbarcontroller *)tabbarcontroller didselectviewcontroller:(uiviewcontroller *)viewcontroller; { [[nsuserdefaults standarddefaults] setinteger:tabbarcontroller.selectedindex forkey:selectedtabindex]; } on launch, can load selected index defaults using -integerforkey: , default 0 if value not found key, or if key not parsed integer. i wrap access saved index method: - (nsuinteger)tabindextoselect; { return [[nsuserdefaults standarddefaults] integerforkey:selectedtabindex]; // defaults 0 } a note nsuserdefaults .. u...

flash - Flex - Remoting vs HTTPService - when to use what? -

i have been using flex while , have not used remoting of yet. apps use webservice generates xml use databinding. what benefit using remoting on xml webservice in use case? there general guideline when should choose remoting on webservices? why want use remoting? i have downloaded http://www.fluorinefx.com/ , have yet real tinkering... thanks. speaking use remoting because prefer amf soap/xml simple reason of speed , packet size. ted has discussion in relative merits of xml vs. amf here something consider have in place on server , think future of clients lies. anticipate replacing or extending clients? if yes web services architectural choice. if committing flex in short/medium term may able squeeze better performance out of remoting amf3 vs. web services. p.s. once had link site had measurements of relative performance of amf , soap - i'll see if can find , post link. p.p.s. here is , seems not working @ moment.

Hello World jQuery Code not working -

i'm trying system set-up learn jquery , can't seem simple hello world program work , i'm not sure why. seems should work fine. i'm using ci here controller followed view. thanks. class java extends controller{ function index(){ $this->load->view('java_view'); } } the view file: <script type = "javascript" src="http://localhost/ci/js/jquery.js"></script> <script type="javascript"> $(document).ready(function() { $("#hi").click(function() { alert("hello world!"); }); }); </script> <a id = "hi" href="">link</a> works perfectly, proven in example: http://jsfiddle.net/tt5s7/ the error has in linkage jquery.js or in java controller.

How to get a variable name as a string in PHP? -

say have php code: $foobar = "a string"; i need function this: print_var_name($foobar); which prints: foobar any ideas how achieve this? possible in php? you use get_defined_vars() find name of variable has same value 1 you're trying find name of. not work, since different variables have same values, it's way can think of this. edit: get_defined_vars() doesn't seem working correctly, returns 'var' because $var used in function itself. $globals seems work i've changed that. function print_var_name($var) { foreach($globals $var_name => $value) { if ($value === $var) { return $var_name; } } return false; } edit: clear, there no way in php, because shouldn't have it. there better ways of doing you're trying do.

using MVVM light messenger with Silverlight 4 ChildWindow dialog class -

greetings! enjoying using mvvm light -great framework - has made life easier, , has removed number of barriers proving difficult overcome.... question: i attempting setup custom dialog box editing messages users send each other. attempting construct silverlight custom dialog box using childwindow object using mvvm framework. was wondering if there suggestions how might accomplished following dialog mvvm sample code found here: http://mvvmlight.codeplex.com/thread/view.aspx?threadid=209338 got stuck because childwindow dialog object in silverlight async, , has different result class. so - basic idea have using view model of class (in case matrix.messageviewmodel) create instance of custom dialog box, send through messenger.send<>, process registered message in view display dialog, have childwindow dialog box's save button handler fire messenger.send modified contents stored using save method on viewmodel... seems bit round-about - wanted make sure there wasn...