Posts

Showing posts from July, 2010

MYSQL - how to string comparisons and query? -

+--------------------+---------------+------+-----+---------+-------+ | id | gkey |goods | pri | country | | +--------------------+---------------+------+-----+---------+-------+ | 1 | book-1 | 1 | 10 | | | | 2 | phone-1 | 2 | 12 | | | | 3 | book-2 | 1 | 13 | | | | 4 | book-3 | 1 | 10 | | | | 5 | phone-2 | 2 | 10 | | | | 6 | phone-3 | 2 | 20 | | | | 7 | book-10 | 2 | 20 | | | | 8 | book-11 | 2 | 20 | | | | 9 | book-20 | 2 | 20 | | | | 10 | book-21 | 2 | 20 | | | | 11 | phone-30 | 2 | 20 | | | +--------------------+

Understanding Brushes in WPF -

beside solidcolorbrush, lineargradientbrush, , radialgradientbrush there 3 other types of brushes: visualbrush, drawingbrush, and imagebrush. the first 3 types self-explanatory. i've troubles understand visualbrush, drawingbrush, , imagebrush. maybe it's easier understand purpose of these brushes. best practices these brushes? there canonical examples? when should use these brushes? there page different wpf brushes in msdn here . have seen yet? maybe answer few of questions

c# 4.0 - Opening of a xml document in internet explore -

how can open xml document in internet explore in c sharp dot net winforms only try this. works perfectly. string strfilename = @"c:\file.xml"; process proc = new process(); proc.startinfo.useshellexecute = true; proc.startinfo.filename = strfilename; proc.start();

plot - Store MATLAB 3d viewport -

i using matlab display 3d data. use gui change view angle, zoom , pan. how can store view , later apply figure (containing more or less same data)? view gives me matrix, how can apply figure? thanks lot! to use current view angle on figure, do: % call when source axes current axes [az, el] = view; % call when target axes current axes view (az, el); or, same using get , set of view property. however, apply view properties mentioned together, easier use matlab's built-in 'generate m file' option - when have 3d figure way want it, go file -> generate m-file , , m-file created gets 3d data input, , apply settings. another option save these relevant settings (just inspect m-file generated): plot3(sin(t),cos(t),t); pba = get(gca, 'plotboxaspectratio'); dar = get(gca, 'dataaspectratio'); cva = get(gca, 'cameraviewangle'); cuv = get(gca, 'cameraupvector'); ct = get(gca, 'cameratarget'); cp = get(gca, 'came

MySQL update many-to-many tabel relation -

i have tables , b , a_has_b have fields: a: id, name b: id, name a_has_b: a_id, b_id, background previously when had not 'background' field in a_has_b, did update delete record in a_has_b , reinsert updated records. but how can update a_has_b whitout deleteing records should reinsert? off top of head, think like.... delete a_has_b not exists ( select 1 b b.id=a_has_b.b_id ); (and similar table 'a') or delete a_has_b b.id <> (select id b);

accelerometer - Android Sensors - Problem getting Proximity Sensor Values and problems with using different phones -

have done android dev in past has been while - want build app uses orientation , proximity sensors. so... msensormanager = (sensormanager) getsystemservice(sensor_service); msensormanager.registerlistener(this, msensormanager.getdefaultsensor(sensor.type_all) , sensormanager.sensor_delay_game); so set listener - listened sensors - wonder should listen two? (would save battery?) sensor mysensor = event.sensor; // if (mysensor.gettype() != sensor.type_orientation) return; if (mysensor.gettype() == sensor.type_orientation) { float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; tv.settext("rotation around x, azimuth = " + x); tv1.settext("rotation around y, pitch = " + y); tv2.settext("rotation around z, roll = " + z); } if (mysensor.gettype() == sensormanager.sensor_proximity) { float p = event.values[0]; tv3.settext("proxim

compilation - redhat - compile ffmpeg - how to link with liblame/x264 when they're installed locally -

i've managed install ffmpeg, basic build using ./configure --disable-debug --disable-network --disable-ffserver --disable-ffplay --prefix=/export/home/userid/bin/ffmpeg now i've installed liblame , x264 /export/home/userid/bin , tried compile ffmpeg follows: ./configure --disable-debug --disable-network --disable-ffserver --disable-ffplay --prefix=/export/home/userid/bin/ffmpeg --enable-libmp3lame --enable-libx264 --enable-gpl and error error: libmp3lame not found how can tell configure things in /export/home/bin? thanks solved. compile using --enable-cflags , --extra-ldflags

iphone - How to Re-buy when testing InApp Purchase with Sandbox? -

i have visited thread iphone + in app purchase testing but solution of creating new account each time want buy same item extremly tedious. there solution of creating new product or guess changing product identifier should work not friendly , productive solution well. so, there documented way of un-purchasing , purchasing again product when testing inapp purchase sandbox? you don't need un-purchase items, re-buying them on same account gives same transaction, minus money. there no way of doing this, other creating new users.

authentication - Display last logged in details using Devise in Rails 3 -

i have rails 3 application , it's using devise authentication. i display date , time each user last logged in within administration table of users. i have based application on following application: https://github.com/dannymcc/rails3-base i have read through devise github wiki , notice mentions user events trackable, can't find information regarding accessing information etc. any help/advice appreciated! thanks, danny the devise documentation outlines trackable module want. in user model, include :trackable module so: devise :database_authenticatable, ... :trackable and make sure database has right fields. not sure how if have user table, adding fields right names , types should trick. migration create users table looks so: class createusers < activerecord::migration def self.up create_table :users |t| t.string :name t.string :email t.database_authenticatable :null => false t.recoverable

xcode - Objective-C - Publish to Facebook -

i’m wanting create iphone application user has option publish data facebook page. does have sample extracts of code or reading material can have background understanding of wish create. have bothered trying facebook sample code @ least? https://github.com/facebook/facebook-iphone-sdk

language agnostic - dont move background while scroll down web page -

is there way dont move background of webpage while scrolling down? dont know how it, maybe using php, css or javascript? thbaks body { background-image:url('mybackgroundimage.png'); background-attachment:fixed; }

windows ce - .NET Compact application throws TypeLoadException when not run through debugger -

if run .net compact application using conmanclient, works. if try running application executing directly shell, throws typeloadexception (a window appears displaying without additional information). use .net compact 3.5 , windows ce 6.0 r2.

iphone - Running method everytime I push the ViewController -

what init metod called everytime viewcontroller pushed window? -viewdidload , -initwithnibname work 1st time view started. want startup checking in vc everytime start it. does such method exist? or have declare somehow manually? try view controller's viewwillappear: method (if want setup 1 specific controller).

amazon s3 - CloudFront - Streaming distribution - ignores files not in root -

i've got bunch of videos in directory, in s3 bucket. databucket contains: videos/18512/version1.flv - contains other versions in directory now, when using rtmp streaming distribution via cloudfront only work if video files in root of bucket. if in sub directories, see structure (which necessary really), ignore/not find files. i can't see on amazon support or googling, or indeed here. advice if nature of beast or setting/config issue? was stuck on issue myself, turns out jw player need precede path mp4: prefix. so example rtmp path cloud front be. rtmp://xxxxxx.cloudfront.net/cfx/st/mp4:videos/18512/version1.flv figure must have gotten past due age of question. since came in search answer, figured leave others might find well.

c# - Command-Line Building -

Image
i used command-line building , every time run application, console appears in background. how should rid of this? please see image: use /target command line option , value winexe : csc /target:winexe mycode.cs

java - Making custom object convertible -

in java possible me design own class convertible(or castable?) primitive type? example, if have: class intstring{ private int intval; private string strval; public intstring(int intval, string strval){ this.intval = intval; this.strval = strval; } } static void main(string[] args){ intstring intstr = new intstring(1,"yes"); } is possible have like: int inttstval = intstr; or even int inttstval = (int)intstr; ? and can make class work string in same fashion? thanks not implicitly can implements same/similar methods wrappers use. int inttstval = intstr.intvalue(); string text = intstr.stringvalue();

android - What are the differences among Internal storage, external storage, sd card and removable storage? -

from official documentation : using external storage every android-compatible device supports shared "external storage" can use save files. this can removable storage media (such sd card) or internal (non-removable) storage ... i'm confused subject. understand, using external storage doesn't mean use removable card, right? however, when talking external storage, it's referred "sd card". i'm developing app downloads .mp3 files internet. want save files in phone memory (don't want use removable device) have learned, files have saved in external memory.however, offer possibility of importing file removable device. , how should save files? thanks when building app uses internal storage, android os creates unique folder, accessible app, no other app, or user, can see what's in folder. the external storage more public storage, now, it's sdcard, become other type of storage (remote hard drive, or else).

php - load xml file with authentication (and improving security) -

i'm trying use simplexml load xml file server: $xml = simplexml_load_file($xml_query); the server needs http authentication, (unsurprisingly) error message: http request failed! http/1.1 401 unauthorized is possible pass username , password server using function? edit if can tell me more secure way this, i'd grateful. you should able prepend username , password url you're opening. instead of http://link.to/file.xml try http://username:password@link.to/file.xml

windows phone 7 - wp7 advertising - unexpected error during response processing ECN -

i using microsoft's adcontrol in app developing. have registered @ pubcentral , using correct applicationid , appunitid. also, setting adcontrol.testmode = false. ads getting displayed correctly yesterday today, error - unexpected error occurred during response processing (name: ecn). has else noticed issue? i using january 2011 tools wp7. not sure if issue emulator. edit: quick update. app ads weren't working during development got published morning , of ads working when downloaded straight marketplace. still not sure of reason thought information may useful. ok - i've spent far time researching this. apparently there lot of people having error. think may have impending update of wp7 because it's relatively recent. if check out official forums ( http://community.microsoftadvertising.com/forums/32.aspx ) there tons of posts describing same issue. for reason still getting impressions adcontrol despite lack of visual advertisement. suggestion leave

Retrieve posts with their latest comment in CakePHP -

say have model post , model comment related follows: post hasmany comment comment belongsto post how use find('all') retrieve every post associated latest comment ? i have tried defining hasone relationship in post as: var $hasone = array('latestcomment' => array('classname' => 'comment', 'order' => 'latestcomment.created desc')); but when post->find('all') returns every post multiple times, once per each comment , latestcomment set different comments . you can add 'limit' => 1 array of parameters return 1 comment. alternatively, instead of defining relationship, can limit number of comments returned when perform find, using containable behaviour. $this->post->find('all',array( 'contain' => array( 'comment' => array( 'order' => 'comment.created d

drupal - Node edit form: edit or new state? -

what's best way of figuring out if node form in create new node state or edit existing node state? is there in $form array or have kludge arg() ? are asking node edit form? if so, can either following: if (empty($form['nid']['#value'])) { // in add form } else { // in edit form } or... if (arg(1) == "add") { // in add form... } else { // in edit form... }

wpf - Adding MultiBinding and Binding to Resources collection -

why not possible? i use same binding in lot of places , hate copy , paste same xaml instead of use resource... any way to this? thanks! define bindings within style can reside resource. <style x:key="mystyle"> <setter property="background"> <setter.value> <multibinding converter="{staticresource myconverter}" > <multibinding.bindings> <binding.../> <binding.../> </multibinding.bindings> </multibinding> </setter.value> </setter> </style>

c# - I want to delete multiple lines of file's output .which file is redirected -

i want delete multiple string lines of files output.which file redirected. code follows. static void main(string[] args) { system.diagnostics.process p = new system.diagnostics.process(); p.startinfo.filename = "cmd "; p.startinfo.useshellexecute = false; p.startinfo.arguments = "/c ipconfig"; p.startinfo.redirectstandardoutput = true; p.start(); string output = p.standardoutput.readtoend(); p.waitforexit(); console.writeline(output); console.readline(); } output : give correct answer.but want ip address of m/c. other lines deleted. please give answer of question changes of code. do need run ipconfig? networkinterface class should able provide information looking without requiring run external process , parse text.

jquery - ajaxSubmit does not reload page after first request (in CakePHP) -

i'm creating cms has page edit section. i'm trying create preview function. works fine on first attempt, if change text , preview again, preview old version. appears quickly. it's if ajaxsubmit function doesn't bother reloading page. i tried round changing url each time (by adding on timestamp end), made no difference. i'm using jquery, cakephp , fck editor. here's have: <script type="text/javascript"> $('#page_modal').jqm(); $('#preview_btn').click(function(e){ // current page content fck iframe var oeditor = fckeditorapi.getinstance('pagecontent'); var newcontent = oeditor.getdata(); $('#pagecontent').html(newcontent); // submit form via ajax var d=new date(); var t=d.gettime(); var thisurl = '/admin/pages/preview/' + t.tostring(); $('#ajaxform').ajaxsubmit({ url: thisurl, error: function(xmlhttprequest, textstatus, errorthrown){ a

iphone - Update text in alert message -

still trying update message in uialertview while alert active. removed of first part of question , publish more code in update below. update 3: adding more code! in .h file declare following (among others): @interface webviewcontroller : uiviewcontroller <uiwebviewdelegate> { iboutlet uiwebview *webview; uialertview *alert; } i @property , @synthesize uialertview to. next create alert in ibaction run button click: -(ibaction)convert { convertbutton.enabled = no; mailbutton.enabled = no; backbutton.enabled = no; //show alert window alert = [[uialertview alloc] initwithtitle:@"converting in progress\nplease wait..." message:@"\n\n\n" delegate:self cancelbuttontitle:nil otherbuttontitles: nil]; [alert show]; uiactivityindicatorview *indicator = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylewhitelarge]; // adjust indicator few pixels bottom of alert indicator.center = cgpointmake(alert.bounds.size.w

.net - Testing installer - browsercam for apps -

i have installer .net application , want test on xp - win 7 on 32 , 64 bit machines. know of service can remote machines, install stuff , kill them when done? its browsercam non web apps. hello. can write script automation install/uninstall app. can try autoit or autohotkey . have written script install application developed installaware.

Can Windows Server AppFabric Caching be used with IIS Express for ASP.NET Session? -

i run windows server appfabric caching locally on windows 7 machine. is possible configure asp.net app use appfabric caching session state iis express ? yes is, need make sure have app fabric caching server set correctly on local machine.

python - Django hideously slow with 8000 model instances (How to drop PostgreSQL database)? -

i have django installation running on development server. used python manage.py loaddata 8000models.json . super slow. pages won't load. python manage.py flush not return. modeltype.objects.count() not return. (or maybe return if wait sufficiently long time.) what's going on here? django unable handle data? or there other issue? update : observe issue on postgresql not sqlite same amount of data. perhaps need wipe postgresql , reload data. update 2 : how can wipe postgresql , reset? python manage.py reset appname isn't responding. update 3 : how i'm trying wipe postgresql: #! bin/bash sudo -u postgres dropdb mydb sudo -u postgres createdb mydb sudo -u postgres psql mydb < ~/my-setup/my-init.sql python ~/path/to/manage.py syncdb however, causes following errors: dropdb: database removal failed: error: database "mydb" being accessed other users detail: there 8 other session(s) using database. createdb: database creation failed: error

Invisible Objects in java -

the following code part of larger application: public static void method_name(object setname, int setlength){ tryloop: for( ; ; ){ try{ setname = new stack(setlength); break tryloop; }catch (instantiationexception e){ system.err.println(e.getmessage()); set_num(1); continue tryloop; } } } whenever try use stack object initialized within try block, cannot found unless reference within try block. why , how can avoid in future? i suspect you're under impression this: setname = new stack(setlength); will have impact on argument passed in caller. won't. java strictly pass-by-value, whether value primitive type value or reference. in other words, if this: object foo = null; method_name(foo, 5); then foo still null afterwards. i suggest return value method instead. example: public static stack method_name(object setn

oracle - SQL Script. Updating a column in a table -

i wondering doing wrong. have 2 tables used in problem: odetails , parts. odetails has following columns: ono, pno, qty, cost parts has following columns: pno, pname, qoh, price, olevel trying update column cost in odetails cost = qty * price price found in parts. how can connect 2 tables. having brain fart because tried: update odetails set cost = qty * (select price parts pno = (select pno odetails not pno= null ) ) not pno = null; i think second subquery wrong becasue can give multiple rows , unnecesary: update odetails set cost = qty * (select price parts parts.pno = odetails.pno) pno not null

objective c - WiFi triangulation on the iPhone -

lets have zoo , want create app shows details on each animal whenever next cage. (just sake of question ... gps signals not option) if there wifi router next each cage, there methods iphone app can use work out phone nearby? guess wifi triangulation. or there other methods kind of geolocation without gps? the iphone can detect intensity of signal.. may enough having router inside each cage, calculated emission power. however, if gets crowded, mapping routers , comparing intensities of different routers might work. nice idea =) --hiring guide might job :d

javascript - Passing a local variable into an event handler -

h.d.d.w = ext.extend(w.g.a, { initcomponent: function () { examplefunctiona('monday'); //other fields omitted } examplefunctiona: function (dayofweek) { this['weekdayhoursstore' +dayofweek] = new ext.data.store({ proxy: a.b.c.getproxy('d/e.asmx/f'), reader: g.h.i.j( [ //array of config objects removed ]), sortinfo: //omitted }); this['weekdayhoursstore' +dayofweek].load( { params: { //parameters removed } }); this['weekdayhoursstore' +dayofweek].on("load", this._renderhours, this); //irrelevant code removed }, _renderhours: function (dayofweek) { var dayindex; for(var = 0; i<7; i++){ if(this.weekdays[i] === dayofweek){ dayindex = i; break; } }

Qt Creator book -

is there pdf tutorial or book how qt creator , developer ? qt assistant, embebbed in qt creator believe, nice. imho, greatest selling point of qt quality of it's documentation. but if want book c++ gui programming qt 4 really nice. it's not qt creator specific you're not going have trouble reading it.

Scriptaculous Appear effect shifts Google Map outside visible iframe area -

first, using wordpress project don't think issue wp-related. i using wp plugin called local market explorer inserts iframe google map , local amenity information, i.e. restaurants. iframe , content served walkscore.com via api. i fade page's container div in using scriptaculous appear effect. effect requires setting "display: none" container div using inline css on page. however, iframe containing map faded in, map contained in iframe moves outside of iframe display. removing "display: none" or setting "display: inline" returns iframe correct map display renders appear effect unfunctional. i suspect map moved outside iframe's display boundaries rather not displaying because horizontal scrollbar appears. when map displayed correctly, has vertical scrollbar no horizontal one. what confuses me scriptaculous fade works fine implemented in tabbed content script called stereotabs . tab content fades in without affecting map display. note

c# - Namespace redefinition exception if XmlTextWriter is declared a certain way -

i bulding xdocument , serializing utf8 string following code: string xmlstring = ""; using (memorystream ms = new memorystream()) { using (xmlwriter xw = new xmltextwriter(ms, encoding.utf8)) { doc.save(xw); xw.flush(); streamreader sr = new streamreader(ms); ms.seek(0, seekorigin.begin); xmlstring = sr.readtoend(); } } this worked fine. i needed toggle whether or not declarator serialized string. changed code this: string xmlstring = ""; using (memorystream ms = new memorystream()) { xmlwritersettings settings = new xmlwritersettings() { omitxmldeclaration = !root.includedeclarator, encoding = encoding.utf8 }; using (xmlwriter xw = xmltextwriter.create(ms, settings)) { doc.save(xw); xw.flush(); streamreader sr = new streamreader(ms); ms.seek(0, seekorigin.begin); xmlstring = sr.readtoend(); } } this throws following exception on doc.save(xw): the prefix '' cannot redefined

vb6 - Active x control (Does it need vb 6 runtime on client machine to work) -

i have developed active x control in visual basic 6. client machines need have visual basic runtime able use active x control in browser. i appreciate response. thanks yes, activex controls created in vb 6 require runtime installed on client machines

msxsl - how to iterate through XML param in XSLT -

i have xml file transforming via xslt. passing xml parameter xslt via c#. parameter's name attachment , contains xml. written follows: stringwriter sw = new stringwriter(); xmltextwriter w = new xmltextwriter(sw); w.writestartelement("root"); if (!string.isnullorempty(swordfilename)) { w.writestartelement("mylink", swordfilename); w.writeendelement(); } if (!string.isnullorempty(spdffilename)) { w.writestartelement("mylink", spdffilename); w.writeendelement(); } w.close(); xpathdocument doc = new xpathdocument(new stringreader(sw.tostring())); xpathnavigator nav = doc.createnavigator(); _exportset[currentexportset].format.paramlist["attachment"] = nav.select("./*"); my xml parameter looks <root><attachment xmlns=file1><attachment xmlns=file2></root> now in xslt need iterate through xml param , create link. here xslt <?xml version="1.0" encoding="utf-

How much data can MATLAB handle? -

i have lots of computing matrix of 200,000 (or more) rows , 100 or 200 columns. what memory threshold of matlab? can matlab handle giant matrix? the problem is, depends on version of matlab have. depends on how memory have. depends on largest piece of contiguous memory available you. answer potentially vague, since don't know have! how many elements there? done simple artifice of multiplication. 2e5*200 = 4e7 elements. 40,000,000 elements. how storage consume? assuming these doubles, each elements requires 8 bytes of memory. 4e7*8 = 3.2e8 bytes of memory, or 0.32 gigabytes of ram. have memory available? cannot say. if running 32 bit version of matlab on windoze, might barely fit. possession of 8 gigs of ram irrelevant if cannot address all, or if os won't let see all. if running 64 bit matlab on system 8 gigs of ram, have no problems in storing array. you can see memory available 1 systems using memory function in matlab.

jpeg - How do I preserve all the original image data in a JPG in Android? -

i'm working client color style guides immutable, , part of app there feature jpgs provided sent server. i'm converting images bytestream , uploading thusly, images arrive colors different original. here's code byte stream creation... bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap b = bitmapfactory.decoderesource(getresources(), uploadimgid); b.compress(bitmap.compressformat.jpeg, 100, stream); byte[] bitmapdata = stream.tobytearray(); i'm using 100% compression, so, i'm not sure why it's altering image in way. would more reliable move jpgs device's file system , upload file? alternatively, more reliable use pngs instead of jpgs? (i'm guessing png treats color information differently jpg does). tia the executive summary seem taking bitmap , compressing using jpeg. jpeg lossy. if colours must kept right, need lossless codec, such png. the long story follows: jpeg lossy codec. compresses pictures

objective c - ObjC: scanf skipped in do/while loop -

i'm starting teach myself objective c , have been fooling around simple console based calculator. start i'm asking user operation perform, 2 numbers perform operation on, , print answer after it's calculated. that part seems work fine - next piece i'm trying implement allow user keep making calculations until decide no longer want to. thinking approach put running of calculator inside do/while loop @ end of checking see if user wants continue via 'y' or 'no' via scanf();, , check see user choose respond with. i'm encountering though @ end of first pass, request input via scanf(); gets ignored , program terminates. i hoping :) i've done due diligence best via troubleshooting, online research(found on white space issue scanf(); didn't help), , guessing date i've been unsuccessful. below main section of code: int main (int argc, const char * argv[]) { nsautoreleasepool * pool = [[nsautoreleasepool alloc] init]; float answ

frp - What's the status of Scala.React? -

i read deprecating observer pattern , found absolutely fascinating. what's status of scala.react package described in document? found 1 tarball of snapshot of scala.react there doesn't seem documentation or active maintenance. found scalafx, looks might related reactive programming, unmaintained. are there projects out there build on ideas in paper create gui framework based on reactives? updated : william harvey points out below , there recent progress! like you, have intense interest in project, creep these pages every few weeks. :) https://github.com/ingoem http://lamp.epfl.ch/~imaier/ https://codereview.scala-lang.org/fisheye/user/imaier https://lampsvn.epfl.ch/trac/scala/search?q=imaier

python - Match but not return regular expression between two matches -

i'm trying retrieve 2 distinct items without matching term in between using regular expressions: [[a]] son of [[b]] i thought work: \[\[[a-za-z\s]+\]\](?:(.*son of.*))\[\[[\|,a-za-z\s]+\]\] but it's not quite working. how can match , b without returning "son of"? i assume have string [[worf]] son of [[mogh]] , want "return" (i.e. match) [[worf]] , [[mogh]] . so, you'll need capturing groups (parentheses) around portions of regular expression want capture (aka "return"). in order not return son of , you'll need remove capturing group have in there (nested within (?:...) ). in code: >>> s = '[[worf]] son of [[mogh]]' >>> p = re.compile('(\[\[[a-za-z\s]+\]\])(?:.*son of.*)(\[\[[\|,a-za-z\s]+\]\])') >>> print p.match(s).groups() ('[[worf]]', '[[mogh]]') if you're using .groups() method matched sections, can drop non-capturing group around .*son of.* , ma

multithreading - C# Events firing on wrong thread -

all i have application allows user communicate multiple serial devices. manager class used start application, creates new thread each serial device. inside thread, serial device created , thread , serial device object stored inside manager class later when needed. the serial device class creates com port class on it's own new thread used connect com port , send / receive data. when data received event fired serial device class in turn fires event manager class, in turn fires event ui alert user new data has arrived. my problem comes when com port class fires it's event notify serial port class, serial port class receives event , continues processing under com port thread. likewise if user sends information down com port, runs under ui thread. i add code edit later, now, if can spot obvious greatful. i have tried receiving event in serial device class , invoking method see if makes run under correct thread no good. i know serial device thread running application.

string - How to expand comma-separated field into multiple rows in MySQL -

select id, ips users; query result id ips 1 1.2.3.4,5.6.7.8 2 10.20.30.40 3 111.222.111.222,11.22.33.44 4 1.2.53.43 i'd run query produces following output user_id ip 1 1.2.3.4 1 5.6.7.8 2 10.20.30.40 3 111.222.111.222 3 11.22.33.44 4 1.2.53.43 if don't mind using cursor, here's example: set nocount on; -- create sample table, @t declare @t table(id int, ips varchar(128)); insert @t values(1,'1.2.3.4,5.6.7.8') insert @t values(2,'10.20.30.40') insert @t values(3,'111.222.111.222,11.22.33.44') insert @t values(4,'1.2.53.43') insert @t values(5,'1.122.53.43,1.9.89.173,2.2.2.1') select * @t -- create table output, @u declare @u table(id int, ips varchar(128)); -- setup cursor declare xc cursor fast_forward select id, ips @t declare @id int, @ips varchar(128); open xc fetch next xc @id, @ips while @@fetch_status = 0 begin

analysis - How to extract a Win32 Cabinet Self-Extractor without executing the extracted file then -

for coursework, have analyse malware. it .exe win32 cabinet self-extractor file. (that's how windows see it, start 4d 5a 00 03 hex). when run, extract files in folder created, run malware (batch/vbs files) @ end delete folder malware files. i wondering how possible extract witout executing malware? used procdump32 gives me: "process not 32bits or can't loaded or finished !". somehow, succeed stucked procdump32 , folder few second , copied before "disapear" got files, i'm not sure gathered of them , in proper way. so i'm looking application can extract content of win32 cab self-extractor file without executing output files and, if possible, giving list of extracted files. you can use /? on self-extractor file, should show /x:path or /t:path /c extract content (according microsoft kb 262841 , 197147 )

ruby on rails - include_root_in_json from controller -

i'm trying return result view json not include root. i don't want set on actions model,so therefore trying avoid setting activerecord.base.include_root_in_json = false i hoping @task = tasks.all @task.include_root_in_json = false to response need, doesn't seem working, returning 'undefined method include_root_in_json= # is there nice way of doing this?? it's old question now, answers not updated, , rails 3.2 filled gap ( rails source ) with rails 3.2, can use: my_model.to_json(:root => false) if don't want root key included. it gets better tested array, can do: model.all.to_json(:root => true)

Android: WebView unable to show '%' percentage sign -

i try play html , js code in webview. code contains sign '%' , webview return error error_bad_url. <style type='text/css'> test{ width: 100%; height: 100%; } </style> any idea? -z use webview.loaddatawithbaseurl if .loaddata causes problems.

In Java, how does break interact with nested loops? -

i know break statement jumps out of loop, jump out of nested loops or 1 in? thanks. without adornment, break break out of innermost loop. in code: while (true) { // while (true) { // b break; } } the break exits loop b , code loop forever. however, java has feature called "named breaks" in can name loops , specify 1 break out of. example: a: while (true) { b: while (true) { break a; } } this code not loop forever, because break explicitly leaves loop a . fortunately, same logic works continue . default, continue executes next iteration of innermost loop containing continue statement, can used jump outer loop iterations specifying label of loop continue executing. in languages other java, example, c , c++, "labeled break" statement not exist , it's not easy break out of multiply nested loop. can done using goto statement, though frowned upon. example, here's nested break might in c, as

java - Compile Error when using Spring JMS -

i'm running compile error while trying use spring-jms. quick google search turned 1 matching result, unable useful out of it. i'm using following code: public class class extends abstractclass { /** {@inheritdoc} */ @override public void acceptimportableitem(final importableitem<file> item) { jmsoperations template = getjmstemplate(); template.convertandsend(item); } } when try compile it, receive following compile error: cannot access javax.jms.destination and class file javax.jms.destination not found nowhere in code reference javax.jms.destination. of have idea why error crop up? jmsoperations requires javax jms classes of methods, need them in build path. going need jms provider's implementations on classpath @ runtime, anyway.

ruby - Why can my functional test not see my methods created using define_method? -

i have in application_controller.rb: group.all.each |g| define_method( "is_#{ g.name }?".to_sym ) unless @current_user.in_group?( g.name ) flash[:notice] = "you must in #{ g.name.titleize } group access page" redirect_to '/' return false end end end it uses entries in groups table create methods on fly. my problem functional tests can't see methods: 1) error: test_has_an_index(sc::questionscontrollertest): nomethoderror: undefined method `is_admin?' #<sc::questionscontroller:0x000000067749c0> what need functional tests can see dynamically created methods?

Linq to Sql - Partial Insert/Update Queries for *All* Tables -

i have database twenty-something tables in it. of them have 4 columns used auditing: createdate, createdby, updatedate, , updatedby. at moment, using partials each table's insert , update methods, , executing dynamic query, so: partial void insertstuff(stuff instance) { instance.createdate = datetime.utcnow; instance.createdby = "web app"; this.executedynamicinsert(instance); } that job; problem have create partial method every table, manually. is there way partial/override all insert , update operations in given context? add nice bit of brevity. scoured interwebs looking way this, never found 1 (at least, without doing crazy code generation that's not worth effort). i'm switching entity framework in future projects, i'll mark answer. unless else comes something, of course.

python - Best way to pipe the output of a local() to the stdin of a remote run() command in Fabric? -

is there simple way pipe output local commands remote ones (and vice versa)? i've piped file, moved file over, , read it...but seems there easier way. for simpler situations, capturing output , using string interpolation works: ip = local('hostname -i') run('script run ip: %s' % ip) but when output either needs escaping safe on command line and/or needs come stdin bit trickier. if output bash-safe, run('echo "%s" | mycmd' % ip) i'm looking (which guess implies equivalent question "is there simple way bash-escape strings?"), seems there should "right way" provide remote stdin. edit: to clarify long-ish inputs there number of potential problems simple string interpollation: classic shell problems (eg. output contain "; rm -rf / ) (and more realistically, in case) output can contain quotes (both single , double). i think doing run("echo '%s' | cmd" % output.replace("'",

Issue with jQuery UI Tabs (loaded via ajax) and form data -

i attempting set interface has form containing filters jquery ui tabs. tabs loaded via ajax. when click on 1 of tabs, want data form submitted tab. i set ajaxoptions grab data form, serialize it, , post url. have caching turned off, , have caching ajaxoptions turned off. this code using set tabs. $("#schedule-tabs").tabs({ ajaxoptions: { type: 'post', data: $('#filters').serialize(), cache: false, error: function(xhr, status, index, anchor) { $(anchor.hash).html("<p>an error has been encountered while attempting load tab.</p>"); } }, cache: false }); when tabs load, data passed along data in form when page first loaded though have changed filters in form. i have added following above tab setup verify form data along way: select: function(event, ui) {

Database design for a product voting system -

i'm making system user can vote or down on product, need able explicitly work out amount of ups , downs product has, total score recent period. each vote can optionally have comment it, , users need ability echo/boost other peoples comments (kinda retweet), , add/subtract total score of product depending on parent vote being retweeted. here current proposed tables: product id, name, category_id vote id, user_id, product_id, parent_id, comment, score, datetime user id, username etc. i thinking possibly need comments table effectively? votes' score field either 1 or -1 per advice read on stackoverflow allow me gather sum() of column calculate total votes, possibility have separate vote_up , vote_down tables...but not sure. depending on want do, can incredibly sophisticated problem, here's take on simplest way (eg. can throw in 10 min before leave work ;-p) i try stackoverflow/hotornot style approach, , store ranking unsigned integer. products(

bash - read: Illegal option -d -

here offending part of script: read -d '' text <<'eof' multiline text in var eof echo "$text" > ~/some/file.txt and error: read: 175: illegal option -d i use read -d on place , works fine. not sure why not happy now. i'm running script on ubuntu 10.10 fixes? workarounds? if run sh , try command, get: read: 1: illegal option -d if while still in bash , works fine. i therefore deduce script not running under bash . make sure script begins line: #!/usr/bin/env bash (or equivalent) correct shell running script. alternatively, if cannot (because script not bash one), aware -d bash feature , may not available in other shells. in case, need find way.

C# Winforms panels side by side taking up 50% width each -

i have 2 panels: panela, panelb in panel: panelcontainer. how make panela , panelb go side side taking 50% width each of panelcontainer? use tablelayoutpanel 1 row(100%) , 2 columns (50% each).

asp.net mvc - Understanding how DropDownListFor is working in MVC3 -

i'm new mvc3 , have been working on small site using ef , 'code first'. i'm trying few things in view dealing drop down list , wondering best way go them is. want user able select rule dropdownlist, , depending upon rule selected, label on page show rule name (without posting). need able send selected rule onto next page. haven't added of necessary fields view yet because i'm @ loss on how should work. how should go trying this? i've got model: public class d1k2n3carule { public int id { get; set; } [required] public int name { get; set; } [required] public string rule { get; set; } public d1k2n3carule(int name, string rule) { name = name; rule = rule; } public d1k2n3carule() { name = 0; rule = ""; } } my viewmodel: public class d1k2n3caruleviewmodel { public string selectedd1k2n3caruleid { get; set; } public ienumerable<d1k2n3carule> d1k2n3ca

html - Rails tab selection -

i have tab-like button interface interact site using following html <li class="current_page_item"><a href="/home" class="first">home</a></li> <li><a href="/projects">projects</a></li> <li><a href="/resume">resume</a></li> <li><a href="/contact">contact</a></li> the class="current_page_item attribute changes of tab. each url view managed my staticpages controller, how can make each view have respective 'tab' selected? current_page?(url) method can you. create additional helper method. module applicationhelper #... def tab_item(name, url) opts = {} opts[:class] = 'current_page_item' if current_page?(url) content_tag :li, opts link_to name, url end end #... end and use in view <%= tab_item 'home', root_path %> <%= tab_item 'projects',

asp.net - Need Javascript to open a web page in full screen after logging in -

i have 1 login.aspx page 1 master page(master.master). when click on login button, web page should view in full screen mode.this should happens automatically when user credentials correct.master page should open in full screen mode. i don't want in new window(pop window). don't want ask user press f11.it should work in browsers.(mainly in firefox , internet explorer) i tried below codes. not working fine. please correct code or suggest me new code. <script language="javascript"> function fullscreen() { window.open('page.php','kyscorp','width='+screen.width+',height='+screen.height+',top=0,left=0'); } </script> i wrote in master.master aspx page. regards, nj use window.location instead window.open window.location="page.php";

Personal finance app database design -

after searching around minimalistic money tracking/budgeting app, decided build 1 own personal use. however i'm unsure part of database design. @ moment, have entries table stores data each transaction, whether credit or debt etc. the dilemma have is, don't know if should create table store current balance of each account or if should populate dynamically subtracting debits credits. part of me saying entries table grows ability generate balance each account slower (yes premature optimization supposedly evil), seems unnecessary add table when can calculate data existing tables. thanks edit: sorry may not have been clear, understand how implement either method of creating account balance. more looking advantages/disadvantages of either method 'best practice'. replies! if design minimalistic accounting application, like ledger ------------- key int(12) primary key account_id int(10) category_id int(10) trans_type char(3)

cocoa - Send window to back? -

i'm looking send window very of screen, in on desktop. i'm wanting launch , never above other apps. there way send window back? you´ll want use nswindowlevel, in specific kcgdesktopwindowlevel. short overview on nswindowlevel can found here , , more elaborate solution has been posted similar stackoverflow question before.

scramble - Form a word from a scrambled letters in java -

i'm doing game project,in have form words dynamically given set of letters... given set of letters may contain duplicate also.. while forming words can use letter given set of letters number of times(say twice or thrice)... me algorithm form possible meaningful words given set thank u all the simple approach create every possible ordering of letters, compare each 1 of them dictionary. you can refine bit storing dictionary in data structure facilitates quick lookups. (hash table, tree, etc) i've been meaning implement 28-ary tree quick dictionary word access, haven't got around yet.

OpenCOBOL Complex ODO (OCCURS DEPENDING ON) -

i new cobol(and opencobol) , question "complex-odo" (occurs...depending on) in opencobol. i used 1.0 on following code ...... 01 w-ptdo-proc-tbl. 05 w-ptdo-proc-entry occurs 0 450 times depending on w-ptdo-proc-max indexed w-ptdo-proc-indx. 10 w-ptdo-proc-apc pic x(05). 10 w-ptdo-proc-lnsub pic s9(07) comp-3. 10 w-ptdo-proc-key. 15 w-ptdo-proc-wa-offset pic 9(08)v99. 15 w-ptdo-proc-units pic 9(09). 10 w-ptdo-proc-device-cnt pic 9(03). 10 w-ptdo-proc-darray occurs 0 450 times depending on w-ptdo-darray-max indexed w-ptdo-darray-indx. 15 w-ptdo-proc-dhcpcs pic x(05). 10 w-ptdo-darray-size pic 9(03). 10 w-ptdo-proc-tot-dchrgs pic 9(10)v99. 10 w-ptdo-proc-tot-dunits pic 9(05). 10 w-ptdo-proc-used pic x(01). ...... and cobc retur

c# - .NET: Windows forms/controls performance -

we have application heavy ui. our clients started complaining application startup performance. (previously our controls/forms initialized while kind of splash screen message 'starting' shown). i've made research , found control's initializecomponent() (which generated vs designer) method call can take ~0.4-0.5s complex controls. , there lot of such controls, i'm getting ~10-15 seconds of application startup time result. there nothing heavy there, controls initialization (for example, different toolstrips, toolstripbuttons, menustrips initialization, setup of different texts etc). is there way improve performance of controls initialization in case? maybe kind of caching or smth (so our application start during first load)? p.s. we're using .net 2.0 thanks in advance. you indicate you've performed @ least rudimentary analysis of app's start-up time, have thoroughly profiled app using visual studio's profiler, ants or similar? tho

lucene - Solr %100 Write Availability During Optimize -

so here's dilemma... i'm running realtime search index solr, indexing 6m documents per day. documents expire after 7 days. every day, add 6m documents, , delete 6m documents. unfortunately, need run "optimize" every or else i'll run out of disk space. during "optimize", solr continues serve requests reads, write requests blocked. have writes behind queue, operationally, fine. however, since index large, "optimize" takes hour, , hour, no new updates available reads. index realtime except hour day optimize. during time, looks index behind hour. not optimal. my current solution this: write data 2 solr indexes, both behind queues. alternate "optimize" on 2 indexes every 12 hours. during "optimize" of index 1, direct read traffic index 2, , vice versa. time based routing seem pretty brittle , sloppy though. is there better way? as per comments here , faq here , optimizing should not necessary. not optimizin

compute and plot arithmetic functions in C++ for large integer? -

how can write c++ code , library can use compute , plot sum of divisors or similar arithmetic functions large integers, example integers bigger 10^100 000. for example code wrote in mathematica: g[n_] := product[prime[i], {i, 1, primepi[n]}]; k[999990]=g[237179]*g[661]*267064515689275851355624017992790*223092870*30030*44100*30*1296*512; k[999991]=g[237173]*g[661]*23768741896345550770650537601358310*200560490130*30030*44100*30*7776*256; k[999992]=g[237179]*g[661]*3217644767340672907899084554130*6469693230*30030*44100*30*7776*256; k[999993]=g[237173]*g[673]*267064515689275851355624017992790*6469693230*30030*44100*900*1296*256; k[999994]=g[237163]*g[677]*23768741896345550770650537601358310*200560490130*30030*44100*30*7776*256; k[999995]=g[237179]*g[659]*23768741896345550770650537601358310*6469693230*30030*44100*30*1296*256; ds[n_] := divisorsigma[1, n]; %sum of divisors f1[n_] := eulerphi[n]; %number of coprimes less n d[n_] := divisorsigma[0, n]; %number of

java - Hibernate: org.hibernate.AssertionFailure: null id in com.xxx.Bean entry -

i faced following error: com.google.gwt.user.server.rpc.unexpectedexception: service method 'public abstract void com.xxx.service.save(com.xxx.bean)' threw unexpected exception: org.hibernate.assertionfailure: null id in com.xxx.bean entry (don't flush session after exception occurs) @ com.google.gwt.user.server.rpc.rpc.encoderesponseforfailure(rpc.java:385) @ com.google.gwt.user.server.rpc.rpc.invokeandencoderesponse(rpc.java:588) @ com.google.gwt.user.server.rpc.remoteserviceservlet.processcall(remoteserviceservlet.java:208) @ com.google.gwt.user.server.rpc.remoteserviceservlet.processpost(remoteserviceservlet.java:248) @ com.google.gwt.user.server.rpc.abstractremoteserviceservlet.dopost(abstractremoteserviceservlet.java:62) @ javax.servlet.http.httpservlet.service(httpservlet.java:641) @ javax.servlet.http.httpservlet.service(httpservlet.java:722) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfiltercha

email - Call another PHP script and return control to user before the other script completes -

i'm trying apply script sends email. sending email part takes few seconds long. want first script stuff , trigger script (which sends email), want first script return control user without waiting second script send email. options have considered: cron job: i'll have have cron job run every 2 mins. not feasible! php script activating cron job deactivates when done : ok, how do this? can php this? you can call shell , manually call php file. no cron required , no waiting. http://www.php.net/manual/en/function.exec.php from notes section "if program started function, in order continue running in background, output of program must redirected file or output stream. failing cause php hang until execution of program ends."

c# - How to register UDF/RTD within VSTO project -

all, this follow question here . my setup: visual studio 10 language c# excel 2007+ windows xp+ what achieve this: create vsto addin excel custom ribbon component , custom task pane create rtd server create udf's wrap =rtd() -calls excel users have clients install addin through clickonce installation apart last requirement, done. problem have rtd server , udf's registered on target machine without using regasm.exe . want client indeed click once , forget it, since there hundreds of potential users, distributed geographically on whole world. also, since not technically savvy, not want them have register com components manually or that. i not care if udf's , rtd server separate project, long can include , register them vsto addin via clickonce. i looked registration-free com, not life of me able work in vsto addin. did create second project (a library class ) , trying export , register com interop, include 'main' project , use there: e