Posts

Showing posts from February, 2010

tsql - How to refer to a variable create in the course of executing a query in T-SQL, in the WHERE clause? -

what title says, really. if select [statement] whatever, why can't refer whatever column in body of clause? there kind of workaround? it's driving me crazy. as far i'm aware, can't directly in sql server. if have use column alias in clause, can this, seems overkill use subquery alias: select * ( select [yourcolumn] youralias, etc... whatever ) yoursubquery youralias > 2 you're better off using contents of original column in clause.

windows phone 7 - Make the PhoneApplicationService.Current.State Dictionary Observable? -

in windows phone 7 app, phoneapplicationservice.current.state object declared idictionary, , implemented dictionary. hoping notified when state changes occur. (i realise build own state collection somewhere else , whatever want, i'm retrofitting existing code.) is there way state object set observabledictionary instead of dictionary, can attach , notified when collection changes? i'm guessing answer 'no' want check haven't missed :) thanks, john you can't change existing implementation, create wrapper class implements iobservable uses phoneapplicationservice.current.state internally. way, wouldn't have build complete state persistence soution , implement observabledictionary best meets needs.

php - Multi Delete using checkbox -

i learning cakephp , i've been trying delete multiple (checked) record using checkbox, still not success. here's jquery : var ids = []; $(':checkbox:checked').each(function(index){ ids[index] = $(this).val();; alert(ids[index]); }); //alert(ids); var formdata = $(this).parents('form').serialize(); $.ajax({ type: "post", url: "tickets/multi_delete", data:"id="+ids, success: function() { alert('record has been delete'); }, error: function(xmlhttprequest, textstatus, errorthrown) { alert(xmlhttprequest); alert(textstatus); alert(errorthrown); } }); and here code in controller : function multi_delete() { $delrec=$_get['id']; //debuger::dump($del_rec); foreach ($delrec $id) { $sql="delete tickets id=".$id; $this->ticket->query($sql); }; } anybody me please...

asp.net - jQuery dialog serving multiple button's click event handller -

i have scenario where... 1.) have created div dropdown list , ok, cancel button 2.) on document ready - registering div created on step 1 jquery dialog 3.) on javascript button click - opening dialog box. 4.) now, problem - jquery dialogbox have created, needs used other button clicks on same page. now, div's (which dialog @ runtime using jquery) ok button click engaged javascript function (button1 click) , can not associate other button's click events - stuck here , have no clues or hit resolve this. anyone have faced issue in asp.net, jquery earlier? can provide guidance? why cant associate event? buttons have different id. it? $('#button1').click(function() { alert('handler button 1 .click() called.'); }); $('#button2').click(function() { alert('handler button 2 .click() called.'); }); is not possible in case.?

associations - How can I count and filter on an associated record in Rails? -

company has_many contacts company has_many contactemails :through => :contacts contactemail belongs_to contact contact belongs_to company contact has_many contactemails for specific instance of company, how can find contactemails , filter on attribute, such date_sent? i tried company.contactemails don't think can make association. you want use named scope this. works rails 2.3, wouldn't change rails 3. i haven't tested it, should work. conditions may need tweaked proper date comparison. contactemail < activerecord::base named_scope :by_date_sent, lambda {|d| { :conditions => ["date_sent = ?", d]}} end @company.contact_emails.by_date_sent(date.today)

C#/MVVM: Enable/Disable Buttons based on another control's property -

say have tab control displays data of various types, eg editortabviewmodel , previewtabviewmodel both inheriting tabviewmodel . implementation similar tutorial on msdn i want enable buttons depending on active tab, whether editortabviewmodel or previewtabviewmodel . how can achieve this? update public icommand editorcommand { { if (_editorcommand == null) { _editorcommand = new relaycommand(() => { messagebox.show("editor"); }, () => { var enabled = true; var viewsource = collectionviewsource.getdefaultview(tabs); viewsource.currentchanged += (o, e) => { if (viewsource.currentitem editortabviewmodel) { enabled = false; } }; return enabled; }); } return _editorcommand; ...

Ruby 1.9.2, Rails 3 Console: Not enough memory? -

i upgraded rails 3, , in last 24 hours have started see new error message popping in console: errno::enomem: not enough space - <stdout> c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:311:in `write' c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:311:in `printf' c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:311:in `output_value' c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:160:in `block (2 levels) in eval_input' c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:273:in `signal_status' c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input' c:/sanj/ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement' c:/sanj/ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop' c:/sanj/ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement' c:/sanj/ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch' c:/sanj/ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement' c:/sanj/ruby192/lib/ruby/1.9.1/irb.rb:1...

Timezone offsets (and st/dst changes) in MySQL / PHP -

basically have site allows stores store open/close times. now, i'm trying add feature of giving visitors ability see if store closed. i understand can run query like: select * `store_hours` time(now()) between `opens` , `closes` ... , query works , retrieves stores open. however, @ first query didn't put consideration store's timezone. so.. decided store store's open/close times conversion utc attached: id | store_id | opens | closes | utc_opens | utc_closes now can query so: select * `store_hours` time(now()) between `utc_opens` , `utc_closes` so can global list of how many stores open , doesn't matter are. now came problem. through php, did add offset timestamp: date('h:i', strtotime($values['closes']) + $offset) then started thinking pacific standard time , daylight savings time. i want add open/close feature , become huge part of system. it's lose out on lot of income if i'm off hour. i've nev...

delphi - "Method '%s' hides virtual method of base type '%s'". What's really being hidden? -

after having read ian boyd 's constructor series questions ( 1 , 2 , 3 , 4 ), realize don't quite grasp literal meaning on what's being hidden. i know (correct me if i'm wrong) override 's sole purpose able have polymorphic behavior, run-time can resolve method depending on actual type of instance - opposed declared type. consider following code: type tbase = class procedure proc1; virtual; procedure proc2; virtual; end; tchild = class(tbase) procedure proc1; override; procedure proc2; // <- [dcc warning] end; procedure tbase.proc1; begin writeln('base.proc1'); end; procedure tbase.proc2; begin writeln('base.proc2'); end; procedure tchild.proc1; begin inherited proc1; writeln('child.proc1'); end; procedure tchild.proc2; begin inherited proc2; writeln('child.proc2'); end; var base: tbase; begin base := tchild.create; base.proc1; writeln; base.proc2; base.free; ...

java - Search for a word in a String -

if looking particular word inside string, example, in string "how you" looking "are". regular indexof() work faster , better or regex match() string teststr = "how you"; string lookup = "are"; //method1 if (teststr.indexof(lookup) != -1) { system.out.println("found!"); } //or //method 2 if (teststr.match(".*"+lookup+".*")) { system.out.println("found!"); } which of 2 methods above better way of looking string inside string? or there better alternative? ivard if don't care whether it's entire word you're matching, indexof() lot faster. if, on other hand, need able differentiate between are , harebrained , aren't etc., need regex: \bare\b match are entire word ( \\bare\\b in java). \b word boundary anchor, , matches empty space between alphanumeric character (letter, digit, or underscore) , non-alphanumeric character. caveat: means if search term isn't...

set flash mode camera.parameters android 1.5 -

i'm trying use camera in android app using 1.5 api. want camera flash every picture. however, when looked @ api camera.parameters, setflashmode() method supported 2.0 , higher. yet cliq xt, runs 1.5, has flash can set in menu - take mean there way 1.5 api, though unable find it. does know how set flash mode using 1.5 api? you can use following code set flash in older versions of api: parameters params = camera.getparameters(); params.set("flash-mode", "on"); camera.setparameters(params); i guessed on values send .set method, tested , turns on flash.

c++ cli - is it possible to return two vectors from a function? -

im trying merge sort in cpp on vector called x, contains x coordinates. mergesort sorts x coordinates, supposed move corresponding elements in vector called y, containing y coordinates. problem dont know how (or if can) return both resulting vectors merge function. alternatively if easier implement use slower sort method. no, cannot return 2 results method in example. vector<int>, vector<int> merge_sort(); what can pass 2 vectors reference function , resultant mergesorted vector affects 2 vectors...e.g void merge_sort(vector<int>& x, vector<int>& y); ultimately, can @ joshd mentioned , create struct called point , merge sort vector of point struct instead.

asp.net - DropdownList reset not working in Updatepanel on Submit button -

i have dropdown list in updatepanel. have fill dropdown on client event through javascript calls __dopostback of updatepanel , calls load event. problem when submit form updatepanel_load event execute again , again reset dropdownlist causes loss of selectedvalue in dropdown. <asp:updatepanel id="updatepanel3" runat="server" onload="updatepanel3_load" updatemode="conditional"> <contenttemplate> <asp:dropdownlist id="ddlitems" runat="server" cssclass="dropdown"> </asp:dropdownlist> </contenttemplate> </asp:updatepanel> on page load dropdown empty .... no function fill it. now problem when ever fill dropdown through load of upatepanel, updatepanel load event execute when submit page. solution of javascript due table , on selection of table row item fills dropdownlist __dopostback of updatepanel. i have button op...

java - JSF Handle served-side exception in browser with A4J -

can a4j handle situation in ajax call server ends exception? handle mean can instance present user dialog box stating exception has occured? default behaviour of a4j in presence of server side exception nothing misleading. yes. you can a4j : add javascript on page: a4j.ajax.onerror = function(req, status, message){ window.alert("custom onerror handler "+message); }

.net - How to measure the time an application takes to start up in C#? -

i have gui application takes while load plugins, before ready used user. i want write c# program measure time taken application start up. thought process.waitforinputidle() method trick, doesn't. exits process started. what have this: datetime starttime = datetime.now; process myappundertest = process.start("c:\\program files\\my app\app_under_test.ext"); myappundertest.waitforinputidle(); //wait until application idle. datetime endtime = datetime.now; int elapsedtimeinsecs = endtime.subtract(starttime).seconds; console.writeline("start time (sec): {0}", elapsedtimeinsecs); how can start time intend? i it's difficult. how classify application loaded , ready? if there way (which don't think so) easy. but if app loading signals in way (ipc/files/network), can capture signal , app loaded. in case, can use timer/stopwatch/performance counter. if can modify timed app, can achieve in various ways. if external you, doubt there ...

.net - Database Connection in VB.NET Windows Forms -

i have problem connecting server machine. when try connecting machine following code, works fine: 'connstring = "data source = .\sqlexpress;" & _ '"initial catalog = one;" & _ '"integrated security = sspi" try conn = new sqlconnection(connstring) conn.open() messagebox.show("connection successful") catch ex exception messagebox.show(ex.message) end try but when try connected machine sql server 2000 installed, timeout message. code follows: connstring = "server = xxx.xxx.xxx.xxx;" & _ "initial catalog = one;user id=xxxx; password=xxxxx;" & _ "integrated security = sspi" try conn = new sqlconnection(connstring) conn.open() messagebox.show("connection successful") catch ex exception messagebox.show(ex.message) end try can please me on issue? imports system.io imports sy...

normalization - Normalize the following scenario -

a college keeps details student , various modules student has studied. these details compromise registration number, name, address, tutor number, tutor name, diploma code, diploma name , repeating fields module code , module name , result. normalize relation. there's quite few resource, this , this - once understand it, it'd simple... think in terms of sets of data , won't go far wrong hint - tables obvious (answers in question), need table links 2 of them together

java - Can you programmatically detect white noise? -

the dell streak has been discovered have fm radio has crude controls. 'scanning' unavailable default, question know how, using java on android, 1 might 'listen' fm radio iterate through frequency range detecting white noise (or signal) act normal radio's seek function? i have done practical work on specific area, recommend (if have little time it) try little experimentation before resorting fft'ing. pcm stream can interpreted complexely , subtly (as per high quality filtering , resampling) can practically treated many purposes path of wiggly line. white noise unpredictable shaking of line, never-the-less quite continuous in intensity (rms, absolute mean..) acoustic content recurrent wiggling , occasional surprises (jumps, leaps) :] non-noise content of signal may estimated performing quick calculations on running window of pcm stream. for example, noise tend have higher value absolute integral of derivative, non-noise. think academic way of s...

r - Create a PDF table -

is there way produce pdf of table r in same way produce plot (ie pdf() or ggsave())? realize there ways other programs (using sweave etc.), produce r. yes there can place text graphs , hence pdf devices. the nicest wrapper may textplot() function in greg warnes' trusted gplots package. below beginning of examples section of page: # show r version information textplot(version) # show alphabet single string textplot( paste(letters[1:26], collapse=" ") ) # show alphabet matrix textplot( matrix(letters[1:26], ncol=2)) ### make nice 4 way display 2 plots , 2 text summaries data(iris) par(mfrow=c(2,2)) plot( sepal.length ~ species, data=iris, border="blue", col="cyan", main="boxplot of sepal length species" ) plotmeans(sepal.length ~ species, data=iris, barwidth=2, connect=false, main="means , 95\% confidence intervals\nof sepal length species") info <- sapply(split(iris$sepal.length,...

javascript - How can I find caller from inner function? -

<input type='button' id='btn' value='click' /> <script type="text/javascript"> var jobject = { bind : function(){ var o = document.getelementbyid('btn'); o.onclick = function(){ // how can find caller here ? } } }; jobject.bind(); </script> update i read trick here - http://www.mennovanslooten.nl/blog/post/62 and can jobject inside inner function. <input type='button' id='btn' value='click' /> <script type="text/javascript"> var jobject = { bind : function(){ var o = document.getelementbyid('btn'); o.onclick = function(jobj){ // 1. add return function(){ // 3. wrap return function(){ ... } alert(jobj); // 4. can jobject here. } }(this); // 2. , } }; jobject.bind(); </script> inside...

bash - Kill all processes launched inside an xterm when exit -

i'm using cygwin start servers. each server launched inside xterm bunch of command one: xterm -e $my_cmd /c & is there easy way kill launched children (xterm , running commands) in row ? i want able kill particular launched command when close parent xterm. someone knows how perform ? killall xterm ? command in psmisc package. xterm notify child process sighup ("hangup") before exits. cause child process exit too, although servers interpret signal differently.

Android 2.2.1 Nexus one : Voice recognition problem -

hi folks, i have strange problem voice recognition on google nexus 1 phone have firmware:2.2.1.voice recognition gives multiple interpretations of spoken word when speak "hello" voice recognition, results received "hello, hotels, photos, fomdem, honda" expected come "hello" same things works fine on firmware 2.1 give satisfactory result. whats has done avoid issue.any suggestions helpful best regards, vinayak i can't explain differnet behavior different versions, have looked @ http://developer.android.com/reference/android/speech/recognizerintent.html#extra_max_results ? the intent accepts max results parameter tells recognizer how many candidate strings return client. typically in speech recognition, client may need provide user disambiguation step (like "did "hello" or "hotel"?". if want candidate, set extra_max_results 1.

arraylist - java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 -

how can fix outofboundsexception ? here code using: resultset rstagcheck = stmt.executequery( "select parking.xkrprmt.xkrprmt_pidm, parking.xkrprmt.xkrprmt_status, parking.xkrprmt.xkrprmt_expire_yr, parking.xkrprmt.xkrprmt_tag parking.xkrprmt xkrprmt_pidm ='" + bannerid + "'"); while (rstagcheck.next()){ string tagnum = rstagcheck.getstring("xkrprmt_tag"); arraylist<string> mytag = new arraylist<string>(); (int = 0; < tagnum.length(); i++){ mytag.add(tagnum); mytag.get(i + i); i kinda know why getting error, not sure how remedy problem. what expect mytag.get(i + i) do? the first time through loop, "i" 0 , add 1 element. there won't element 1, call throw exception. see wrote, it'll fail on second iteration, not first, poor @giu noted in now-deleted answer. still, it's weird , don't know you're trying accomplish calling .get() , not looking ...

html - Altering multiple input's id's using jquery -

i trying change id's of of check boxes inside of parent container, far have ot been able work, here code, html: <div data-custom='other_container' class='container'> <h3>other:</h3> <div class='container'> <label for='monitoring'>monitoring , verification of energy savings: </label> <div> <input type='checkbox' name='other' id='monitoring' class='validate[mincheckbox[1]] checkbox' /> </div> </div> <div class='container'> <label for='engineering'>engineering & project management: </label> <div> <input type='checkbox' name='other' id='engineering' class='validate[mincheckbox[1]] checkbox' /> </div> </div> <div class='container'> <label for='energy_audits'>energy audits: </label> <div> <input ...

python - Grab elements inside parentheses -

how can grab elements inside parentheses , put them in file? me (i) (you) him (he) (she) thanks in advance, adia import re txt = 'me (i) (you) him (he) (she)' words = re.findall('\((.+?)\)', txt) # words returns: ['i', 'you', 'he', 'she'] open('filename.txt', 'w') out: out.write('\n'.join(words)) # file 'filename.txt' contains now:

visual studio 2010 - How to find classes in VS -

how find exception classes represented example in system.io namespace. possible in vs? in object browser, select 1 of .net framework versions (not components or solution). you can expand class , @ derived types. (note take time expand) alternatively, look @ msdn . edit : paste following linqpad : var mscorlib = typeof(string).assembly; var basetype = typeof(exception); mscorlib.gettypes().where(t => (t.namespace ?? "").startswith("system.io") && basetype.isassignablefrom(t)).dump();

android cell id -

i cid cell phone , using code : gsmcelllocation gsmlocation = (gsmcelllocation)telephonymanager.getcelllocation(); int cid = gsmlocation.getcid(); log.e("#############","current cid is: "+cid); int lac = gsmlocation.getlac(); log.e("#############","current lac is: "+lac); this returns 301 or 6061. i browsing example codes , found : /** * seems cid , lac shall in hex. cid should padded zero's * 8 numbers if umts (3g) cell, otherwise 4 numbers. mcc padded 3 * numbers. mnc padded 2 numbers. */ try { // update current location updatelocation(getpaddedhex(cid, cellpadding), getpaddedhex(lac, 4), getpaddedint(mnc, 2), getpaddedint(mcc, 3)); strresult = "position updated!"; } catch (ioexception e) { strresult = "error!\n" + e.getmessage(); } // show info toast results of updatelocation // call. toast t = toast.maketext(getapplicationcontex...

java - how to schedule some code execution in android or: what exactly are daemon threads in android? -

i'm working on app android os requires fetch data remote server time time. as "update" should carried out when actual frontend app not running, implemented remote service started on system boot. need schedule timer start update. is "timer"-class right 1 job? , if "yes": difference between "normal" timer() , 1 started "daemon" timer(true)? http://developer.android.com/reference/java/util/timer.html isn't helpful :( edit: ok - see there more methods expected. clarify: i want execute code @ time specified. this timer used trigger execution of code 7 days in future. (i.e., every week @ given weekday , time) the code should run without waking phone if "sleeping" (screen dimmed). when running code, no activity should started. i.e. no app pops on screen. the code executed should fetch data internet. if @ time no internet connection available, timer should set sth 30 minutes , try again. after completing...

jquery - How do I catch Javascript functions that are being called? -

i'm working cognos, frustrating bi application relies heavily on javascript. basically, when <select> box changed, data on screen refreshed, presumably ajax function or similar. i'd force change using jquery, i'm not sure how intercept call making can duplicate it. there's metric ton of js code, it's hard find hand. is there way using firebug display different functions being called? approach correct? if open firebug script panel, on top left there's button looks pause button on tv remote: || . tells firebug pause on next bit of javascript runs. i'd page open, ensure script panel enabled, click button, change select box. should trigger breakpoint in firebug, after can step through code figure out what's being called when. alternately, if don't mind using different tool, google chrome has built-in debugger , inspector can show event handlers attached element. in chrome, if bring page, right-click select box , choose inspe...

java - Extract the primary key from a entity object in JPA 2.0? -

let's have entity object. there way extract primary key it? i want this: public static object extractprimarykey(entitymanager em, object obj) { return em.givemetheprimarykeyofthisentityobject(obj); } reason attached copy of detached entity: public static object attach(entitymanager em, object obj) { return em.find(obj.getclass(), extractprimarykey(em, obj)); } is possible? (i using eclipselink 2.1) perhaps work: em.getentitymanagerfactory().getpersistenceunitutil().getidentifier(obj);

file get contents - Process pages for a certain information using PHP -

for example, wish mine https://stackoverflow.com/privileges/user/3 , data in div <div class="summarycount al">6,525</div> can add reputation local db along usernumber. think can use file_get_contents $data = file_get_contents('https://stackoverflow.com/privileges/user/3'); how extract required data i.e 6,525 in above example? you'll need login (through php) see relevant information. isn't straightforward , require work. you can use *shrugs* regex parse data, or use xml parser php simple html dom parser . regex...: preg_match('!<div class="summarycount al">(.+?)</div>!', $contents, $matches); $rep = $matches[1]; if scraping so, can use api instead. code: $url = 'http://api.stackoverflow.com/1.0/users/3'; $tucurl = curl_init(); curl_setopt($tucurl, curlopt_url, $url); curl_setopt($tucurl, curlopt_returntransfer, 1); curl_setopt($tucurl, curlopt_encoding, 'gzip'); $data ...

plsql - Where can I find an official grammar for the PL/SQL programming language? -

where can find official grammar pl/sql programming language? see antlr project has a user-contributed grammar , hoping find more authoritative source. you mean documentation? it'd know version of oracle -- this link covers 9i (v9.2 technically) .

.net - Window min width in WPF -

i have 2 collumn grid application. 1 has minimum width , has width = * , other has width=auto .. problem when resize window ,when grid has minimum width window shouldnt resize.... can set min width should guess width of auto collumn , not think.... i not positive asking here, taking wild stab @ it, want set minimumwidth of window? can that.

java applet not responding to repaint request in webkit browsers -

i have tiny java applet i'm writing solve specific problem in our company intranet in browser neutral way. used accomplished activex we'd let people move away ie. code unsafe public consumption, it's useful under controlled circumstances. want user able click link in , open application installed on local machine based on data returned ajax call. signed java applet , certificate has been accepted on local machine. currently works in ie , opera, fails in chrome , safari. appears repaint() method doesn't cause repaint, struggling with. here's applet code: import java.applet.applet; import java.awt.graphics; import java.util.*; public class odehapplauncher extends applet { private arraylist<string> torun = null; public void paint(graphics g) { system.out.println("-----painting"); try { if (torun != null) { new processbuilder(torun).start(); torun = null; } ...

php - SESSION variables not passed from page after destroying the rest -

i @ total loss words. i allow admin reset registration if reaching error during process. in theory, following code should function this: page reached, $adminvalidated set based on session data. $_session array cleared; cookie cleared on consumer end; session id regnerated , session destroyed. session restarted , mentioned variable put session. the "echo" statements included below work when redirect page (commented out below), session variables not carry over. yes have started session on follow page well. <?php session_start(); ob_start(); if( $_server['server_port'] == 80) { header('location:https://'.$_server['http_host'].$_server["request_uri"]); die(); } $adminvalidated = $_session['adminvalidated']; $_session = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() ...

python-opencv webcam ["noneType"] -

few weeks ago tryed move mouse pointer using python , opencv ...i didnt had time , today accidentally found piece of code doing problem cant open webcam anymore opencv ... i`m using ubuntu 10.04 ... /dev/video0 working can luvcview -d /dev/video0 but when camera = highgui.cvcreatecapturecamera(0) , try type(camera) nonetype ... i`ve apt-get remove --purge python-opencv , reinstalled ...but cant make work ... dont know whats wrong few weeks ago worked , ... here`s code controling mouse python opencv , xlib ... #! /usr/bin/env python print "opencv python version of lkdemo" import sys import os sys.path.insert(1, os.path.join(sys.path[0], '..')) xlib import x, display, xutil # import necessary things opencv opencv import cv opencv import highgui ############################################################################# # "constants" win_size = 10 max_count = 500 #############################################################################...

android - Setting parameters on child views of a RelativeLayout -

i'm having trouble finding syntax need use set paramters on child views of relative layout. have root relative layout want set 2 child textviews next each other this ---------- --------- | second | | first | ---------- --------- so have public class rl extends relativelayout{ public rl(context){ textview first = new textview(this); textview second = new textview(this); first.settext('first'); first.setid(1); second.settext('second'); second.setid(2); addview(first, new relativelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content, layoutparams.allign_parent_right ???); addview(first, new relativelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content, layoutparams.allign_right_of(first.getid()) ???); } } how set relative alignments? public class rl extends relativelayout { public rl(context context) { ...

visual studio - How to import an ASP.NET MVC app from VisualStudio to SharpDevelop? -

i'd import asp.net mvc 2 app visual studio 2008 sharpdevelop v4.0. i'm using: * windows 7 * iis 7.5 * .net sdk v4.0 * visualstudio 2008 * mvc 2 * sharpdevelop v4.0 beta r6767 thanks bunch beforehand currently there's no tooling support in #develop asp.net mvc don't expect add view , add controller , jump corresponding view controller action , stuff this. work asp.net projects in #develop using this plugin . because uses msbuild won't have problems compiling asp.net mvc application.

python - Excluding a Django app from being localized using a middleware -

i need localize django project, keep 1 of applications (the blog) english only. i wrote middleware in order achieve this: from django.conf import settings django.core.urlresolvers import resolve class delocalizemiddleware: def process_request(self, request): current_app_name = __name__.split('.')[-2] match = resolve(request.path) if match.app_name == current_app_name: request.language_code = settings.language_code problem is, assumes middleware lies directly in application module (e.g. blog/middleware.py ) retrieving app name. other projects might have middleware in blog/middleware/delocalize.py or else altogether. what's best way retrieve name of running app? you can use django's resolve function current app name. https://docs.djangoproject.com/en/dev/topics/http/urls/#resolve

algorithm - Bin-packing (or knapsack?) problem -

i have collection of 43 50 numbers ranging 0.133 0.005 (but on small side). find, if possible, combinations have sum between l , r, close together.* the brute-force method takes 2 43 2 50 steps, isn't feasible. what's method use here? edit: combinations used in calculation , discarded. (if you're writing code, can assume they're output; i'll modify needed.) number of combinations presumably far large hold in memory. * l = 0.5877866649021190081897311406, r = 0.5918521703507438353981412820. the basic idea convert integer knapsack problem (which easy). choose small real number e , round numbers in original problem ones representable k*e integer k . smaller e , larger integers (efficiency tradeoff) solution of modified problem closer original one. e=d/(4*43) d width of target interval should small enough. if modified problem has exact solution summing middle (rounded e ) of target interval, original problem has 1 somewhere within interva...

css - Display email like major providers (Gmail, Yahoo) -

i want display email in section of page other data (css layout). when emails sent browser (jquery ajax), 1 of emails has css style affects existing pages css. rather not use iframe contain emails. how providers such gmail , yahoo display emails html , css without embedded css/html affecting rest of page? the e-mails parsed server-side , reformatted. you'll notice isn't perfect. there sorts of issues html e-mail.

java - How to map a Map<String,Double> -

i tried @manytomany(cascade = cascadetype.all) map<string, double> data = new hashmap<string, double>(); but produces error : org.hibernate.annotationexception: use of @onetomany or @manytomany targeting unmapped class: com.company.klass.data[java.lang.double] @ org.hibernate.cfg.annotations.collectionbinder.bindmanytomanysecondpass(collectionbinder.java:1016) @ org.hibernate.cfg.annotations.collectionbinder.bindstartomanysecondpass(collectionbinder.java:567) @ org.hibernate.cfg.annotations.mapbinder$1.secondpass(mapbinder.java:80) @ org.hibernate.cfg.collectionsecondpass.dosecondpass(collectionsecondpass.java:43) @ org.hibernate.cfg.configuration.secondpasscompile(configuration.java:1130) @ org.hibernate.cfg.annotationconfiguration.secondpasscompile(annotationconfiguration.java:296) @ org.hibernate.cfg.configuration.buildmappings(configuration.java:1115) any idea? well, error message pretty clear: double isn't entity. if want map collection of ...

visual studio - Where are logs for witadmin actions in TFS 2010? -

when running witadmin command visual studio 2010 command line, action logged in tfs 2010? example command be: c:>witadmin exportwitd -collection:http://server:8080/tfs/projectcollection -p:teamproject -n:bug -f:c:\bug.xml one way query command log in collection database. note: it's recommended not query database directly, since schema not documented/supported , change in future release. select * tbl_command (nolock) useragent 'team foundation (witadmin.exe%' a ' exportwitd ' command show command = ' getmetadata '. same command visual studio makes when connect tfs, you'll need filter on user agent. a ' importwitd ' command show command = ' update '

html - Define <OL> start value -

building on post found @ ordered lists <ol>, starting index xhtml strict? , wondering if there way define start value of list without using css , still compliant conforming strict dtd specification? looking solution of "value" attribute assigned tag li . can start numerical value? able commence specific alphabet example? correct way: <ol> <li value='10'>item</li> <li>item</li> <li>item</li> </ol> correct, deprecated <ol start='20'> <li>item</li> <li>item</li> <li>item</li> </ol> ugly hack xd <style> li.hidden { visibility: hidden; height: 0px; font-size: 0px; /* don't try display:none, trust me */ } </style> <ol> <li class='hidden'></li> <li class='hidden'></li> <li class='hidden'></li> <li>item 4<...

java - commandLink does not work on the first click -

i've found questions seem related one, none describes exaclty happening web app. here goes: it's simple app, left menu bar, header , central panel show texts. menu bar has lot of commandlink s define page going loaded in central panel. strange problem none of these links work when page loaded. in other words, first click nothing. second click on, links work. i'm using jsf 1.2 , icefaces 1.8.1. code snippet first commandlink (all of others similar): <f:view> <html> <head> <ice:outputstyle href="./xmlhttp/css/rime/rime.css" /> </head> <body> <ice:form id="nav_form" partialsubmit="true"> <ice:messages /> <ice:panelgrid columns="1" width="152"> <ice:panelcollapsible expanded="true"> <f:facet name="header"> <ice:panelgroup> <ice...

graphics - Why is my animation flickering on iPhone? -

i'm getting random flickers following animation -- looks picture centering 1 frame or before continuing it's supposed doing, , don't know why. -(void)generatewander{ //nslog(@"generatewander"); if(targetchange==0) { targetchange=target_length+1; float destinationangle=((float)random()/rand_max)*2*m_pi; nslog(@"new destination: %f",destinationangle); targety=sin(destinationangle)*target_radius; targetx=cos(destinationangle)*target_radius; nslog(@"new target is: %f %f",targetx,targety); } targetchange--; float newvectorx=(targetx-currentx)*vector_scalar; float newvectory=(targety-currenty)*vector_scalar; vectorx+=newvectorx; vectory+=newvectory; if (pow((vectorx*vectorx+vectory*vectory),.5f)>max_speed) { vectorx*=.5; vectory*=.5; } float newx=currentx+vectorx; float newy=currenty+vectory; //nslog(@"new position is: %f %f",newx,newy); self.wander=[cakeyframeanimation animationwithk...

python - Tkinter Cxfreeze Error -

i'm trying make exe in windows out of python developed in linux. program works on it's own in python under windows, , when use cxfreeze completes , makes exe. when run get: c:\projects\0802001s\dist>listen.exe traceback (most recent call last): file "c:\python26\lib\site-packages\cx_freeze\initscripts\console.py", line 27 , in <module> exec code in m.__dict__ file "./listen.py", line 425, in <module> file "c:\python26\lib\lib-tk\tkinter.py", line 1643, in __init__ self.tk = _tkinter.create(screenname, basename, classname, interactive, want objects, usetk, sync, use) _tkinter.tclerror: can't find usable init.tcl in following directories: c:/projects/0802001s/lib/tcl8.5 c:/projects/0802001s/lib/tcl 8.5 c:/projects/lib/tcl8.5 c:/projects/0802001s/library c:/projects/libr ary c:/projects/tcl8.5.9/library c:/tcl8.5.9/library this means tcl wasn't installed properly. so, looked init.tcl in python26 dir...

postgresql - Postgres string data type storage allocation -

we running postgres 8.3.3 , documentation ( http://www.postgresql.org/docs/8.3/static/datatype-character.html ) leaves me few questions how storage allocated. for purposes of discussion i'd stick assuming character = 1 byte. i understand character(n) blank pads have n bytes stored. if char(n) > 126 characters long, have overhead of 4 bytes (presumably storing length), otherwise overhead of 1 byte. i'm interested in happens varchar(n). if use varchar(255) , store 4 character string in it, have 4 bytes string & 4 bytes overhead, or have 1 byte overhead until hit 126 character limit? i've googled , can't find documented anywhere. any thoughts? it's length of data store controls overhead, not maximum length of column. have 1 byte overhead until hit 126.

c# - Get FieldInfo of inherited class -

in c# have classes derived in following way: myclass1 <- myclass2 <- myclass3 <- myclass4 (the root class myclass1) now have instance of myclass4 myclass4. how private field info declared in myclass2? can following: fieldinfo[] fields = model.gettype().basetype.basetype. getfields(bindingflags.nonpublic | bindingflags.instance); foreach (fieldinfo fld in field) { .... } what if inheritance level unknown? do know looking field in myclass2 ? if so, keep reading currenttype.basetype until currenttype == typeof(myclass2) . iow type lcurrenttype = model.gettype(); while (lcurrenttype != typeof(myclass2) && lcurrenttype != null) { lcurrenttype = lcurrenttype.basetype; }

design - What are good software for creating icons? -

i looking software can draw web ui icons butttons or navigation tabs etc. i've tried fireworks , liked trial expired. used make simple buttons using ms paint drives me nuts trying make fancy. i pay fireworks know there decent program can free. doesn't have super powerful 3d graphic. try gimp... it's 1 free powerfool tool !!! :d

asp.net mvc - How to get to the parent object in an editortemplate? -

in custom editor template want access parent object. i'm using code not best way it, when using nested views: object parent = viewcontext.controller.viewdata.model; does have better idea? you shouldn't try climbing model hierarchy, if editor requires data add model or use viewdata. call render editor <%: html.editorfor(model => model.editormodel, new {viewdatakeyname = model.additionaldata})%> be careful when adding data vital editor way, has included in each call template, that's why prefer include values in model itself.

Why WCF cannot be invoked in wcftestclient? -

i built wcf service, works in ie addr, once add wcftestclient , invoke method, error prompted , shown : failed invoke service. possible causes: service offline or inaccessible; client-side configuration not match proxy; existing proxy invalid. refer stack trace more detail. can try recover starting new proxy, restoring default configuration, or refreshing service. error details: the address property on channelfactory.endpoint null. channelfactory's endpoint must have valid address specified. @ system.servicemodel.channelfactory.createendpointaddress(serviceendpoint endpoint) @ system.servicemodel.channelfactory`1.createchannel() @ system.servicemodel.clientbase`1.createchannel() @ system.servicemodel.clientbase`1.createchannelinternal() @ system.servicemodel.clientbase`1.get_channel() @ mydownloadsvcclient.deletemyfolder(int32 userid, int32 folderid) the config file is: (updated @ 10/9) <?xml version="1.0" encoding="utf-8"?...

c# - How to invoke static generic class methods if the generic type parameters are unknown until runtime? -

assume have static generic class. generic type parameters not available until runtime. how invoke members? please see following code snippet: static class utility<t> { public static void dosomething() { } } class tester { static type gettypeatruntime() { // return object of type type @ runtime. } static void main(string[] args) { type t = gettypeatruntime(); // want invoke utility<>.dosomething() here. how this? } } edit: ok, solution based on responses given 2 guys below. both of you! static class utility<t> { //trivial method public static void dosomething(t t) { console.writeline(t.gettype()); } } // assume foo unknown @ compile time. class foo { } class tester { static void main(string[] args) { type t = typeof(foo);// assume foo unknown @ compile time. type gentype = typeof(utility<>); type con = gentype.makegenerictype(new type[] { t }); ...

Future of GDIPlus Windows User interfaces: which will be the replacement? -

almost windows applications gui (winforms or native) use gdiplus. but technology quite old, , shows many limitations. alternatives wpf, or silverlight, flash? developer tools visual studio , delphi still use gdiplus reference. when change? , moreover: there portability? delphi vcl in future ported new technology maintaining backwards compatibility? (for ex tbutton gdi, in future can else). update : maybe question can stated "will future os render gui widgets without gdi+ using newer technology, kind of builtin silverlight/flash?" for native programs, wpf has replaced gdi+ in view, since gdi+ , winforms have been in play long time, take long time majority of developers go on new technology, if has lot of great features , possibilities gdi+ not come close to. visual studio still have support winforms/gdi+ of course, since visual studio 2008 built in support wpf have been there, , working fine. silverlight , flash never mainstream replacement na...

Error in my existing android project -

error: the project not built due "resource exists on disk: '/project/bin/default.properties'.". fix problem, try refreshing project , building since may inconsistent project unknown java problem try removing entire bin directory , rebuilding.

c# - Response.AddHeader("Content-Disposition") not opening file in IE6 -

i'm using response.addheader("content-disposition", "attachment; filename=" + server.htmlencode(filename)); pop 'open/save file' dialog users, can download file on local machines. this working in ie7,but on ie6 file not opening when user click on open button in 'open/save file' dialog. gone through net , found response.addheader("content-disposition", "inline; filename="+server.htmlencode(filename)); should provide work in ie6,and works fine.. but issue of files can open in browser opens on page itself.. ie user on mail page , click download image file opens there,, need open in window in case of ie7 can do... other files cannot open in bowser open current application in system ie(word,excel etc).. please suggest method stick same code both ies... code used here.... response.addheader("content-disposition", "attachment; filename=" +filename); response.addheader("content-length", file.l...

c++ - Progressive disclosure control -

in windows api, how implement progressive disclosure control? gonna lot of hand coding, probably. if you're using message box, taskdialog: has similar built-in. otherwise you're on own.

oracle - Are there any situations in which you would use NLS_LENGTH_SEMANTICS=BYTE on a Unicode database? -

having unicode (multi-byte charset) oracle database nls_length_semantics=byte seems disaster waiting happen. field validation in applications check number of characters within bounds, not byte sequence length in database’s default character encoding scheme! if you've got unicode database, there ever reason use nls_length_semantics=byte rather char? it's legacy, think. there plenty of old applications have worked on bytes , may confused if changes. byte strings , indexes go off external app/language works in bytes going go wrong in weird , unpredictable ways if indexes redefined underneath it. i not use byte semantics new application , agree it's not default. you're using nvarchar, avoids issue (since it's character-based).

Silverlight Control property as a data binding Source and View-Model property as target -

i have property on silverlight control viewmodel wants bind to. viewmodel need told of changes property not other way around syntax <mycontrol viewport="{binding vmproperty}"/> declares viewport target, in instance viewport source of data. know make twoway binding seems wrong when want 1 way in other direction. besides not want make property on control dependencyproperty because not want property settable , not beleive silverlight supports read dependency properties. is there different way of setting binding? tia pat long maybe works? http://forums.silverlight.net/forums/p/141042/315359.aspx#315359 {binding elementname=textbox1, path=text, mode=twoway ,updatesourcetrigger=explicit}

android - Scrolling ListView like in TweetDeck -

i wondering if knows how scrolling in tweetdeck can done. in particular how did last item can scrolled top of listview. i think kinda awesome , use such behavior in app too. it not listview. timelineview class inhert view class. can decompile dex file , check it.

Ant if statement -

below snippet build.xml file. want modify file jar name set depending on value of variable within build file. <info jarname="java get" jarurl="${deploy-url}${polish.jarname}" /> so - <info if(${deploy-url} == "test") jarname="java get" else jarname="java test" jarurl="${deploy-url}${polish.jarname}" /> or can call java program return jar name, - <info jarname=java programtoexecute jarurl="${deploy-url}${polish.jarname}" /> thanks suggestions, adrian the ant contrib project has selection of custom tasks , including <if> task let this. it's clumsy, works.

c# - Explicit assignment of null -

string s1; string s2 = null; if (s1 == null) // compile error if (s2 == null) // ok i don't understand why explicit assignment needed. whats difference between null variable , unassigned variable? assumed unassigned variables assigned null runtime/compiler anyway. if they're not null, they? unassigned members automatically initialized default values (which null reference in case string ). unassigned local variables not assigned value , trying access possibly unassigned variable give compile error.

c - Query regarding main() of GRUB -

below code of main() of grub. here want know line: file = fopen(arg_v[1], "rb"); here file fopen opening? file arg v[1] pointing to? int main(unsigned arg_c, char *arg_v[]) { file *file; if(arg_c < 2) { printf("checks if file multiboot compatible\n"); return 1; } file = fopen(arg_v[1], "rb"); if(file == null) { printf("can't open file '%s'\n", arg_v[1]); return 2; } check_multiboot(arg_v[1], file); fclose(file); return 0; } if call program with program arg1 arg2.txt 65 argv[1] pointer "arg1" ; argv[2] pointer "arg2.txt" , argv[3] pointer "65" , argv[4] null argv[0] either points "program" or "" if os and/or library and/or startup code cannot identify name used call binary executable in specific case, program...

internet explorer 8 - If I develop webpages to ie8 will they render correctly in ie6? -

i have developer toolbar, other tools missing ? i not doing fancy graphics/html 5. i have been told need support ie8; want know if need test in both, or ie8. have used ms superpreview, static sites - developig large data driven jsp website. , far can see there not easy way test on both ie6 ie8, without using separate machine (albeit virtual). edit ietester remove standard ie install (i want keep developer toolbar). ietest enable me test under both, , develop usign developer toolbar in whichever browser (ie6/ie8) ie6 1 of dumbest browser , biggest pain both designer , developer. there no guarantee site work in both ie8 , ie6. checking can use ie tester software free. should stop considering ie6 :)