Posts

Showing posts from January, 2011

java - How were the Locale constants chosen? -

the java class java.util.locale has set of public static final fields languages/countries direct references specific locales. other locales can used via appropriate constructors. however, selection of values seems rather arbitrary me. the languages (in order in appear in source): english, french, german, italian, japanese, korean, chinese, simplified chinese, traditional chinese the countries are: france, germany, italy, japan, korea, china, prc, taiwan, uk, us, canda , canada french (for locale fr_ca). does have idea (or guess) how languages/countries chosen? those codes defined iso standards 3166 country codes , 639 language codes. see w3c internationalization activity page. edit: re-reading question, op knew :-) according sun article internationalization: understanding locale in java platform values chosen examples , tells us: because few premade locales exist, should avoid these static objects altogether.

Less time consuming : Rewriting or converting an app from VB5 to C# -

i've got contract have continue development of , old application suite programmed in vb5 in days. i've bug fix , new feature develop. so have few choices: keep programming in vb5 (nooooooooooooooo!!!!) convert vb5 c# (how??? possible without going insane?) rewrite whole application suite (very time consuming) is there other choices? should do? edit: ah , also, relies on access database i'd move sql express. because it's crazy database made illogically stupid programmer '90s lol. thanks the choice i've made every time re-write, or purchase suitable replacement if find one. i have tried doing incremental upgrades vb6 vb.net, don't approach because leaves around activex controls i'd rather not use. re-writing cleaner. i don't think there converter vb5 c#. might able go vb5 vb.net , convert c#, in experience it's less time-consuming re-write try upgrade , fiddle around broken code.

How to Hide Eclipse editor while doing back ground processing -

how hide eclipse editor while doing ground processing, means how working pro-grammatically on eclipse editor without showing end-user. i working on uml diagram. activity diagram gets jumbled on editor when making pro-grammatically, call 'arrange selection' action arrange activity, works properly. need save images of uml diagrams on fly running background processing; editor should not opened user 'arrange selection' code requires editor opened & diagram elements should selected e.g. org.eclipse.gmf.runtime.diagram.ui.actions.internal.arrangeaction.createarrangeselectionaction(iworkbenchpage workbenchpage) how can achieve this. please tell if possible?? thanks in advance kishore you can run background jobs in eclipse ide. in eclipse help, see platform plug-in developer guide > programmer's guide > runtime overview > concurrency infrastructure explanation , examples on how create eclipse background jobs.

activerecord - Undefined method error when using "has_many :through" relationship on Rails3 -

i working on small android project ror server. here 3 models: class user < activerecord::base has_many :relations has_many :friends, :through => :relations attr_accessor :friend_ids end class relation < activerecord::base belongs_to :user belongs_to :friend end class friend < activerecord::base has_many :relations has_many :users, :through => :relations end class createusers < activerecord::migration def self.up create_table :users |t| t.string :user_name t.string :password t.integer :city_id t.integer :travelstyle_id t.boolean :online t.string :self_description t.string :sex t.integer :head_id t.timestamps end end def self.down drop_table :users end end class createfriends < activerecord::migration def self.up create_table :friends |t| t.string :user_name t.integer :city_id t.integer :travelstyle_id t.string :self_description t.string :sex t.integer :head_id t.timestamps end ...

css3 - How can I create a "tooltip tail" using pure CSS? -

Image
i came across neat css trick. check out fiddle... .tooltiptail { display: block; border-color: #ffffff #a0c7ff #ffffff #ffffff; border-style: solid; border-width: 20px; width: 0px; height: 0px; } .anothertail { background-image: url(http://static.jqueryfordesigners.com/demo/images/coda/bubble-tail2.png); display: block; height: 29px; width: 30px; } <div>cool trick: <br /> <div class="tooltiptail"></div> </div> <br /> <div>how effect css? <br /> <div class="anothertail"></div> </div> this creates little arrow/triangle-like effect, "tooltip tail". blows mind! i'm interested in knowing how works?! further, there way extend css trick create effect follows: this interesting problem. can done using css, ignoring shadow now? update 1 i figured out solution initial question. here's fiddle... http://jsfiddle....

javascript - Dynamically add components in specific fieldset in FormPanel -

dynamically add text box in specific fieldset here field set , have many fieldset in form here sharing code of 1 fieldsest. for example, var extradata = [{ bodystyle: 'padding-left:5px;', items:{ xtype:'fieldset', title: 'extra', collapsible: true, autoheight:true, layout:'column', items:[{ columnwidth:.5, layout: 'form', items: [{ xtype:'textfield', fieldlabel: 'comment', name: 'comment', anchor:'95%' }] },{ columnwidth:.5, layout: 'form', items: [{ xtype: 'fileuploadfield', fieldlabel: 'photo', name: 'last', anchor:'95%' }] }] } }]; var fsf = new ext.formpanel({ labelwidth: 75, // label settings here cascade unless overridden url:'save-form.php', frame:true, title: 'enter n...

.htaccess - Redirect 301 - why is my old url being appended to my new url causing a 404 error? -

redirect 301 /features/blahblah.php http://www.mysite.com/articles/blahblah1.php results in http://www.mysite.com/articles/blahblah1.php?q=features/blahblah.php 404 error page not found. so doing wrong here http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect documents what's happening. you want use redirectmatch, like: redirectmatch ^/features/blahblah.php http://www.mysite.com/articles/blahblah1.php if want "permanent" redirect http status 301 (which can desirable seo purposes) rather temporary 302 redirect, instead use: redirectmatch permanent ^/features/blahblah.php http://www.mysite.com/articles/blahblah1.php

code organization - Tips on organizing larger Android projects? -

my current project getting awfully large. have dozens of activities, adapters, fragments, layout xmls, , other resources. in (smaller) previous projects organized stuff 1 package / 1 category style. had com.stuff.xy.adapter, com.stuff.xy.activity, , on. these packages contain many items, , find myself wasting considerable amounts of time searching specific class in package hierarchy. i use eclipse, , there shortcuts 1 can use (go class definition e.g.), tend situational (i can't use jump layout definiton xml). could share tips on organizing large scale projects efficiently? or plugins perhaps? (it might example if group source files deal specific application screen - adapters, layouts, activity , fragment code - can open them) edit: after many months developing large projects first tried go working sets eclipse. didn't cut me, problem our single android project big, containing many resources, classes, interfaces, etc. messing around working sets in context of sin...

javascript - IE7 loses parameters in event handler function - prototype.js -

i have bunch of elements on page class of "product". want attach event handler each one, on hover tooltip shown. following code working fine in chrome, firefox, safari , ie8+, not ie7: function init() { $$('.product').each(function(elm) { var id = elm.id; var name = new element('div', {'class': 'title'}).update(products[id].name); var desc = new element('div').update(products[id].desc); var content = new element('div'); content.appendchild(name); content.appendchild(desc); elm.observe('click', function() {showtooltip(content)}); elm.observe('mouseover', function() {showtooltip(content)}); elm.observe('mouseout', function() {hidetooltip()}); }); } document.observe('dom:loaded', init); in ie7 first time hover on each element, works fine. but, 2nd time hov...

osx - Vi keys in Xcode -

i'm surprised no 1 has asked yet. what's best way (if any) vi experience in xcode? know vimate textmate doesn't come close xcode in terms of integration , code completion. btw, using xcode 4. you might want try out xvim seems active project. indicate works xcode 4.2, espresso , chocolat. presumably selectively enable other applications.

ASP.NET - Global location to execute some code? -

i have newbie .net question. where place write code executes globally before each page load? operations doing are: a) open database connection b) check session see if user logged in c) maybe initialize few objects i thinking of doing in master file, wasn't sure if that's idea. , maybe each of operations listed, maybe there's feature in .net already, don't have "re-invent" wheel. i create base page pages inheriet (except master pages these have different base class) you override preload on base page , checks in there.

.net - Auto generate email based on a field in SQL Server database -

i need run on our internal network , monitor sql server database condition based on date field , generate email when condition met internal user. attempt restate; should monitor db , when date in field reaches variable should generate , send email related user. i.e. auto-reminder i send emails through our exchange server in our desktop app believe on email portion. have not done web developing though wondering if web service looking in answer question. i once wrote windows service monitors network location , generates email based on events there, similar? how interact sql server database windows service? wcf, fit in. i want make sure looking in right direction. i did same , windows service far better web service in specific case. you cannot automatically monitor using web service; must have process (usually windows service) query webservice trigger it's execution. by way, since monitoring database, send email sql server trigger , since doing in on condi...

How to generate custom response for REST API with Ruby on Rails? -

i'm implementing rest api in rails 3. allow json , xml response formats. the default respond_with works fine long 1 wants requested resource returned, e.g.: def show respond_with user.find(params[:id]) end /users/30.xml <?xml version="1.0" encoding="utf-8"?> <user> <birthday type="date">2010-01-01</birthday> <company-name>company</company-name> <email>email@test.com</email> <id type="integer">30</id> </user> however, following standardized response: <?xml version="1.0" encoding="utf-8"?> <response> <status> <success type="boolean">true</success> </status> <result> <user> <birthday type="date">2010-01-01</birthday> <company-name>company</company-name> <email>email@test.com</email> <id type=...

search - (VB.net) Find specified text on an entire line (not just beginning characters) in a listbox -

i have listbox each line contains short 3-4 character model number followed tab , product name model number corresponds to. have textbox using search listbox. the code using far works somewhat, not how like. if enter search text highlight results in listbox first characters, there anyway search text of entire line (index) of listbox? right using following: private sub txtsearch_textchanged(byval sender system.object, byval e system.eventargs) handles txtsearch.textchanged listbox.selectedindex = listbox.findstring(txtsearch.text) end sub on assumption line representation tostring() of item in list: listbox.selecteditem.tostring().contains(txtsearch.text)

android - Cannot find package value in AndroidManifest.xml for module -

when compiling android module intelij-idea following error message: cannot find package value in androidmanifest.xml module the hover tell me fill in resources page on settings dialogue. but, have fill in? the manifest file pretty sort (it's library) <manifest android:versioncode='1' android:versionname='0.1' package='com.xxx.datamodel' xmlns:android='http://schemas.android.com/apk/res/android' > <uses-sdk android:minsdkversion='4' android:targetsdkversion='8' ></uses-sdk> </manifest> such error may occur when path androidmanifest.xml file in idea android facet settings configured incorrectly. correcting manifest path should fix problem.

c# split images into smaller blocks -

hey, want user selected how many columns image, image split columns user entered. anyone know how that? yes, can crop using bitmap.clone specifying rectangle want copy.

Android: Debugging Android Applications on a Handset -

i trying debug android aplication on real phone (htc desire). enabled usb debugging on android device. clicked on debug configuration,set deployment target selection mode manual , clicked on debug in android device choiser can't see phone. can please? i assume using eclipse ide. have use idea, experience debugging different. these steps have do: 1- enable usb debugging. ( have enabled it). 2- download htc sync software computer (macbook). 3- close open emulator , connect device computer. 4- start debugging session. i did not device chooser dialog also. surprise phone chosen on emulator.i not know how can personal experience, worth try.

problem with android GPS provider: too many updates -

although set mintime 10 seconds in requestlocatioupdate method still new location in less 1 second. public class gpsactivity extends activity { locationmanager mlocationmanager; textview mtextview; int count; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mtextview = (textview) findviewbyid(r.id.text); count = 0; mlocationmanager = (locationmanager) getsystemservice(location_service); mlocationmanager.requestlocationupdates(locationmanager.gps_provider, 10000, 0,mgpslocationlistener); } handler mhandler = new handler(){ @override public void handlemessage(message msg){ switch(msg.what){ case 1: mtextview.settext("new location count:"+count); } } }; locationlistener mgpslocationlisten...

objective c - Blocks in Obj-C for performSelector: onThread:? -

while wouldn't hard spin own method this, wouldn't efficient as - (void)performselector:(sel)aselector onthread:(nsthread *)thr withobject:(id)arg waituntildone:(bool)wait; is there built-in method blocks? if not, there way can avoid creating object, putting block on it, , passing selector method? wonder if there problems data accessed within block... the blocks equivalent performselector: method cfrunloopperformblock — need reference thread's cfrunloop . have @ apple's documentation function , note caveat in discussion — you'll want call cfrunloopwakeup afterwards block executed right away.

python - google storage acl change on existing object -

im having problems understanding how put headers change acl on exixting object on google storage developers. need manually without boto or other helper libs. what need set object public private , other way around. this example found on the developers guide put /paris.jpg?acl http/1.1 host: travel-maps.commondatastorage.googleapis.com date: mon, 15 feb 2008 21:30:39 gmt content-length: 0 authorization: goog1 googts7c7fup3airvjte:y9gblaeinilfv5zlam9ts= x-goog-acl: private <empty entity body> what not clear me , im stuck how build signature. signature composed by: signature = base64-encoding-of(hmac-sha1(utf-8-encoding-of(yourgooglestoragesecretkey, messagetobesigned))) i dont know header parts should include, exclude, newlines.... compose messagetobesigned. have python sample code doing similar? thank you! first, recommend using the json api google's api client libraries, make make authorization easier in variety of language. second, recommend a...

entity framework 4.1 - Generic Repository With EF 4.1 what is the point -

as dig deeper in dbcontext, dbset , associated interfaces, wondering why need implement separate "generic" repository around these implementations? it looks dbcontext , idbset need , include "unit of work" inside dbcontext. am missing here or seem people enjoy adding layer of dependency no reason. you right. dbcontext implementation of unit of work pattern , idbset implementation of repository pattern. repositories popular , overused. use them because there dozens of articles creating repository entity framework nobody describes challenges related decision. main reasons using repository usually: hide ef upper layer make code better testable the first reason kind of architectonic purity , great idea if make upper layers independent on ef can later on switch other persistence framework. how many times did see such thing in real world? reason makes working ef harder because repository must expose lot of additional features wrapping ef allo...

Fluent Nhibernate table-per-subclass with discriminator strategy -

is there anyway use fluent in order implement table-per-subclass discriminator strategy? of documentation i've seen, use of discriminator tells fluent use table-per-class rather table-per-subclass . i having similar issue. far option have been able think of put property on base class , have set operation protected. class inherits base, sets property in constructor. far have not found better way. in case have class references base class , want query type of subclass in reference , filter on in query found no way apart suggested.

java - How Can I write a Fibonacci sequence, which uses an array? -

here code: class fibonacci { static final int min_index = 1; public static void main (string[] args){ int high = 1; int low = 1; string jel; system.out.println("9: " + high); (int = 8; >= min_index; i--){ if (high % 2 == 0) jel = " *"; else jel = " "; system.out.println(i + ": " + high + jel); high = low + high; low = high - low; } } } i want write program, store fibonacci sequence in array, , write out them. can't write it. can do? don't need "mark them" *. i think answer question (i added handling pessimistic scenarios): public class fibonacci { public static void main(string[] args) { int[] fibmembers = buildfibarray(9); printfibarray(fibmembers); } private static void printfibarray(int[] fibmembers) { (int = 0; < fibmembers.length; i++) ...

c++ - Assert and unused local variable warning in GCC don't mix well? -

i have problem unused local variable warning in gcc. often have code looks this: bool success = foo(); assert(success); this fine debug builds. in release however, assert compiles nothing, , gcc gives me warning. what best way work around this? wrapping bool success = #ifdef not seem nice solution... i define macro specific scenario #ifndef ndebug #define verify(expression) assert(expression) #else #define verify(expression) expression #endif i prefer approach on using local variable because doesn't pollute method values conditionally exist. in general find helpful have 2 sets of macros in projects assertxxx: debug execution verifyxxx: retail + debug execution

windows phone 7 - Making offline database application on WP7 - find the right way -

i need build offline database application on wp7. app simple - it's making orders our clients, translate main server (ms sql). spend days read existing techologies - i'am still confused. right project? sync framework. looking good, understand - provides single tables - no reference beetwen them. references have build on client side. sad. entity framework on server side. , have no clue - can use on client side. there way serialize entity object isolate store, restore it, , continue work it? may can use sync framework, scheme become strange - kinda 1 way.))) working wcf & xml - simple me. lot of code , conversion, in case understand data flow. in other view - have app pure sql-queries. wanna advanced. )))) using ext. databases (siaqodb example). one? siaqodb suppots "sync provider", doesn't support references beetwen objects - have build them myself? gain? don't know. is there way build such apps? point please. if has done offline, u...

Is there an easier way to do this in C#? (null-coalescing type question) -

is there easier way this? string s = i["property"] != null ? "none" : i["property"].tostring(); notice difference between , null-coalesce (??) not-null value (first operand of ?? op) accessed before returning. try following string s = (i["property"] ?? "none").tostring();

syntax error in python function definitions -

sorry if sound complete idiot when asking this, i'm new python. when create function : def load_content(name, colorkey=none, datatype): it tells me there syntax error. can tell, right way write function. said, i'm new. know what's wrong here? you can't have default arguments between non-default arguments def load_content(name, colorkey=none, datatype=none): or def load_content(name, datatype, colorkey=none):

html - how do i use .htaccess to redirect different languages to different pages? -

i'm trying make simple 2-language site, en , th, unfamiliar .htaccess found online tool: http://www.htaccesstools.com/redirection-by-language/ i english browsers go root folder's index.html, , thai browsers subfolder. what got generator is: rewriteengine on rewritecond %{http:accept-language} th [nc] rewriterule .* http://www.mysite.com/th/index.html [r,l] this doesn't work , redirect loop/other error. i've tried changing url on last line relative, doesn't affect it. any help? *to confirm, have 1 .htaccess in root folder only try in .htaccess file: options +followsymlinks -multiviews rewriteengine on rewritecond %{request_uri} !^(/th/index.html|.*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ [nc] rewritecond %{http:accept-language} ^th [nc] rewriterule .* /th/index.html [r,l,qsa,ne]

javascript - Adding KML layer to google map API 3 -

i trying make when user selects things form , hits submit add stuff google map. adding markers works fine , add listening event add polylines works fine also. reason kml file not overlay correctly. not sure doing correctly though. value form echo out correctly know data reaching @ least map function. here code not working: window.onload = function() { // creating object literal containing properties // want pass map var options = { zoom: 5, center: new google.maps.latlng(39.09, -95.71), maptypeid: google.maps.maptypeid.roadmap }; // creating map var map = new google.maps.map(document.getelementbyid('map'), options); // creating latlngbounds object var bounds = new google.maps.latlngbounds(); // creating empty mvcarray var route = new google.maps.mvcarray(); var polyline = new google.maps.polyline({ path: route, strokecolor: ...

drupal - Limiting lines and char count per line in a textarea with jQuery -

i have drupal webform textarea limit line , character per line when option selected, related textarea. example, user picks option a, textarea should limited 2 lines, , 14 characters per line. option b, 3 lines, 18 characters. on , forth. i cannot seem interact webform through hook_form_alter add attributes textarea javascript callback. assume first issue. able jquery however. $(document).ready(function() { $('#mytext').keyup(function() { var v = $(this).val(); var vl = v.replace(/(\r\n|\n|\r)/gm, "").length; if (vl == 0) { count = 1; } if (parseint(vl / count) == chars) { $(this).val(v + '\n'); count++; } if (count > 3) { var text = $('#mytext').val(); var lines = text.split('\n'); var test = implode('\n', lines); alert(test); } }); }); also, how can count lines , characters per line, , prevent typing if limits met? i borrowed part ...

java - Generic class to array of generics of same generic type -

i have method signature like public <t extends someclass> t[] findall(class<t> oclass, string condition) but i'm not sure how can create t[] type class<t> . i've tried using collection<t> cannot cast (t[]) collection.toarray() , array.newinstance(class<?>, int) asks array class (i.e. t[] ) already, of no use , redundant. also, obvisously, new t[n] not work. i presume it's easy, i'm numb solution right :) thanks. newinstance not ask array class, asks component type. work fine, albeit usual problems unchecked casts , generic arrays. t[] myarr = (t[]) array.newinstance(oclass, length); but why mix arrays , generics @ all? it'll lead headaches. use collections api, list .

iphone - Setting rootViewController for ipad 3.2 doesnt work -

i did simple navigationbased app. works on iphone well, doesnt work on ipad 3.2 simulator , device. in applicationdidfinish event; mainviewcontroller *viewcontroller = [[mainviewcontroller alloc] initwithnibname:@"mainview" bundle:nil]; [self.navigationcontroller pushviewcontroller:viewcontroller animated:no]; self.window.rootviewcontroller = self.navigationcontroller; [viewcontroller release]; it says line: self.window.rootviewcontroller = self.navigationcontroller; [uiwindow setrootviewcontroller:]: unrecognized selector sent instance 0x4c22dd0 but works on ipad 4.2 , over. how can solve ipad 3.2? uiwindow did not have rootviewcontroller property in ios < 4.0. therefore, need check version (google it) , either set rootviewcontroller, or add navigationcontroller's view subview window below, based on version user running.: [self.window addsubview:self.navigationcontroller.view]; quick edit: check if can use rootviewcontroller property, c...

html - Relative z-index? -

i've got "dialog" widget pops z-index of 100. when create popup (a floating div), appears underneath dialog widget, because haven't explicitly set z-index on new popup. the structure ends looking like <div id="dialogbox" style="z-index: 100"> <div> <div id="widgetthatcausesthepopup" /> </div> </div> <div id="popuphiddenbehindthedialog" /> i'm using gwt generate html. there can arbitrary levels of nesting between dialogbox , widgetthatcausesthepopup, , actual z-index may arbitrary well. how can ensure new div shown in front of dialogbox? the natural css solution to: make sure, "dialogbox" gets stacking context. can done setting z-index else auto , and additionally position either relative , absolute or fixed . then add popup child "dialogbox". if isn't yet, can move in dom. in case, popup doesn't need z-index @...

javascript - XMLSerializer skips element values -

i've got javascript code serializes entire dom tree follows: (new xmlserializer()).serializetostring(document) but different i'd expect. specifically, html source, not values of various input/selects. if objects inserted dom, objects, again, no values. however, if walk through dom in javascript other purpose, have access every input's value. what gives? obviously, i'm missing basic concept, i've no idea what. can full dom html/xml formatted string, with input/select values? if so, how? this due fact dom form input maintains value property (which reflects current state) separately value attribute (which represents initial value of input , used xmlserializer serialize dom). i've written several times on stack overflow. here's recent example: jquery .attr('value', 'new_value') not working?

mongodb - mongoose node.js, query with $lt and $gt not working -

i want pupils last mark between 15 , 20. so, perform following query in mongodb using mongoose: models working fine (all other queries ok). pupils.find({"marks[-1].value": {'$lt' : 20 }, "marks[-1].value" : { '$gt' : 15 }}, function(err, things){ this not working, there missed ? * update * i found like: pupils.find({ "marks[-1].value": {$gt : 15, $lt : 20}}); but not work either. there way last mark of marks array in case ? lets consider pupils collection: pupils { _id, marks(integer), latestmark(int) } i suggest add latest mark pupil document(as can see @ document above), , update each time when adding new mark nested collection. able query on this: db.pupils.find({ "latestmark": {$gt : 15, $lt : 20}}); also can query latest mark using $where , care because: javascript executes more native operators, flexible

x11 - Using Xnest between Mac OS X (Snow Leopard) and Ubuntu 10.10 -

i installed ubuntu 10.10 desktop on system development work. run x server environment on macbook instead of keyboard hopping (the graphics system on ubuntu box not great). poking around on web uncovered following command can run terminal in mac os x: /usr/x11/bin/xnest -geometry 1280x900 :1 & display=:1 ssh -x -y grog@ubuntusys gnome-session note have ssh set authentication happens automatically. this seems work great -- ubuntu desktop appears on mac os x screen! (it seems smart enough start x11 if isn't running already). if try open program, dies out. close. any suggestions appreciated. update: answer below provides tutorial link learned how basic x forwarding. can x terminal window on mac this: ssh -x -y username@targetsystem then can start x applications run on remote system windows on mac x server. issue have want start gnome desktop session: gnome-session but problem there session takes on whole mac desktop. cannot resize or move it. worse, ...

Page content to not scroll off page (no iframe) -

it’s difficult me word question not know correct terminology. i’m trying make website when scroll main content, not scroll off page. want main content end somewhere in middle of page not cover “fixed” background image. not want iframe. in other words, it'll iframe, should controlled main scroll bar. anyway, hope made sense. i'd appreciate suggestions. can use 2 <div> s cover top , bottom part text go underneath them. +----------------+ |+--------------+| || top || |+--------------+| | text | | text | |+--------------+| || bottom || |+--------------+| +----------------+ on z-index , top , bottom on main layer, , positioned fixed top-left corner , bottom-left corner. here: http://jsfiddle.net/fe2wg/3/

php - Is a cursor the only way to do this? -

i'm in process of churning through raw data have. data in mysql database. data lists, in millisecond-by-millisecond format, of number of possible 'events' happening. has few columns: id - unique identifier row event - indicates event occurring what basic information regarding these data. specifically, i'd create table has: the id event starts the id event ends a new id indexing events , occurrence, column detailing event happening. i know easy deal using php, using simple loop through records, i'm trying push boundaries of mysql knowledge bit here (it may dangerous, know!!). so, question this: cursor best thing use this? ask because events can occur multiple times, doing grouping event type won't work - or it? i'm wondering if there clever way of dealing have missed, without needing go through each row sequentially. thanks! to demonstrate commented earlier about, have following table: event_log id int not null auto_incr...

Block wireless interface and get internet connection through gateway in android -

i working in application , in part of need prevent android phone requesting internet connection wireless interface or 3g , requesting phone note: android phones connected ad-hoc network , each node can send/receive packets each other , want share internet connection between them providing 1 node internet connection(gateway node), if others android phones want internet access, directly contact gateway my problem how prevent android phone request internet access network interface , request gateway.

java - sorting and searching an arraylist -

i've looked @ posts on here sorting , searching can't seem arraylist sort or search using collections.sort(myarraylist); the data stored in arraylist stored when user enters data in textfields in gui. have used gettext store data (that user enters jtextfields) in arraylist. the user should able enter firstname or surname a string searchstring = joptionpane.showinputdialog("enter name"); the sort should done after user adds each new contact arraylist surname. so question is: how can sort arraylist? how can search arraylist? please can advise me how proceed stuck!! the arraylist myarraylist holding contacts, assume has @ least 2 string fields (first , last name). if comparing 2 contacts, how decide 1 goes first on sorted list? my guess have sort of contact type holding of these fields. what need implement comparable interface contact type, sorting algorithm can figure out of 2 given contacts comes first in list. where declare...

How to check focused TextBox in vb.net winforms? -

i have multiple textbox in form. how know textbox cursor is? trying this: if textbox2.focus() = true messagebox.show("its in two") elseif textbox3.focus = true messagebox.show("its in three") end if but think not working. obviously, not work if calling code in button_click because when click button focus goes button have clicked. you can 2 things: make combined focus event textboxes , check sender object. private sub textbox_focus(byval sender system.object, byval e system.eventargs) handles textbox2.enter, textbox3.enter dim currtextbox textbox = sender if currtextbox.equals(textbox2) messagebox.show("it's in two") elseif currtextbox.equals(textbox3) messagebox.show("it's in three") end if end sub or take global string variable, , set value @ each textbox_focus event, check string value in button click event. dim str string pri...

Automatically reconnect a Haskell Network connection in an idiomatic way -

i've worked way through don stewart's roll own irc bot tutorial , , playing around extensions it. current code same "the monadic, stateful, exception-handling bot in glory"; it's bit long paste here unless requests it. being comcast subscriber, it's particularly important bot able reconnect after periods of poor connectivity. approach time ping requests server, , if goes without seeing ping time, try reconnecting. so far, best solution i've found wrap hgetline in listen loop system.timeout.timeout . however, seems require defining custom exception catch in main can call main again, rather return () . seems quite fragile specify timeout value each individual hgetline . is there better solution, perhaps wraps io a bracket , catch entire main can handle network timeouts without overhead of new exception type? how running separate thread performs reading , writing , takes care of periodically reconnecting handle? something this ...

Can Ruby on Rails be a game server? -

i want make multiplayer game. so, should make server socket , loop forever accept incoming client's request. since don't want browser browse php website that, want server auto execute server socket once. can use ruby on rails that? rails made it. not best tool particular job. http request/response protocol , sending out-of-band data tricky, need use cometd or new websockets, , have clients listening or polling data. i think using erlang better tool, or if more comfortable ruby use ruby server (not rails) using eventmachine.

Why does Google stipulate that you specify whether you are using a sensor in the maps API? -

when retrieving google maps api javascript, google requires specify whether using sensor or not application (e.g. sensor=false ). why this? matter of data collection google can approximate how api being used, or modify returned in instances? per api , sensor option determine if using gps-enabled / location tracking device. sensor=false maps more light-weight since don't handle additional functionality. mentioned, sensor=true maps handle device specific location tracking, etc.

debugging - Dynamic Random number glitch -

for project, http://www.swfcabin.com/swf-files/1302575829.swf , number doesn't appear when "scratch" top part off. code being used (yes it's little nooby, i'm new @ this) { zoom = random (20) +1; gotoandplay(2); } how can make number appears every time? thanks! -zach ps: actionscript2 use floor method , multiplication: math.floor(math.random() * 20) + 1;

need help in macros and access DB with external oracle DB connectivity? -

in existing microsoft access database have table inputvalue mapped oracle db,i hope of macros getting purged access db oracle db. here question there anyway identify existing mapping between oracle db field access db field? please on this. using vba: dim fld dao.field dim tdf tabledef dim db database set db = currentdb each tdf in db.tabledefs ''linked table if len(tdf.connect) > 0 debug.print tdf.connect ''local name debug.print tdf.name ''source name debug.print tdf.sourcetablename each fld in tdf.fields ''local name debug.print fld.name ''source name debug.print fld.sourcefield next end if next

keypress - capturing keys pressed on the keyboard in mfc application -

i new mfc. have created mfc application, trying capture if character keys pressed. have added on_wm_char message map , have written onchar function perform function when particular character pressed. but if character pressed, not reach onchar function. what class's onchar have overloaded? such input should typically handled in view class.

haskell - arising from a use of `Control.Exception.catch' -

when load haskell file, has error module repl(repl(..), repl) import qualified control.exception e import system.console.readline(readline, addhistory) data repl s = repl { repl_init :: io (string, s), -- prompt , initial state repl_eval :: s -> string -> io (bool, s), -- quit flag , new state repl_exit :: s -> io () } repl :: repl s -> io () repl p = (prompt, state) <- repl_init p let loop s = (do mline <- readline prompt case mline of nothing -> loop s line -> (quit, s') <- repl_eval p s line if quit repl_exit p s' else addhistory line loop s' ) e.catch undefined (\(e :: e.someexception) -> putstrln "handled exception!" ) loop state repl.hs:21:5: couldn't match expected type `io (maybe string)' against inferred type `t -> maybe string'...

nhibernate disable unicode -

in our company using nhibernate our default mapper. write queries using nhibernate criteria - noticed parameters send unicode this: exec sp_executesql n'select this_.id id23_0_, this_.nazwa nazwa23_0_, this_.opis opis23_0_, this_.typgrupy typgrupy23_0_, this_.czydystrybuowana czydystr5_23_0_, this_.czyaktywna czyaktywna23_0_ grupa this_ this_.nazwa @p0',n'@p0 nvarchar(50)',@p0=n'%something%' this not desired behavior. possible disable unicode in nhibernate queries? thanks romek i guess have match mapping files use ansi string instead of unicode whcih default value. check this mapping table between database , nhibernate, , sections between 5.2.2 , 5.4 on nhibernate - basic o/r mapping , notice type attribute guess can explicit define ansistring in there. hope help.

assembly - Question about ASM execution flow -

i'm not sure how interpret asm execution flow. until now, of files i've looked @ have had explicit jumps (intel x86 at&t syntax, i.e jmp or jl) labels within asm file. my question: happens when reach end of label without explicit jump other label. execution continue next label? example: foo: opcodes ... nextlablel: moreopcodes ... after executing opcodes under 'foo' label, assembler move onto 'nextlablel'? thanks in advance! the labels non existent actual code, yes, if there no branch, code execute naturally. assembler continue code, ignoring labels. labels there convenient way branching after jmp, je , likes. if code did not have branches, still have many labels wanted. not , bad practice, illustrates idea not cause problems natural code flow.

uitextview - Reading Arabic text from a UTF-8 text file? -

dear all, have strange (stupid) problem when trying read "arabic text" given file. let assume have text file called text.txt encoded utf-8 , looks (arabic text righttoleft): :xxx xxxx xx xxx .xxx, xxxxxxx xxxxx xxx when trying read text.txt in xcode using uitextview *about; about.textalignment = uitextalignmentright; nsstring *textfilepath = [[nsbundle mainbundle] pathforresource:@"text" oftype:@"txt"]; nsstring *filecontents = [nsstring stringwithcontentsoffile:textfilepath encoding:nsutf8stringencoding error:nil]; about.text = filecontents; nslog(@"the text is: \n %@",about.text); which believe right way!!! shows on iphone simulator , on device this: xxx xxxx xx xxx: xxx, xxxxxxx xxxxx x...

windows - How to Install Driver with a cat file? -

i have kernel driver. when installing on 32 bit systems , windows xp , below, had no problem , used setupcopyoeminf, 64 bit drivers required signed. have signed , need have cat file driver copied somewhere on computer, , method of install doesn't work. how should install it? edit: clarified question. in windows vista , windows 7 there new utility handling drivers setup call pnputil . handles kind of work. copy driver relevant files(*.inf, *.cat, *.sys) directory on target computer , use pnputil -i -a <infname>.inf note: need in administrator context use tool.

svn - When I try to checkout a project I get Unusable URI: it does not refer to this repository -

today i'm trying checkout svn project, , when go repo url in tortoisesvn see project structure online, when use checkout get: unusable uri: not refer repository and nothing downloaded. any point?¿ thanks in advance, tomás garcía i'm guessing url you're using try checkout url of web viewer. hosted projects offer 2 urls: 1 browsing repository webbrowser offers syntax highlighting , other stuff, , url repository. to checkout, have find url repository.

java - Scheduling a persistent entity -

let's have db entity cronexpression field: @entity @table(name = "job") public class job { ... private cronexpression cronexpression; } what best approach put onto quartz schedule? use spring3 , hibernate. schedule in dao - anytime job created or updated - need schedule existed job @ application start-up.. thanks advices! you need dao/repository cronexpression storage. create in memory dao @repository public class jobentitydao { public list<jobentity> findall() { list<jobentity> list = new arraylist<jobentity>(); jobentity job1 = new jobentity("0 0 12 * * ?"); jobentity job2 = new jobentity("0 15 10 ? * *"); jobentity job3 = new jobentity("0 15 10 * * ?"); list.add(job1); list.add(job2); list.add(job3); return list; } } and component create quartz scheduler based on cronexpression. call quartzexecutor @service public...

ruby on rails 3 - Previous user picked up with auth_token login in Devise -

here's scenario. first, log in alice: http://localhost:3000/?auth_token=emxbk8cujma1etzfmigb then, without logging out, log in bob: http://localhost:3000?auth_token=z9ui7cw_xcnomgwoeueh what happens is, after second request, i'm still logged in alice, not bob. if http://localhost:3000/users/sign_out in between 2 auth_token logins, everything's ok. without sign_out, bob can't login using token. is bug, or way things should due security issues i'm ignorant of? can behavior overriden through hooks? devise's token_authenticatable strategy login path. sending user's authentication_token devise log in user , set session, logging in via web would. not supposed act api key, required sent on every request , knowledge of request disappears once server responds. take @ issue here more information: https://github.com/plataformatec/devise/issues/300 @jschorr's answer work if wish use more api key, should aware original issue not persist prev...

Putting applets into a HTML, but how? -

i wrote applet called "idrawapplet.java" , html supposed contain applet. somehow when run html says can't find java-class. "dynamic-web-project". has "webcontent"-folder contains both, html , java-class. as see tried insert applet in 2 different ways. putting in "applet"-tag , "object"-tag (as suggested) on selfhtml.org: <!-- <applet code= "idrawapplet.class" codebase= "../applets" width= 320 height= 180></applet> --> <object classid="java:idrawapplet.class" codebase="../applets" width="800" height="600"></object> thanks in advance... the proper way (which html5 way) embed java applet is: <object type="application/x-java-applet" width="320" height="180"> <param name="code" value="myjavaclass"> fallback content ...

Sort an array based on an index array in C -

i trying sort many arrays in parallel. sort 1 array qsort , return int array specifies indices of original positions. int array, need sort other arrays. array 1: zzz yyy def abc cde xxx after sorting, index array , sorted array:idx position array 3 : abc 4 : cde 2 : def 5 : xxx 1 : yyy 0 : zzz now based on index array, need sort array a b c d e f so becomes d e c f b thanks lot for (i=0; < 6; ++i) sortedarray[indexarray[i]] = anotherarray[i];

List of all imports in python 3 -

how find out list of available imports in python 3 via program? tried @ first, couldn't understand returned import sys sys.modules i think isn't way, although struck mind first. searched web , found http://effbot.org/librarybook/core-modules-index.htm can tell me whether correct or not? from http://docs.python.org/library/sys.html (a place documentation on python stdlib) sys.builtin_module_names is tuple (a bit immutable anonymous structs) of strings giving names of modules compiled python interpreter. sys.modules this dictionary maps module names modules (module objects) have been loaded. can manipulated force reloading of modules , other tricks. note removing module dictionary not same calling reload() on corresponding module object. so modules dictionary (a mapping of module names actual module objects). names type sys.modules.keys() although isn't usefull.

vb.net - download a file to project resources -

i use visual basic 2008 . hello possible download file directly project resources, or import file resources on running vb 2008 application. for example have : www.example.com/file.ext , want download it, not c:\ or c:\ drives, my.resources.file ... possible? thank you this isn’t possible. resources in program fixed : once program running, cannot modify resources. apart can use webclient.downloaddata method download data variable without saving disc.

database - Has Soundex been improved? -

soundex seems implemented in dbms's, have there been algorithmic improvements definitively better current implementation of soundex? yes. wikipedia points out, there's metaphone , double metaphone, nysiis , more. keep in mind these works english, has own particular problems orthography. it's hardly needed spanish, , doesn't make sense chinese/mandarin.

java - Why do I get a "Premature End of File" error when performing my XSLT transform? -

getting line #-1; column #-1; premature end of file error while xslt transform xsl : <xsl:template match="/"> <html> <head> <title>real's howto</title> </head> <body> <table border="1"> <tr> <th>titleamit</th> <th>link</th> </tr> <xsl:for-each select="mx:feed/mx:entry"> <tr> <td> <xsl:value-of select="mx:title" /> </td> <td> <xsl:value-of select="mx:published" /> </td> </tr> </xsl:for-each> </table> </body> ...

sql server 2005 - how to take out the average in a single query and also checking the average greater than certain value and arranging in ascending order -

display average basic salary each department , include employees having more 20 years age? , display departments average basic salary more 5000? sort output in ascending order of average basic salary? plz tell me single query statement thanks, churchill this may help: select t.dept,t.salary (select dept,avg(salary) salary employee age > 20 group dept)t t.salary > 5000 order t.salary asc

.net - Enabling Ajax on Sharepoint -

what have? i have installed windows sharepoint services 3.0 on pc work on locally. deployed external web part loads rss feeds , shows posts' titles, links , descriptions ( rss advanced reader web part sharepoint ). what problem facing? on machine wss 3.0, web part not work had error message "ajax not enabled." has faced problems , found solutions? web.config entries enabling ajax sharepoint 2007

visual studio 2010 - VS2010 - How can two or more people edit a use-case file at the same time? -

i have solution written in vs2010. have modeling project in solution use case. want allow 2 or more people able edit file @ same time. also, don't want people overwrite each other. instead, i'd vs2010 merge changes. possible in vs2010? it's not advisable multiple people work on same file @ same time, if use team foundation server version control, take @ topic managing models , graphs under version control : merging changes in model files , diagrams after more 1 user has worked on model concurrently, team foundation version control prompt merge changes in model files. working on separate projects described in previous preceding sections avoid of merges. ordinarily, remaining conflicts can safely merged automatically. following kinds of changes should cause no difficulty: types of lifelines. when add lifeline interaction (sequence diagram), type stored in root model, unless have created lifeline existing type. new activities , interactions stored in root...

java - What is a good algorithm for mapping random (barcode values) numbers to an String in a collection? -

say application has finite number of "stuff", in case items in game purposes of question i'll use strings. say have 5 strings : james dave john steve jack there set list of them, increase list in future. question : algorithm can use, go random number (generated barcode) 1 of values above? for example, if have value 4523542354254, algorithm use map onto dave ? if have same number again, need make sure maps dave , not else each time. one option did consider taking last digit of barcode , using 0-9 map onto 10 items, not future proof if added 11th item. any suggestions? with clarification "if have same number again, need make sure maps dave , not else each time." applies long set of strings doesn't change. simplest maverik says, name = names[barcode % names.length]; a java long big enough store upc barcode, int isn't, assume here barcode long . note last digit of upc barcode base-11, can x . leave exercise reader h...