Posts

Showing posts from April, 2011

objective c - Display images in both portrait and landscape mode -

i have straight forward ui displays 3 250 x 180 images in uiimageview's want able show them in more interesting way , when ipad rotated landscape mode images overlap text etc. looks bit cheap. what options displaying 3 images more creatively? determine best way display images both orientations are. depending on how different things need be, got 3 basic options: 1) difference small, need tweak positioning. can accomplished adjusting images struts , springers on layout tab of @ nib editor. 2) need rearrange things make more sense when rotated. in case, implement willrotatetointerfaceorientation , adjust position of images in method. changes animated automatically, looks simple adjustments. 3) want give user different experience in both orientations. in case might want make separate view controllers both orientations. there quite few tutorials found if need approach. if matter of placing images in way fit, option 2 suitable one.

How to retrieve a clicked element in a Jquery treeview -

i willing use jquery treeview. have categories , subcategories choose item , display them in treeview. clicked value. for moment working on of kind of : <ul id="treeview"> <li>group1a <ul> <li>group11 </li> </ul> </li> <li>group2 </li> <li>group3 </li> <li>group4 </li> <li>group5 </li> </ul> and tried script, click function throw me error. <script type="text/javascript"> $().ready(function () { $("#treeview").treeview(); }); $("#treeview").click(function (e) { e.target.addclass("selected"); }); </script> i big beginner jquery way of handling things, assume missing important point somewhere... help.. the addclass jquery method, while e.target not jquery object. need enclose...

Displaying a string while using cond in Lisp -

i'm starting off lisp , need help. technically homework, gave try , getting wanted: (defun speed (kmp) (cond ((> kmp 100) "fast") ((< kmp 40) "slow") (t "average"))) however, if run program displays "average" instead of average (without quotes). how can display string without quotes? you can use symbols instead of strings: (defun speed (kmp) (cond ((> kmp 100) 'fast) ((< kmp 40) 'slow) (t 'average))) symbols uppercased default, internally fast fast. you can write symbol in case , characters using escaping vertical bars: |the speeed fast!| above valid symbol in common lisp , stored internally write case preserved.

flex - Javascript: Flash callback method produces error UNLESS alert() first? -

ok have flex app , adding callback method this: private function init():void { externalinterface.addcallback( "playvideo", playvideo ); } private function playvideo(videosource:string):boolean { videodisplay.source = videosource; return true; } i calling javascript this: function showvideo(video) { document.getelementbyid("video_overlay").style.display = "block"; //alert('no error'); document.getelementbyid("minimacvideopreview").playvideo('https://www.kranichs.com/instore/minimac/videos/'+video); } i javascript error: object not support property or method. however if uncomment , run alert first. no error , works perfectly. my first thought alert buying time until script execute, tried run script inside settimeout() did not work. any ideas? thanks! i try placing code in jquery's $(window).load function. have feeling right. time close alert, dom , contents fin...

delphi - How to embed HTML help in a form window -

i'm wondering if possible display topics chm file in form of delphi application? know how use htmlhelp api launches external viewer. display topics within form not tested, but... if pass help url (like ms-help://embarcadero.rs2009/delphivclwin32/system__tdatetime__-@tdatetime_@const.html ) embedded webbrowser , should work.

iphone - Can we create xib (with view) programmatically ? If No, why & If yes, How? -

can create xib (with view) programmatically ? if no, why & if yes, how ?? xibs files, too, there's no technical reason why wouldn't able create 1 programmatically. expect no convenience methods create xibs however, purpose circumvent need create , configure ui elements programmatically, opposite of people use xibs for. if must create xibs though, open 1 in texteditor - you'll see consists of readable xml code. may take time work through keys , possibilities, creating xibs programmatically can done. edit: it's gonna hard, though.

asp.net mvc 2 - Silverlight application with binary xml -

my silverlight + asp.net mvc application following: 1) silverlight client sends request via httpwebrequest. 2) asp.net mvc connects sql server database (stored procedure) , gets xml data sends raw xml client (no web services or wcf). 3) silverlight client receives xml , deserializes xmlserializer class. 4) deserialized object manipulated, serialized , sent server. 5) asp.net mvc receives xml , directly sends database (stored procedure) shreded , saved appropriate table(s). is acceptable architecture? problem approach be? also, sl 3 there seems option use binary xml, don't see information how use without wcf. found wcf quite heavy, deliberately avoid it. me, asp.net mvc based restful architecture seems more appealing. above description may not restful, think quite close. thoughts welcome. i think wcf simplify scenario , open many options maybe don't need right useful in future (for ex. if decide add kind of client, or decide implement security mechani...

c# - Cannot localize (translate) a custom control in .NETCF 2.0 -

i translating compact framework 2.0 windows form in visual studio 2005. that, change language of form german (the target language) , edit/resize controls on form. creates resources.de.resx file containing translated strings expected. however, there custom control on form, has property called grouptext, must translated. however, form designer refuses use resource files property. whenever change property in property editor, gets changed languages. checked resx files - not contain grouptext property, , designer generated code not use resx file property. is there way enable resx-based, visual studio supported localization custom controls well? edit: as addition accepted answer, here's have resx files custom controls work. each property should go resx file must have localizable attribute set true . now, cf not support attribute via usual bracket syntax. cannot write [localizable=true] in cs source file. have create separate file called designtimeattributes.xmta in proje...

lint - Which are the best free Visual Studio 2008 plugins? -

i new visual studio 2008 (not 2010). think best free visual studio 2008 add-ins or plugins? there lint one? thanks powercommands pretty nice: http://code.msdn.microsoft.com/release/projectreleases.aspx?projectname=powercommands&releaseid=559 coderush express helps quite lot, , code style enforcer nice too. coderush: http://devexpress.com/products/visual_studio_add-in/coderushx/ code style enforcer + dxcore: http://joel.fjorden.se/static.php?page=codestyleenforcer , devexpress.com/products/visual_studio_add-in/dxcore/

c# - Best pattern for "Do some work and quit" -

i'm writing little gui program work , exits afterwards. while work done, gui thread updated infos user. this pattern i'm using , i'm thinking it's not elegant one: static void mainform_loaded(beoexport exporter) { // thread 1 runs export workerthread = new thread(() => { exporter.startexport(); // don't exit immediately, user sees someting if work done fast thread.sleep(1000); }); // thread 2 waits thread 1 , exits program afterwards waiterthread = new thread(() => { workerthread.join(); application.exit(); }); workerthread.start(); waiterthread.start(); } so pattern/mechanics use same? to clarify: not interested in way update gui thread. that's done. might sound esoteric lookig right way quit application. if could, give dave credits, since pointed out usefulness of backgroundworker. have considered backgroundworker thread instead? can use reportp...

c# - Decompile without CLI header? -

is possible decompile executable when trying decompile w/ reflector, errors out "module ... not contain cli header.", , if so, how decompile c#? thank you. that indicate it's not managed assembly. means reflector won't able decompile it.

How do you reload all vim windows at once? -

i have few files open in vim, in multiple windows. there command :e reload buffers files have open? need because sometime alter of files editor while open in vim. the :windo command windows :bufdo buffers. is: :windo e should cycle through visible windows (i.e, not windows on other tabs, if any) , execute ':e' command. likewise: :bufdo e would cycle through buffers in buffer list (i.e., no "hidden" buffers) , execute same command. note may have buffers in buffer list not displayed in window. whether use ':windo e' or ':bufdo e' depends on want. relevant here: http://vimdoc.sourceforge.net/htmldoc/windows.html#list-repeat

c# - C-sharp's "#region" & "#endregion" in Java? -

possible duplicate: java equivalent #region in c# is there in java allow structuring source code done in c# pre-processor directives #region and #endregion ? no, there nothing equivalent. code folding ide feature, not language feature. eclipse has code folding classes , members when java files loaded in it. may extended (for example) add code folding on crafted comment lines.

c++ - Disable accelerator table items in MFC -

i need temporarily disable few items accelerator table when input focus on cedit field. my application has commands associated keyboard keys (a, s, d, etc.) , need disable while user entering text in field. you try copyacceleratortable array of accel structures edit out ones don't want, call destroyacceleratortable on current table. use createacceleratortable create new table edited accelerator table. edit: this link may useful.

.net - c# extract values from key-value pairs in string -

i have string this: blablablamorecontentblablabla?name=michel&score=5&age=28&iliedabouttheage=true looks regular query string yes, i'm not in web context now want extract values (after = sign) key , example,what name (michel), score(5), age(28) etc. normally parse string position in string of word 'name', add 5 (length of 'name=') , name position 'start' search &-sign , name position 'end', , string between position start , end. but there must better solution, regex thing? try system.web.httputility.parsequerystring , passing in after question mark. need use system.web assembly, shouldn't require web context.

java - Android onKey w/ virtual keyboard -

i catching keyboard events/presses using onkey method: public boolean onkey(view arg0, int arg1, keyevent arg2) { //do return false; } this fires off fine physical keyboard presses not fire on virtual keyboard presses. there event handler handle virtual keyboard presses? if it's edittext, see if can use textchangedlistener instead. myedittext.addtextchangedlistener(new textwatcher(){ public void aftertextchanged(editable s) {} public void beforetextchanged(charsequence s, int start, int count, int after) {} public void ontextchanged(charsequence s, int start, int before, int count) { //do stuff } });

rubygems - Ruby OSA gem install problem -

trying install rubyosa on imac sudo gem install rubyosa i following error: error: error installing rubyosa: error: failed build gem native extension. /system/library/frameworks/ruby.framework/versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files ruby @ /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/ruby.h gem files remain installed in /library/ruby/gems/1.8/gems/rubyosa-0.4.0 inspection. results logged /library/ruby/gems/1.8/gems/rubyosa-0.4.0/gem_make.out i've had error show lot of times while installing gems. found out later needed development package included needed headers compilation. on debian machine in ruby-dev package. i reading on internet os x ships headers xcode, might need them there. i found link might of you: http://www.fngtps.com/2009/08/missing-ruby-headers-after-snow-leopard-upgrade [edit: original link broken, here's internet archive of page: https://web.archive.org/web/20100327201647/htt...

Exponential Operator in C++ -

i taking class in c++ , noticed there few math operators use. noticed c++ not come exponential operator within math library. why must 1 write function this? there reason makers of c++ omit operator? you don't write function (unless you're insane, of course). there's perfectly pow function defined in <cmath> header. aside: if try use ^ power operator, people wont do, you'll in nasty surprise. it's exclusive-or (xor) operator (see here ).

c++ - initialize boost::multi_array in a class -

for start newbie. i trying initialized boost:multi_array inside class. know how create boost:multi_array : boost::multi_array<int,1> foo ( boost::extents[1000] ); but part of class have problems: class influx { public: influx ( uint32_t num_elements ); boost::multi_array<int,1> foo; private: }; influx::influx ( uint32_t num_elements ) { foo = boost::multi_array<int,1> ( boost::extents[ num_elements ] ); } my program passes through compilation during run-time error when try accuse element foo (e.g. foo[0] ). how solve problem? use initialisation list (btw, know zip bit of boost, i'm going code): influx::influx ( uint32_t num_elements ) : foo( boost::extents[ num_elements ] ) { }

c++ - Converting a string to LPCWSTR for CreateFile() to address a serial port -

i seem having bit of text / unicode problem when using windows createfile function addressing serial port. can please point out error? i'm writing win32 console application in vc++ using vs 2008. i can create handle address serial port this: #include <iostream> #include <windows.h> #include <string> int main() { handle hserial; hserial = createfile( l"\\\\.\\com20", generic_read | generic_write, 0, 0, open_existing, file_attribute_normal, 0);` return 0; } that works fine (the \\\\.\\ bit required comports greater com9 , works com9 also). problem comport not com20, i'd have user specify is. here things i've tried: #include <iostream> #include <windows.h> #include <string> int main() { std::string comnum; std::cout << "\n\nent...

jquery - When adding events to FullCalendar they are duplicated - multiple calls made to add event without cause -

i using fullcallendar , jquery. made google calendar interface , pull events json file. when user clicks on day div opens them enter info click add event , event added. on second click when user clicks add event 2 events added, 1 on first clicked day , second on selected day. on third click 3 events added , on. here code: var c = 0; function cleaneventbubble(){ $('#event').hide(); $('td').removeclass('selday'); $('#eventdate').text(''); $('#calevent,input:text').val(''); } function createevent(date, allday, jsevent, view, selcell){ //clean event bubble , calendar cleaneventbubble(); $(selcell).addclass('selday'); $('#eventdate').append(date.todatestring()); $('#event').css('left', jsevent.pagex); $('#event').css('top', jsevent.pagey); $('#event').show(); $('#btnaddevent').click(function(){addevent(date, $('#...

c++ - Direct Show (AMCap) - Platform SDK -

i trying capture images multiple web cams simultaneously , save them automatically minimum delay using c++. want program able alter parameters of web cam when ever needed. hoping build direct show samples (amcap) on platform sdk, , edit code suit application. keep getting errors. i able build base classes , included paths under 'include' , 'library files'. got following errors when trying build amcap. working on xp visual studio 2008. compiling... amcap.cpp d:\program files\microsoft sdks\windows\v6.1\samples\multimedia\directshow\capture\amcap\amcap.cpp(231) : error c2664: 'stringcchcata' : cannot convert parameter 3 'wchar [260]' 'strsafe_lpcstr' types pointed unrelated; conversion requires reinterpret_cast, c-style cast or function-style cast d:\program files\microsoft sdks\windows\v6.1\samples\multimedia\directshow\capture\amcap\amcap.cpp(327) : error c2664: 'getprofilestringa' : cannot convert parameter 4 'wchar [...

flex4 - Flex 4: Can't pre-select item in DataGrid (Array) -

i'm polling remoteobject every 5 seconds using setinterval , returned result (array) being fed datagrid dataprovider. everytime happens selected row deselects when datagrid refreshed. want re-select item when datagrid has been updated. so far i've tried capturing selected row before remoteobject called using: private function refreshdatagrid(e:resultevent):void { var selectedrow:object = mydatagrid.selecteditem; mydatagrid.dataprovider = e.result array; mydatagrid.selecteditem = selectedrow; } however doesn't work. if select row , "trace(mydatagrid.selecteditem)", result in console blank. in attempt tried: private function refreshdatagrid(e:resultevent):void { var selecteditem:* = mydatagrid.selecteditem.itemid; mydatagrid.dataprovider = e.result array; mydatagrid.selecteditem.itemid = selecteditem; } this doesn't work either. can me make work? appreciated. in advance. it looks have unique itemid property on o...

r row-wide conditional replacement -

friends i'm trying t set matrix or data.frame canonical correlation analysis. original dataset has column designating 1 of x conditions , subsequent columns of explanatory variables. need set array sets indicator variable each condition "x". eg. columns in df are: id cond task1 taskn a, x, 12, 14 b, x, 13, 17 c, y, 11, 10 d, z, 10, 13 here "cond" can x,y,z,... (can vary, don't know how many). needs go to: id, x, y, z, task1, taskn a, 1, 0, 0, 12, 14 b, 1, 0, 0, 13, 17 c, 0, 1, 0, 11, 10 d, 0, 0, 1, 10, 13 so, can set indicators in array iv<-as.data.frame(array(,c(nrow(df),length(levels(cond))))) and cbind df, can't figure out how go array , set appropriate indicator "1" , rest "0". any suggestions? thanks jon if code cond factor, can r expansion want via model.matrix . complication coding chose (dummy variables coding, or sum contrasts in r) need change default constrast...

css - Floating elements within a div, floats outside of div. Why? -

say have div, color green , give definite width, when put stuff within it, in case img , div. idea content of container div cause container div stretch out, , background contents. when this, containing div shrinks fit non-floating objects, , floating objects either way out, or half out, half in, , not have bearing on size of big div. why this? there i'm missing, , how can floated items stretch out height of containing div? the easiest put overflow:hidden on parent div , don't specify height: #parent { overflow: hidden } another way float parent div: #parent { float: left; width: 100% } another way uses clear element: <div class="parent"> <img class="floated_child" src="..." /> <span class="clear"></span> </div> css span.clear { clear: left; display: block; }

OutOfMemoryError: Trying to optimise Maven multi-module unit tests using HSQLDB, DBUnit, unitils, Hibernate, Spring -

i have big multi-module maven project thousands of tests. each test loads daos, services, etc using springapplicationcontext annotation. unitils configuration looks this: database.driverclassname=org.hsqldb.jdbcdriver database.url=jdbc:hsqldb:file:mytestdb database.schemanames=public database.username=sa database.password= database.dialect=hsqldb unitils.modules=database,dbunit,hibernate,inject,spring # custom version of hsqldbdbsupport calls "set referential_integrity false" org.unitils.core.dbsupport.dbsupport.implclassname.hsqldb=my.company.unitils.hsqldbdbsupport org.dbunit.dataset.datatype.idatatypefactory.implclassname.hsqldb=org.dbunit.ext.hsqldb.hsqldbdatatypefactory org.unitils.dbmaintainer.structure.constraintsdisabler.implclassname=org.unitils.dbmaintainer.structure.impl.defaultconstraintsdisabler # custom version of cleaninsertloadstrategy calls "databaseunitils.disableconstraints();" dbunitmodule.dataset.loadstrategy.default=my.company.unitils.dat...

java - Changing Tomcat web application context -

i have web application, designed , worked under root context ("/"). css , js , links started / (for example /css/style.css ). need move web application different context (let's /app1 ). easy change server.xml configuration file , bring web application in new context app1 using [context path=""] item. web pages broken because links incorrect. point old root context /css/style.css instead of new app1 context. there magic way fix problem without fixing each link prefixing "context" variable? used server - tomcat 5. application written java , uses jsp, struts2, spring , urlrewrite filter. more interesting hear real experience in fighting such problems theoretical debates. thank you. p.s. not see how urlrewrite filter can me because work in app1 context. requests links /css/style.css not passed it. you should create urls via url re-writing, not session info can added url, if required, context path can added. should create urls abso...

before filter - In Ruby on Rails, when a before_filter is used, then the local variables need to become instance variables? -

if have before filter that's called initialize initialize common variables, variables must made instance variables? there alternative ways of doing it? update: situation validate url params, , set them. used in 1 action, can done using local variables. now, 3 actions take same params, code moved private method validate_params , , called using before_filter , local variables seem have made instance variables. can not made instance variables? there frameworks / gems validating url params since built-in validations models. are there alternative ways of doing it? doing what, exactly? if want variable available methods in controller, instance variable typically appropriate. if want have variable (or more constant) available controllers, or models , views, there other techniques accomplish that. we'll need more detail specific requirements figure out.

java - How do I get an array of keys from a hashmap that aren't type Object? -

iterator = myhashmap.keyset().iterator(); while (it.hasnext()) { int next = it.next(); } that doesn't work because it.next() returns object. hashmap uses ints keys. of methods accept ints access hashmap. how can int value when looping through keys can pass other methods? you should use generics. map<integer, object> myhashmap; this gives keys integer (not int, cannot helped). integer can automatically unboxed: for (int key : myhashmap.keyset()){ } if want keys in ascending order, consider using treemap instead of hashmap .

how to use use load_file in mysql ? I get a wrong message " Can't get stat of 'D:\w.ini' " ! -

like title. guess matter of file's name. try "d://w.init" , "file:///d:\w.ini", util wrong message. my wild guess running command on remote mysql server, , trying load infile file on local d:\ drive. this cannot work, mysql on server side can't access local d: drive. you need upload file server first.

Python conversion from binary string to hexadecimal -

how can perform conversion of binary string corresponding hex value in python? i have 0000 0100 1000 1101 , want 048d i'm using python 2.6. welcome stackoverflow! int given base 2 , hex : >>> int('010110', 2) 22 >>> hex(int('010110', 2)) '0x16' >>> >>> hex(int('0000010010001101', 2)) '0x48d' the doc of int : int(x[, base]) -> integer convert string or number integer, if possible. floating point argument truncated towards 0 (this not include string representation of floating point number!) when converting string, use optional base. error supply base when converting non-string. if base zero, proper base guessed based on string content. if argument outside integer range long object returned instead. the doc of hex : hex(number) -> string return hexadecimal representation of integer or long integer.

activerecord - how to modify complex find_by_sql query w/ union into rails 3 -

here's current query: @feed = ratedactivity.find_by_sql(["(select *, null queue_id, 3 model_table_type rated_activities user_id in (?)) " + "union (select *, null queue_id, null rating, 2 model_table_type watched_activities user_id in (?)) " + "union (select *, null rating, 1 model_table_type queued_activities user_id in (?)) " +"order activity_datetime desc limit 100", friend_ids, friend_ids, friend_ids]) now, bit of kludge, since there models set for: class ratedactivity < activerecord::base belongs_to :user belongs_to :media end class queuedactivity < activerecord::base belongs_to :user belongs_to :media end class watchedactivity < activerecord::base belongs_to :user belongs_to :media end would love know how use activerecord in rails 3.0 achieve same thing done crazy union have there. it sounds should consolidate these 3 separate models single model. statuses such "watched", "...

vb.net - ASP.NET MVC custom user roles/profiles -

i creating website using asp.net mvc model. when create mvc application asp.net automatically creates roles/profiles user , admins (as far know) , corresponding tables in sql server database. i need new profile/role names "sponsor" has benefits of users/admins (like authorization etc). is there way this? thanks in advance actually default there no roles defined in asp.net forms authentication database when use asp.net mvc, it's easy define them. need open project in visual studio , click "project" menu , click "asp.net configuration" @ bottom. system can set roles , users need.

c# - How to get value from the object but its type is unreachable -

for instance, in current class, there hashtable, hashtable t = gethashable(); //get somewhere. var b = t["key"]; the type of b hidden current class, unreachable, not public class type. but want value b, example b has field call "id", need id b. is there anyway can it, reflection ??? if don't know type, you'll need reflection: object b = t["key"]; type typeb = b.gettype(); // if id property object value = typeb.getproperty("id").getvalue(b, null); // if id field object value = typeb.getfield("id").getvalue(b);

iphone - How do you calculate the day of the year for a specific date in Objective-C? -

this found myself spending hours figure out , therefore want share you. the question was: how determine day of year specific date? e.g. january 15 15th day , december 31 365th day when it's not leap year. try this: nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsuinteger dayofyear = [gregorian ordinalityofunit:nsdaycalendarunit inunit:nsyearcalendarunit fordate:[nsdate date]]; [gregorian release]; return dayofyear; where date date want determine day of year for. documentation on nscalendar.ordinalityofunit method here .

iphone - NSManagedObject is there a way to import created subclass to xcdatamodel file -

i have question. you can export nsmanagedobject subclass xcode xcdatamodel file when create entity. is there way import nsmanagedobject subclass xcdatamodel diagram??? thanks i not think possible. however, should pretty easy manual build entity , may find out had missing (e.g. inverse relationship). you can import compiled datamodel file (.mom) model design document (.xcdatamodel) using xcode > design > data model > import.

Access/rights to Infragistics images and javascript in Sharepoint for a page in _layouts -

the infragistics images , javascript files located on server in: "\nasmoss\c$\inetpub\wwwroot\aspnet_client\infragistics". i created page , put in _layouts folder in sharepoint. hierarchical grid. has + expand group. for certian users, displays red x showing images not available. javascript errors since can't access javascript include files infragistics. if login network admin login, works. if login normal user account works sometimes. fix login admin account , login noraml account. this affects other normal users. if red x login admin account. works them while. it appears rights issue sharepoint. intermittent. can't reproduce it. stops working in day hours. don't use page (twice week). if right click , full path image webresource.axd. https://sharepoint .{domain}.com/webresource.axd?d=i9i-y5igqdxx3n6e-hsxfehlchb2dbatydlbt5a8vp6asscjd8jdrowgqkdsq5wmawcgxjgrfyntcf93yfplid2ytesxjvg7xipvnlttfe7wxg6qgtlali18s2hn40po0&t=633480367580000000 if hav...

Print all session/post/get variables in ASP.NET page -

i new asp.net, i'm quite used php (which unfortunately not use @ work) i'd print session variables. in php it's quite easy, use: echo '<pre>' . print_r($_session, true) . '</pre>'; for this, there as-easy asp.net equivalent? with box being label. foreach (string in session.contents) { if (session[i] != null) { box.text += + " = " + session[i].tostring() + "\n"; } }

c# - WP7 Wlan detection (HOW am I online) -

to honest, kind of lazy @ moment. tried 3 minute search, lot of windows7 , c# related stuff, not looking for. pet project anyway, give try: is there way find out how connected internet in wp7? background: app written fun purposes, e.g. picture sorting app. want sync lot of stuff server when online via wlan (e.g. 200mb), should not if using expensive gprs connection... thanks tips, rtfm search word google trick :-) chris i believe this answers question from link: the application must register networkaddresschanged event of system.net.networkinformation.networkchange class. on receipt of event application can use networkinterfacetype property determine current connection state.

How to iterate initialized enumerated types with Delphi 6 and avoid the "out of bounds" error? -

i using delphi 6 professional. interfacing dll libraty declares enumberated type follows: textdllenum = (enum1 = $0, enum2 = $1, enum3 = $2, enum4 = $4, enum5 = $8, enum6 = $10); as can see initialized values not contiguous. if try iterate type using loop follows: var e: textdllenum; begin e := low(texttodllenum) high(texttodllenum) ... // more code end; delphi still increments e 1 each loop invocation , thereby creates numeric values e not members of enumerated type (for example, '3'), , resulting in 'out of bounds' error. how can iterate enumerated type in loop generates valid values enumerated type? thanks. by defining set of constants... type textdllenum = (enum1 = $0, enum2 = $1, enum3 = $2, enum4 = $4, enum5 = $8, enum6 = $10); const cextdllenumset = [enum1, enum2, enum3, enum4, enum5, enum6]; var e: textdllenum; begin e := low(textdllenum); while e <= high(textdllenum) begin if e in cextdllenumset ...

php - Approach to sending alerts with CakePHP -

this rather obscure question please bare me. it's more approach syntax. i have mysql table filled 'notifications' (id,user_id,date,etc). have send alert (via email, facebook, twitter, whatever... not issue) when each of entries pings 'true'. here's thing, how should go pinging them true in efficient way possible when conditions determine true/false have calculated? sending email of bday easy. search date field today's date. suppose have send en email every 20th day starting date entered in field? have calculate each row see if it's true today. how should that? i've considered following: 1. complex mysql query 2. php page cron job run through each row , mark them done 1 1 every x seconds/min 3. pulling hair out , running out of room screaming little girl. i'm leaning toward 3 @ moment. my main concern i'm on shared server , don't want intensive. spending brain on this. appreciate it. you should have @ strtotime() exam...

java - referencing data files in jars -

my java program references lot of data files. put them in top level directory called data/, along src/ , bin/. in eclipse, references data/ , ../data/ both seem work. when run command line, ../data/ works. when put bin/ , data/ directories in jar , correctly set entry point, doesn't seem know want access data/ directory inside jar. way i've been able work setting references ../data/ , placing jar in bin directory. doesn't me good, because it's not self-contained. what need references make them work? thanks i'd recommend access files in classpath-relative way, whether in eclipse or in compiled jar. there few ways might go it, basic jdk-only approach use class's getresourceasstream() method, giving access inputstream object can read in.

ASP.Net MVC 2 Areas: The partial view '...' was not found -

we upgraded project mvc 2 , we'd use areas there issue. we have created new area, setup controller, configured route, , created view in correct location. when run code finds route , hits controller when goes render view there exception. the web forms view engine doesn't seem looking in areas section views. error we're seeing is: ~/views/<controllername>/<viewname>.aspx ~/views/<controllername>/<viewname>.ascx ~/views/shared/<viewname>.aspx ~/views/shared/<viewname>.ascx when should be: ~/<areaname>/views/<controllername>/<viewname>.aspx ~/<areaname>/views/<controllername>/<viewname>.ascx ~/<areaname>/views/shared/<viewname>.aspx ~/<areaname>/views/shared/<viewname>.ascx ~/views/<controllername>/<viewname>.aspx ~/views/<controllername>/<viewname>.ascx ~/views/shared/<viewname>.aspx ~/views/shared/<viewname>.ascx this indicate it...

Is it possible to make a WebSocket connection in Silverlight? -

is possible make websocket connection in silverlight? or if not, know whether scheduled future versions? ostensibly yes. in fact has been used provide fall solution browsers don't support websockets. see following more info note implementation against v75 not v76 (latest). demo: http://40interop.ep.interop.msftlabs.com/html5/wschat.html info: http://mtaulty.com/communityserver/blogs/mike_taultys_blog/archive/2010/07/27/silverlight-and-websockets.aspx info: http://tomasz.janczuk.org/2010/07/silverlight-html5-websocket-client-with.html

string - What's the difference between \n and \r\n? -

they both mean "new line" when 1 used on other? \r\n windows style \n posix style \r old pre-os x macs style, modern mac's using posix style. \r carrige return , \n line feed, in old computers not have monitor, have printer out programs result user, if want printing staring of new line left, must \n line feed , , \r carriage return left position, old computers syntax saved time on windows platform.

xilinx - Why IEEE vhdl standard library is not STL? -

ieee vhdl language reference manual defined limited set of standard packages.and not defined functionalities on standard types,such std_logic.so there no standard and2, inv components/operator. it seems altera's max+plus ii not support and2, inv component(if there are,please feel free correct me),but xilinx foundation does. why ieee vhdl standard library not become stl in c++ world? thanks. invert, and, or,... std_logic types are supported ieee libraries: a <= b , c d <= not e f <= g or h your synthesis tool automatically translate these expressions best implementation target technology (xilinx fpga, altera fpga, asic, ...). there no need explicitly instantiate technology specific components. instantiating technology specific components might obstruct optimizations. you should try write vhdl code technology independent . allows reuse code.

actionscript 3 - ArgumentError: Error #1508: The value specified for argument font is invalid -

i have air application loads external swf when prompted user. in external swf, have class loads necessary fonts particular swf. when air application attempts load swf argumenterror: error #1508: value specified argument font invalid. ideas? thanks. i decided not load font libraries external swf used , opted use fonts loaded @ runtime main application.

c# - How do I look up the proper Windows System Error Code to use in my application? -

i writing c# .net 2.0 application wherein when message expected received via serialport . if frame not received (i.e. times out) or determined invalid, need set error code using setlasterror . windows has plethora of error codes. there simple tool or reference narrow down proper error code use? additional info while throwing exception , handling higher stack preference, not option in case because application updating not designed take advantage of such useful feature. in "good old days" (c , c++), list of possible windows errors defined in winerror.h update: link below dead. not sure if file still available download, windows system error code definitions can found @ link. this file can found on microsoft's site (although surprises me little dated far 2003 - might worth hunting more recent version). but if you're getting (or wanting set) win32 error codes, this'll definition found.

Rails: Ajax: Changes Onload -

i have web layout of looks this <html> <head> </head> <body> <div id="posts"> <div id="post1" class="post" > <!--stuff 1--> </div> <div id="post2" class="post" > <!--stuff 1--> </div> <!-- 96 more posts --> <div id="post99" class="post" > <!--stuff 1--> </div> </div> </body> </html> i able load , render page blank , , have function called when page loaded goes in , load posts , updates page dynamically. in rails, tried using "link_to_remote" update of elements. tweaked posts controller render collection of posts if ajax request (request.xhr?). worked fine , fast. update of blank div triggered clicking link. same action happen when page loaded don't have put in link. is there rails aja...

objective c - Binding returns default value (set with registerDefaults:) instead of zero -

here's setup: mytextfield bound key in shared user defaults controller. user can enter numbers in text field. each time application loads, load default preferences (from app's resources folder) using [[nsuserdefaults standarduserdefaults] registerdefaults: ... ] . mymenuitem 's title bound same key in shared user defaults controller. the issue: when mytextfield empty, mymenuitem receives default value loaded using registerdefaults: instead of value represents empty field (i expect 0 or nil ). for example, when nstextfield empty menu item receives "2", value loaded using registerdefaults: , instead of value means field empty. if comment registerdefaults: code, binding returns nil expect when there nothing in nstextfield . i tried mess around many of bindings' settings experiment placeholder values , looked @ cocoa bindings , user defaults docs not find solution. expected behavior: when text field empty, want mymenuitem reflect i...

XML to XLS using java -

how can map metadata data. example want lastname , email xml file xls file. how can select lastname , email xml file , convert 2 column xls file columns being lastname , email. thank you xml document <root> <metadata> <item name="last name" type="xs:string" length="182"/> <item name="first name" type="xs:string" length="182"/> <item name="class registration #" type="xs:decimal" precision="19"/> <item name="email" type="xs:string" length="422"/> <item name="saclink id" type="xs:string" length="92"/> <item name="term desc" type="xs:string" length="62"/> <item name="status code" type="xs:string" length="6"/> </metadata> <data> <row...

Update datasource from view values (WinForms DataGridView) -

i changing datagridview cell values programmatically, values not pushed bound datasource. pushed cells belonging selected row. how can ask datagridview push rows values datasource? edit: this code seems trick, may better solution? grid.currentcell = cell; cell.value = "some value"; grid.endedit(0); you shouldn't update datagridview cells, instead should directly update data source. if implements inotifypropertychanged , datagridview reflect changes automatically

curve fitting - In Java, does an implementation exist for interpolating non-uniformly distributed time series data? -

i have matlab code requires time series data uniformly distributed in time produce answer. driver matlab code reads data file runs interp1 ( x, y, xi, 'cubic') on data after reads file because data not uniformly distributed in time. now have port process java add production process. matlab version isn't anemiable large numbers of data files , can't used in production. my actual question can find java library implements interp1 'cubic' method use when data read process? according matlab docs, 'cubic' same piecewise cubic hermite interpolating polynomial (pchip) interpolation. 'spline' produces unacceptable results. have looked @ apache commons-math , jama . drej. http://www.gregdennis.com/drej/ nonlinear least squares via regression on data sets. can specify lamda value ( goodness of fit) , cheaper fit data. it interpolate , extrapolate, don't extrapolate far; if want specific extrapolated far-field behavior ad...

Ruby: Convert time to seconds? -

how can convert time 10:30 seconds? there sort of built in ruby function handle that? basically trying figure out number of seconds midnight (00:00) specific time in day (such 10:30, or 18:45). you can use datetime#parse turn string datetime object, , multiply hour 3600 , minute 60 number of seconds: require 'date' # datetime.parse throws argumenterror if can't parse string if dt = datetime.parse("10:30") rescue false seconds = dt.hour * 3600 + dt.min * 60 #=> 37800 end as jleedev pointed out in comments, use time#seconds_since_midnight if have activesupport: require 'active_support' time.parse("10:30").seconds_since_midnight #=> 37800.0

java me - How to sort Persistent store records in Blackberry application? -

can please me in sorting persistent store records in blackberry application? want sort in ascending , descending order... for sorting in blackberry can use simplesortingvector bad news is, simplesortingvector not persistable. sorting in persistent store have write own sorting method. vector info = (vector) store.getcontents(); now sort contents of vectors sorting algo.

java - Trying to make a program that imitates a Process Table -

i trying create program process table. i have implement class pcb (process control block) several fields such as: process name (a string) process priority (an integer) register set values (an object of class register set containing following fields: xar, xdi, xdo, pc. then program needs create process table data structure either array (max size 100 elements) or arraylist of type pcb, , initialize array data file "processes1.txt" process table arrraylist has print out contents each process. so questions are: 1. how many programs/classes have write? 3. first program creates process table arraylist of pcb. 2nd class pcb class defines pcb fields. 2. how first program initialize arraylist data text file? 3. use arraylist of arraylist? , how that? thank in advance. processtable, processcontrolblock, registerset sound starts. i'd create method in processtable called load(file file) uses file, , perhaps textreader read configuration. there many ways re...

html - HTMLControl on WM 6.1 - VGA -

i facing trouble enabling "high resolution" mode in wm6 professional. using htmlview.dll embed htmlcontrol in our application. default "html" shown not in "high resolution" mode - app appearing zoomed , how displayed in lesser resolution emulators/devices.(qvga) i have referred few links suggested folks. of links point http://msdn.microsoft.com/en-us/library/aa454895.aspx which offers solution turn off emulation layer in wm6 adding line resource file. hi_res_aware ceux {1} // turn off emulation layer this because of accepted bug - discussed @ - hxxp://social.msdn.microsoft.com/forums/en-us/vssmartdevicesnative/thread/4d3c837d-16f4-4ae4-acc2-96bb8d573111/ doing hi_res_aware didn't view on htmlcontrol same. want imitate same functionality ie mobile when select menu->view->high resolution, show html way supposed shown (smaller - more html view screen achieved). i have tried modify dtm_zoomlevel set when html written htmlcontrol - lea...

geolocation - Rails gem - geoipcity is not being included in the application -

i installed geoip_city gem, , tested gem in irb... when using gem in application error uninitialized constant applicationcontroller::geoipcity i guessed because did not add line require geoip_city so tried adding line function used code in, got error no such file -- geoip_city please help. have require rubygems before ? require 'rubygems' require 'geoip_city'

python - trapping a MySql warning -

in python script trap "data truncated column 'xxx'" warning durnig query using mysql. i saw posts suggesting code below, doesn' work. do know if specific module must imported or if option/flag should called before using code? thanks all afeg import mysqldb try: cursor.execute(some_statement) # code steps here: no warning trapped # code below except mysqldb.warning, e: # handle warnings, if cursor you're using raises them except warning, e: # handle warnings, if cursor you're using raises them warnings that: warnings. reported (usually) stderr, nothing else done. can't catch them exceptions because aren't being raised. you can, however, configure do warnings, , turn them off or turn them exceptions, using warnings module. instance, warnings.filterwarnings('error', category=mysqldb.warning) turn mysqldb.warning warnings exceptions (in case caught using try/except) or 'ignore' not show ...

windows - What is the performance cost of a Win32 process switch? -

i know cost of physical win32 thread context switch estimated @ between 2-8k cycles. estimates on cost of process switch? instead of asking estimates, i'd test it. start program like: #include <windows.h> int main() { (int i=0; i<1000000; i++) sleep(0); return 0; } then create parent program spawns (say) 32 copies of this, , uses waitformultipleobjects wait them finish. measure (wall) time start finish, , divide total number of process switches. of course, want run on relatively quiescent system meaningful result.

python - How do I write to the apache log files when using mod_wsgi -

i have django project have been logging file using standard library logging module. variety of reasons change writes apache log files. i've seen quite bit of discussion of how mod_python, not mod_wsgi. how do project running under mod_wsgi? mostly, use logging , write sys.stderr . seems write apache error_log.

java - Compare Multiple Substrings -

i'm attempting write basic dna sequencer. in that, given 2 sequences of same length, output strings same, minimal length of 3. input of abcdef dfeabc will return 1 abc i not sure how go solving problem. can compare 2 strings, , see if equal. there, can compare length-1 string size, i.e. if dfeabc contains abcde . however, how can program possible strings, down minimal size of 3 characters? 1 issue above example of length-1, i'd have string bcdef , compare that. the naive way every single substring of string , see if it's in string b. here's naive way of doing that: for ( int = 0; < a.length; i++ ) { ( int j = i+1; j <= a.length; j++ ) { if (b.contains(a.substring(i, j))) { //if longer last found match, record match } } } the more optimal way @ longer substrings first, first substring matches longest. for ( int length = a.length; length > 0; length-- ) { ( int = 0; + length < a.length; i++ ) {...

C issue - Can't figure how to assign pointer to beginning of list -

i have simple assignment professor wants do. pull in numbers text file , load linked list. don't want details have basic question. he provided function so: intlist* init_intlist( int n ) { intlist *lst; lst = (intlist *)malloc(sizeof(intlist)); lst->datum = n; lst->next = null; return lst; } this function used initialize linked list first element. asked define function signature: int insert_intlist( intlist *lst, int n ) so assume wants add linked list tried this: int insert_intlist( intlist *lst, int n ) { intlist* lsttemp; lsttemp = (intlist *)malloc(sizeof(intlist)); lsttemp->datum = n; lsttemp->next = lst; lst = lsttemp; free(lsttemp); } so thought process creates temporary node, assigns data value (datum) , assigns next pointer point current pointer pointing at. reassign main pointer newly created temp node. that way have instance 2 nodes: [new temp node] -> [prev initialized node] when step through code looks ...