Posts

Showing posts from May, 2015

big o - Big-Oh Notation problem -

i think big-o notation n^2, im not sure. for (int = 0; < n -1; i++) { (int j = 0; j < n – 1; j++) if (x[j] > x[j+1]) { temp = x[j]; x[j] = x[j+1]; x[j+1] = temp; } } you doing n * (n * (4)) operations = o(n^2)

csv - In VBA, how do I use ADODB to query the same file on a hard drive at the same time? -

i have vba code looks , aim query csv file , bring records. however, want able query same file (which sits on network drive) @ same time 2 computers. tried using readonly mode still doesn't work. please help? dim cnt_string string cnt_string = "provider = microsoft.jet.oledb.4.0;" & _ "data source=" & "v:\data\;" & _ "extended properties = text;" strsql = "select * " & strdata & ".csv " & strdata & " (" & strdata & ".application_assigned_to='" & strbrokernumber & "')" sheets("broker").activate dim rs adodb.recordset set rs = new adodb.recordset call rs.open(strsql, cnt_string, cursortypeenum.adopenforwardonly, locktypeenum.adlockreadonly, commandtypeenum.adcmdtext) dim sh worksheet set sh = sheets("broker") call sh.range("a10").copyfromrecordset(rs) rs...

markup - How can I convert an Excel table into Trac Wiki Table format? -

i've seen copy & paste converters mediawiki or html format. not find 1 converts trac wiki format (wikiformattting) uses pipes separate cells, such as: ||cell 1||cell 2||cell 3|| ||cell 4||cell 5||cell 6|| you save excel sheet csv file. command prompt (assuming running windows xp or newer) type command: for /f "tokens=1,2,3 delims=," %a in (mycsvfile.csv) ((echo ^|^|%a^|^|%b^|^|%c^|^|) >> mywikifile.txt) the number of tokens depends on how many columns have. 26 columns way in single pass increasing number of tokens , adding corresponding number of variable names %d, %e, etc.

java - Comparison between woodstox and sjsxp -

has used stax implementation woodstox http://woodstox.codehaus.org , sjsxp https://sjsxp.dev.java.net/ . encountered wierd issue sjsxp xmlstreamreader not reading complete text value , tried woodstox resolved earlier issue. i wanted confirm guys if has used woodstox before , experience. apache cxf recommends woodstox. faster , less buggy. support sjsxp, source of mild-to-moderate hair pulling. our default, validated lots , lots of users, woodstox.

android - Ubuntu - Error: Failed to create the SD card -

i see lot of posts writing sd card, believe problem different. unable create sd card during process of building avd. i tried use android sdk , avd manager this, selecting name : my_avd target : android 2.2 - api level 8 sd card : size: 1024 mib skin : built-in: default (hvga) hardware : property: abstracted lcd density, value: 160 this pops window message: "result of creating avd 'my_avd': error: failed create sd card." i tried repeat process command line, receiving similar error: alex@alex-desktop:~$ android create avd -n my_avd -t 1 -c 1024m android 2.2 basic android platform. wish create custom hardware profile [no]no error: failed create sd card. attempting follow instructions using mksdcard equally unproductive; think basic lack of linux experience may causing me problem here. when try use mksdcard, reports cannot find file or directory. mksdcard tool available use way in linux? alex@alex-desktop:~$ mksdcard 1024m ./sdcard.iso bash: /home/alex/an...

Basic stucture of a C/C++ project (header files and cpp files) -

this brain-dead newbie question, here goes: what determines files included in c/c++ project? my understanding compiler starts file has main() in , file contain #include's various h files contain #include's other h files , on until included in project. my questions: what relationship between h files , cpp files of same name? mean, of course understand code-wise need each other , cpp file (almost always?) #include's h file, compiler's point of view important them have same names or convention? can include cpp files without corresponding h files? also, when project built , linked, how know cpp/h files build object files for? start @ cpp file "main()" in , keep going through #include's until has needs , build of that, or build user specifies in makefile or in ide project file? finally, when linker comes around , links object code make executable, there special order arranges in? any help, hints, explanations appreciated.. thanks! --r ...

constructor - Java: If object of same parameters exists do not add new object -

here object constructor static class edge { int source; // source node int destination; // destination node int weight; // weight of edge int predecessor; // previous node public edge() {}; public edge(int s, int d, int w) { source = s; destination = d; weight = w; } } now, here statement create new edge object edges.add(new edge(nodestart, tempdest, tempweight)); i need skip on statement if there has been object created same parameters (nodestart, tempdest) basically, don't want add same edge twice. edges.add(new edge(0, 1, tempweight)); edges.add(new edge(0, 1, tempweight)); if happens, want make sure adds once, , not new identical objects. the proper way make edges set<edge> . , override hashcode , equals. so, should declare edges so: set<edge> egdes = new hashset<edge>(); and should implement hashcode , equals so: public boolean equals(object o) { if (o == null) return false; if (o == this) ...

WPF TextBox binding to decimal respecting culture -

i've bound textbox decimal. problem ist, binding using american numerical standards, using dot decimals separation ("1.5") my system german , configured use colon decimals separation ("1,5"). i need textbox binding show , use colon instead of dot separate decimals. how binding respect set localization/culture settings numerical input? read this article . should set default language framework elements: public partial class app : application { static app() { frameworkelement.languageproperty.overridemetadata( typeof(frameworkelement), new frameworkpropertymetadata( xmllanguage.getlanguage(cultureinfo.currentculture.ietflanguagetag))); } }

ruby - Abnormal termination running an RSpec/Watir script -

i using ruby 1.8.6, watir 1.6.6, , rspec 1.3.0. when run following script, "terminates" (term given in eclipsepdt ide) no error listed. same when run c-prompt on windows, except no "terminate". browser never opens. got clue? runs ok if take off describe, it, , end lines. describe 'facebook' before :all @b = watir::browser.new @b = watir::ie.start('http://www.facebook.com') end 'default page links' @b.link(:class, 'fbxwelcomeboxname').text.should == 'dave mcnulla' @b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'home' @b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'profile' end 'home page links' @b.link(:href, 'http://www.facebook.com/?ref=home').click @b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'home' @b.link(:href, 'http://www.facebook.com/dave.mc...

asp.net - How do you stop source file information appearing in a Release? -

i building web application. here's do. set solution configuration manager release. projects building release version. clean solution , build all. "build deployment package". when running installed code deployment package notice when there bug in compiled source source file appears! how possible, building release configuration. source code not in release must in dlls. is there way stop this? assuming talking 'yellow screen of death' asp.net error pages, showing source code locations of exceptions; happening due including debug symbols in build , deployment package. *.pdb file(s) named same *.dll file(s). this not bad, in , of itself. however, should not displaying errors end-users regardless. without debug symbols, error messages show information. should handling errors , displaying 'safe , friendly' error message users. if want remove debug symbols, can remove pdb files. can change build properties in project, , remove option inclu...

C# image manipulation using a console application throwing 'Out of Memory' Exception -

i have console application re-sizes image while maintaining aspect ratio. i need crop image code using below: using (var thumbnail = croppicture(image, rectangle)) { encoderparameters encparams = new encoderparameters(1); encparams.param[0] = new encoderparameter(system.drawing.imaging.encoder.quality, (long)90); thumbnail.save(destination, getimagecodecinfo(image.rawformat), encparams); } public static image croppicture(image source, rectangle croparea) { using (var bitmap = new bitmap(source)) { return (image)(bitmap.clone(croparea, source.pixelformat)); } } it seems throwing out of memory exception on line return (image)(bitmap.clone(croparea, source.pixelformat)); any ideas what's going on? think it's open file can't 100% sure. according msdn documentation, bitmap.clone(rectangle, pixelformat) can throw outofmemoryexception if first parameter "outside of source bitmap bounds". verify first parameter bitm...

javascript - how to refresh the asp.net Label every second automatically using Java script instead ajax? -

how refresh asp.net label every second automatically using java script instead ajax? ajax javascript in combination webrequest, if don't want use ajax javascript data has come somewhere else... put @ end of page , replace label1 name of label nice working digital clock: <script type="text/javascript"> function updatelabel(){ document.getelementbyid('<%= label1.clientid %>').innerhtml = new date(); // replace new date() updated value settimeout("updatelabel()",1000); } updatelabel(); </script>

cookies - Remember me login - Asp script -

hello have create "remeber me login" asp script, have read many scripts procedure , have see many people use store username , password inside cookie. in opinion not secure (safety), advice you don't need store password. need username , if make sure encrypted ok save in cookie. important user not able tamper value , if server should detect it. sha1 hmac generation , aes encryption commonly used algorithms.

c# - Asynchronous TDD - Test Class blocks -

how create unit test test class sits in loop? here's scenario. i have class injected reference serial port. the class has method called send(string data); this public method invokes aysnchronous private method actual work. the class under test (cut) should following when method called. 1) split string chars. 2) send char 3) wait char echoed 4) send next char (repeat until chars sent) so after sending first char cut sit in loop waiting echo until receives 1 or times out. the problem have once cut has entered loop block test class until times out. since need test class send echo cut im stuck. to test i've created mock serial port , im using nunit. the test below. idea after sending test string wait cut respond. each time cut writes char serial port wait cancelled , write echo serial port , cut responds sending next char. [test] public void test() { _serialport.datasentevent += new eventhandler(_serialport_datasentevent); ...

sql - Count Distinct with NULL retention -

i using sql 2005 , having simple query below trap duplicates: select x,y,count(distinct z) z_count tbla group x,y having (count(distinct z) > 1) now issue column z having null values, ignored count distinct. such, duplicates having z null in 1 record , not-null in another, not getting trapped. can plz suggest how can around 1 single query? quick , dirty solution: replace null dummy-null value: select x,y,count(distinct coalesce(z, 'dummy-null')) z_count tbla group x,y having (count(distinct coalesce(z, 'dummy-null')) > 1) only possible, if can fake dummy-null value. edit: guess use count(distinct z) because rows having x=y=z shoud not considered duplicates (for reason). otherwise, duplicates of x=y use: select x,y,count(*) dup_count tbla group x,y having (count(*) > 1)

vb6 - What is the equivalent for VB's CreateObject in c# 3.0? -

i have below code in vb private sub refreshcharts() on error goto err_getichelper_refresh application.cursor = xlwait dim objoperationrefresh set objoperationrefresh = createobject("charting.automationproxy") dim variant set = application objoperationrefresh.refreshapplication application.statusbar = "refreshing .. " while len(objoperationrefresh.refreshstatus) = 0 doevents loop application.statusbar = "refreshing complete." set objoperationrefresh = nothing application.statusbar = "" exit sub err_getichelper_refresh: i have done conversion in c# except createobject("charting.automationproxy"). equivalent of in c# 3.0? thanks you use reflection: type type = type.gettypefromprogid("charting.automationproxy"); object instance = activator.createinstance(type); contrary vb , vb.net, c# doesn't support dynamic types until c# 4.0. com object poss...

filesystems - How can I create a file with invalid Windows timestamps? -

i'd create file invalid created/modified/accessed timestamp use in unit tests ensure application can handle files invalid timestamps. it's windows application written in c# run on both ntfs , fat32 filesystems. this not possible .

Set-based execution; SQL and .NET -

in sql, 1 should strive set-based operations versus iteration-based (i.e. looping). in .net, loop collections , objects. there commands in .net allow set-based processing or iteration-based? (i'm reminded of how dataadapter.fill calls datareader iterates through each record in result set). i'm not terribly familiar linq , guess implementation merely masks iterations happening behind scenes. update: to clarify: i'm not claiming sort of genius here , i'm not second guessing of brilliant people make life programming better. asking if there commands perform set-based operations, sql when update , versus foreach(var item in obj) { ... } iterating through object. sql developers chastised @ every turn if ever use loop, yet in .net, use them time. being develper works heavily in both sql , .net, i'm asking if there alternatives in .net avoid looping altogether. i'm not terribly familiar linq, guess implementation merely masks iterations happeni...

I have to parse a complicated string format. Is implementing an automaton a sensible approach? -

i struggling particularly obnoxious string format have parse. strings can contain substrings denote variable property has resolved. imagine "thisexamplestringcontainsa[variable_property]" . also, these properties can arbitrarily nested , can have different meanings, dependending on context. if [variable_property] in fact not valid name of variable (which of course has decided @ runtime), becomes normal part of entire string , remains unchanged , verbatim. followingly, there no invalid strings, number of opening square brackets not need match number of closing brackets! this]is[a[valid]]][exampletoo! . there more rules, give idea. so, @ moment unsure how approach this. first tries have ended in incredible mess of ifs , elses , noticed more , more solution should propably incorporate sort of state concept. now, thinking more , more using automaton this. however, have encountered automatons pure theoretical constructs. never came across actual implementation. furthermore,...

asp.net - Which gridview event to use to add items to the dropdownlist used in the edit template? -

i show different values in dropdownlist, while editing gridview, depending on user logged in. example... the officer see "approved officer" status. director see "approved director" status i trying add these programatically dropdownlist have in edit template of gridview (approvalsgrid). here code: protected sub approvalsgrid_rowupdating(byval sender object, byval e system.web.ui.webcontrols.gridviewupdateeventargs) handles approvalsgrid.rowupdating dim approvaleditdd dropdownlist = ctype(approvalsgrid.rows(approvalsgrid.editindex).findcontrol("approvaledit"), dropdownlist) if user.identity.name = "officer" approvaleditdd.items.add("approved officer") end if end sub i not errors. empty dropdown no items. using correct event? why not try this <script runat=server> string getapprovedby() { if (user.identity.name == "officer") { ...

indexing - Creating index/pk in a huge table is taking too long. I am using Oracle. How do I know if it is going well? -

i have huge table, ~200 million rows. had no index/pk @ all. selects in table (obviously) running slow. decided create pk using 3 columns. did in test environment has smaller version of table , worked charm. so, before going home did alter table hugetable add constraint pk_hugetable primary key (id1, id2, id3); i expected run on night, has been on 24 hours , still running. i know if had kept session id before starting query able track @ v$session_longops. didn't. is there way check how query going or how long still take? you should still able query v$session_longops. if run like select sid, serial#, start_time, sofar, totalwork, time_remaining, message v$session_longops time_remaining > 0 you'll see 1 session started yesterday , other columns should corroborate indications session has done lot of work. message should indicate full scan on hugetable.

html - z-index maximum value -

possible duplicate: mininum , maximum value of z-index what maximum value can use z-index? depend on browser? yes depend on browser http://www.puidokas.com/max-z-index/

c# - How to change the appearance of any control when property changes? -

i'd highlight user has been modified, know have changed or has been programatically changed behind scenes them. i want use styles apply logic controls, i'm not sure how. know need create trigger not sure trigger on or how pick changes bound property in order know if it's changed or not. thanks. probably best approach involves writing wrapper class values implements inotifypropertychanged , exposes read/write value property of type object , boolean valuehaschanged property. can change tracking pretty in value setter: if (!value.equals(_value)) { _value = value; valuehaschanged=true; onpropertychanged("value"); } instead of view model class exposing string or datetime properties, should expose valuewrapper properties wrap internal fields, e.g.: private string somestringfield; private valuewrapper _somestringproperty; public valuewrapper somestringproperty { { return (_somestringproperty == null) ? _s...

sql server - How to reverse values in a string in T-SQL -

using t-sql, i'm trying find easiest way make: "abc.def.ghi/jkl" become "abc/def/ghi.jkl"? basically switch . , / thank you one way select replace(replace(replace('abc.def.ghi/jkl','/','-'),'.','/'),'-','.') you need use intermediate step, chose - symbol, choose won't exist in string

java - Classification of Unit Testing -

assume have built mvc web apps written using java. now want write unit tests web apps, kind of unit testings should done normal mvc web apps? model testing controller testing ui testing db testing any more? i should write unit tests (model,controller,db) ui-testing considered integration test web apps better tested this tools . for swing , swt specialized tools available. for db-testing might want check dbunit open-source testing tools

Encoding error in Python with Chinese characters -

i'm beginner having trouble decoding several dozen csv file numbers + (simplified) chinese characters utf-8 in python 2.7. i not know encoding of input files have tried possible encodings aware of -- gb18030, utf-7, utf-8, utf-16 & utf-32 (le & be). also, measure, gbk , gb3212, though these should subset of gb18030. utf ones stop when first chinese characters. other encodings stop somewhere in first line except gb18030. thought solution because read through first few files , decoded them fine. part of code, reading line line, is: line = line.decode("gb18030") the first 2 files tried decode worked fine. midway through third file , python spits out unicodedecodeerror: 'gb18030' codec can't decode bytes in position 168-169: illegal multibyte sequence in file, there 5 such errors in million lines. i opened input file in text editor , checked characters giving decoding errors, , first few had euro signs in particular column of csv files. con...

Designing an Python API: Fluent interface or arguments -

i'm playing around simple port of protovis api python. consider simple bar chart example, in javascript: var vis = new pv.panel() .width(150) .height(150); vis.add(pv.bar) .data([1, 1.2, 1.7, 1.5, .7, .3]) .width(20) .height(function(d) d * 80) .bottom(0) .left(function() this.index * 25); vis.render(); i'm debating whether continue use fluent interface style api or use named parameters instead. named parameters write: vis = pv.panel(width=150, height=150) vis = vis + pv.bar(data=[1, 1.2], width=20, height=lambda d: d * 80, bottom=0, left=lambda: self.index * 25) vis.render() is there preferred python style? my vote anti-chaining, pro-named-params. dot-chaining makes poor code-intellisense since empirical prototype empty panel() or bar(), can of course pydoc on it, in day , age intellisense available in ides , great productivity ...

c# - WCF impersonation is not impersonating an administrator -

i trying use wcf remote user management things. , reusing code had on server 2003 box , worked fine, on windows 7 test box when check see if user called function administrator says not. [operationbehavior(impersonation=impersonationoption.required)] public string setpassword(string username) { windowsprincipal principal = new windowsprincipal(operationcontext.current.servicesecuritycontext.windowsidentity); system.diagnostics.debug.print(windowsidentity.getcurrent().name); system.diagnostics.debug.print(principal.identity.name); if (principal.isinrole(windowsbuiltinrole.administrator)) { //try { lock (watchdog.m_principalcontext) { using (userprincipal = userprincipal.findbyidentity(watchdog.m_principalcontext, username)) { string newpassword = createrandompassword(); up.setpassword(newpassword); up.save(); ret...

javascript - Sliding box with caption -

i have sliding boxcaption , works fine. when first view has box caption on , when mouse on works starts off caption on top. , want box caption show when user mouses on box. cant figure out why that. it's kind of odd. take @ here can see talking about. http://ironbulldog.com/windows/test.html below source code. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>testing</title> <style type="text/css"> *{ padding:0px; margin:0px; } body{ background:#d5dee7; } a{ color:#c8dce5; } h3{ margin: 190px 10px 0 10px; color:#fff; font:18pt arial, sans-serif; letter-spacing:-1px; font-weight: bold; } .boxgrid{ width: 325px; height: 260px; ...

iphone - Apple push notification enhanced format -

does know how error response apple push notification service when enhanced version of protocol used? according apple documentation if using enhanced version of push protocol can error response channel, error respose format: command(1 byte)|status(1 byte)|id(4 byte) statuses: 0: 'no errors encountered' 1: 'processing error' 2: 'missing device token' 3: 'missing topic' 4: 'missing payload' 5: 'invalid token size' 6: 'invalid topic size' 7: 'invalid payload size' 8: 'invalid token' 255: 'none (unknown)' here example code: ... socket = sslsocket ( socket.socket() , ssl_version = ssl.protocol_sslv3 , certfile ) socket.connect(apnshost, apnsport) len_written = connectioncontext.write(socket) errors = [] # wait input socket inputready = select.select ([socket], [],[], 1)[0] if inputready: replyblock = channel.recv (6) errors = [] #will filled error r...

asp.net mvc - TDD and MVC Model Binding -

let's have unit test: [test] public void lastnameshouldnotbeempty() { examplecontroller controller = new examplecontroller(); person editedperson = new person { firstname = "j", lastname = "" }; controller.editperson(editedperson); assert.areequal(controller.modelstate.isvalid, false); } and code: public class examplecontroller : controller { public actionresult editperson(int personid) { // serve view, whatever return view(person.loadperson(personid)); } [httppost] public actionresult editperson(person person) { if (modelstate.isvalid) { // todo - save modified person, whatever } return view(person); } } public class person { public string firstname { get; set; } [required] public string lastname { get; set; } } it's bothering me if tdd out requirement lastname can't empty, can't satisfy tes...

vb.net - VB, DES and MD5 -

hello guys trying migrate java code vb, need duplicate des encryption having trouble part. i admit haven't done encryption since college. this encrypt key using md5, , send function des encryption, seems got clue of error, key must 8 digit key , sending 16 length key. dim md5 new md5cryptoserviceprovider() dim datahash() byte = md5.computehash(encoding.utf8.getbytes(challenge + password)) dim sb new stringbuilder dim b byte each b in datahash sb.append(b.tostring("x2").tolower()) next dim md5key string = sb.tostring ''dim md5key string = digestutils.md5hex(challenge + password) dim geoencrypt new geoencriptamiento dim challengeanswer string = geoencrypt.encryptfile(challenge, md5key) this code encryption function encryptfile(byval esquema string, byval llave string) string dim des new descryptoserviceprovider() 'establecer la clave secreta para el algori...

floating point - Why do we have "is not a Number" (isNan) functions? -

many languages have isnan() function. asking myself: why check not being number ? is reason purely logical or faster check not number instead of is number ? note pure question of understanding. know can negate isnan() achieve isnumber() function example. searching reason why checking not number ? in computing, nan (not number) value of numeric data type representing undefined or unrepresentable value, in floating-point calculations. wiki article because not number special case of expression. you can't use 0 or -1 or because numbers have meanings. not number means went awry in calculation , valid number cannot computed out of it. it's on same line of thinking having null . sure, assign arbitrary numerical value mean null confusing , we'd hit sorts of weird errors on corner cases.

ajax - Copying file uploaded vai PHP's HTTP Get in PHP 4 -

i have been working on adding functionality site written in php 4.4.9. it's not in budget port site php5, don't suggest it. (although needs badly). problem facing how copy binary data request file location on server. code written support method follows: function save($path) { $input = fopen("php://input", "r"); $temp = tmpfile(); $realsize = stream_copy_to_stream($input, $temp); fclose($input); if ($realsize != $this->getsize()){ return false; } $target = fopen($path, "w"); fseek($temp, 0, seek_set); stream_copy_to_stream($temp, $target); fclose($target); } the problem having funciton stream_copy_to_stream supported in php 5. here have far, seems create files 8k in size , i'm not sure why. should, in theory, allow 20m. function save($path) { $input = fopen("php://input", "rb"); $temp = tmpfile(); fwrite($temp, fread($input, 2...

c# - list of all available server controls -

just title states, can point me list of available asp.net server controls (preferably descriptions)? have thought readily available i've had no luck finding this. have dig around find control solve particular problem, quick reference handy. msdn has list framework documentation, has links descriptions , examples controls (see classes list). list has few items in of controls eventargs classes , such. http://msdn.microsoft.com/en-us/library/8bhzsw6t(v=vs.80).aspx

flash - Flex video/audio chat for a site -

looking component can embedded inside site (php, asp.net...whatever) , give support video chat. i'm not flex developer , use component. there some/many video chats available, flashcoms, red5chat...but of heavy(monolit) components. what have on site small video showing output camera (me) , video showing other party...but videos should split, not in same flash component, separate (two different embed tags on page). are there components available (of course support appropriate media server)? there guides on how develop such component? thank much! you have program in flash, there no stright direct components waiting implemented, can use flash cs3 instead of flex!! let built small video object display camera, publish it, , capturing on swf small video object there play netstream object , add video object , voila!!!

Android: Control Hierarchy in Custom Components -

i'm reading android docs on custom component development , i'm little confused. if you're creating activity, can add add hierarchy of views via setcontent. however, if you're creating custom component, have handle in draw() overload. if want build custom component relies on view hierarchy, model create hierarchy internally , in draw call myviewhierarchy.draw() or something? however, if you're creating custom component, have handle in draw() overload. not necessarily. that's 1 approach, hardly one. if want build custom component relies on view hierarchy, model create hierarchy internally , in draw call myviewhierarchy.draw() or something? no. add children container, add logic container representing composite widget. example, have colormixer custom component combines 3 seekbars , 3 textviews (labels seekbars ), , plain view (used provide color swatch).

python - Test framework allowing tests to depend on other tests -

i'm wondering if there test framework allows tests declared being dependent on other tests. imply should not run, or results should not prominently displayed, if tests depend on not pass. the point of such setup allow root cause more readily determined in situation there many test failures. as bonus, great if there way use object created 1 test fixture other tests. is feature set provided of python testing frameworks? or such approach antithetical unit testing's underlying philosophy? or such approach antithetical unit testing's underlying philosophy? yep...if unit test, should able run on own. anytime have found wanting create dependencies on tests due code being structured in poor manner. not saying instance in case can sign of code smell.

how to create this linq query -

i have situation have list of ids such {1,2,3,4}. need pass method list of ids , if list has same numbers in return true, else if either list not identical (disregarding ordering) need return false. so, call method {1,2,3,4,5} should return false while call {2,4,1,3} returns true. sounds simple enough can't figure out how it. if guaranteed not have repeating elements in idlist , can use following: if (idlist.count == otheridlist.count && idlist.intersect(otheridlist).count() == idlist.count) { // contain same things. } else { // not contain same things. } the first check make sure they're same size. cheap way see if lists have chance of being identical, same strings. also, without it, statement return true if otheridlist superset of idlist . if cannot guarantee uniqueness within collection, think you're going have code yourself.

ssh - how to automatically run a bash script when my qsub jobs are finished on a server? -

i run script when of jobs have sent server done. for example, send ssh server "for in config*; qsub ./run 1 $i; done" and list of jobs started. automatically start script on server process output these jobs once completed. i appreciate advice me avoid following inelegant solution: if save each of 1000 job id's above call in separate file, check contents of each file against current list of running jobs, i.e. output call to: ssh qstat i need check every half hour, imagine there better way. it depends bit on job scheduler using , version, there's approach can taken if results-processing can done on same queue job. one handy way of managing lots of related job in more recent versions of torque (and grid engine, , others) launch individual jobs job array (cf. http://docs.adaptivecomputing.com/torque/4-1-4/content/topics/commands/qsub.htm#-t ). requires mapping individual runs numbers somehow, may or may not convenient; if can jobs, simplify m...

linux - rlwrap: Could not open master pty: No such file or directory -

when trying run rlwrap tclsh getting error message: rlwrap: not open master pty: no such file or directory what causes this? how fix issue? p.s. running 64 bit centos. check /dev/ptmx should have crw-rw-rw- once had crw------- caused error message @ system. see man ptmx : the file /dev/ptmx character file major number 5 , minor number 2, of mode 0666 , owner.group of root.root. used create pseudo-terminal master , slave pair.

actionscript 3 - Is there a way to keep an object always at the top of the display list? -

is there way make display object @ top of display list? for example, know can set childindex, i.e: setchildindex(mydisplayobject, numchildren-1); but there way object has sensed else has been added display list , restack accordingly? you can listen event.added event on container. event bubble up, you'll called whenever display object added container or of children. here's example of how this. you'll see black box stays on top. var container:displayobjectcontainer = this; // frame script change line necessary container.addeventlistener(event.added,handleadded,true); function handleadded(e:event):void { // if tries cover edge cases, unlikely happen in code, description if(container == topelement.parent && container.numchildren > 0 && container.getchildindex(topelement) != container.numchildren - 1) { container.setchildindex(topelement,numchildren - 1); } } function getsprite(c:uint):sprite { var sp:sprite = ...

c# 4.0 - Is there a way to new a class that's the same type as another class without directly specifying it -

i have extension method this public static void dostuff(this objectcontext context) { using(var newcontext = new myentitiescontext()) { // stuff newcontext.savechanges(); } context.savechanges(); } i wondering if there way new context of same type context passed in instead of specifying myentitiescontext? thanks in advance if don't mind reflection: var context = activator.createinstance(context.gettype()); now either need base type or - if still don't mind reflection - can call method name. or, since using c#4 go dynamic. edit: go way: public static void dostuff<t>(this t context) t : objectcontext, new() { using(var newcontext = new t()) { // stuff newcontext.savechanges(); } context.savechanges(); }

python - Basic Widget Interaction with PyQt -

please can tell me im doing wrong here respect calling pwtxt.text. #!/usr/bin/python import sys pyqt4 import qtcore, qtgui mainwindow import ui_mainwindow class myform(qtgui.qmainwindow): def __init__(self, parent=none): qtgui.qwidget.__init__(self, parent) self.ui = ui_mainwindow() self.ui.setupui(self) def on_pwextract_pressed(self): print self.pwtxt.text if __name__ == "__main__": app = qtgui.qapplication(sys.argv) myapp = myform() myapp.show() sys.exit(app.exec_()) the line print self.pwtxt.text fails because can't find widget, pwtxt qlineedit defined on main window. made in qtdesigner , generated python code pyuic4. how correctly reference other widgets on same window, in case want text qlineedit named pwtxt when qpushbutton pwextract pressed. thanks lot. try: print self.ui.pwtxt.text()

asp.net - Why am I getting this error "Internal connection fatal error" in only one of my stored procedures? -

this issue similiar here. what causes "internal connection fatal errors" except it's happening on 1 stored procedure , happening of time , happening when access stored procedure website. i've ran stored procedure in sql server , seems execute fine. what possibly error? as message say, problem on connection sql. because happends 1 procedure quest have left open connection database before try call store procedure. you can check connection turn on perfmon , see connection pool. if growing on time left open connections. also check if network stable, on lan, wan, web, local or remote ? in connection string use of this: 127.0.0.1 / localhost / or real ip address ?.

javascript - Possible preventing repaint when dynamically inserting script? -

as i've understood browser freeze dom rendering when sees script tag , continues once has processed it. when inserted external javascript file (typekit) directly in html seemed case, i'm including dynamically causes repaint of window. possible fixing issue? i'm playing around yui3 , yes know y.get.script works wanted try without framework well. using framework function causes same sort of repaint. live example: with loader: http://oxy.fi/oxy/ (and oxy/without_loader.php, not allowed post more 1 link) yui().use(function(y) { var modules = { modernizr: { head: true, js: ["scripts/modernizr-1.5.min.js"] }, typekit: { head: true, js: ["http://use.typekit.com/xxxxxxx.js"], onsuccess: function () { try{ typekit.load(); } catch (e) {} } } }; for(var index in modules) { var module = modules[index], css = module.css, js = module.js; ...

c++ - Update and multiple console windows -

i want write simple c++/c console app, show process 1% 2%. now, print line line like finished 1% finished 2% and etc how can update percentage x% without printing new line? also, want open 2 console windows 1 show messages 1 show process above. how open console window? on most-all terminals, can print ascii carriage return '\r' (value 13 decimal) return cursor left of current line, allowing overwrite previous value. or, can send backspaces ('\b', ascii 8) move single character left. neither automatically remove content displayed, can overwrite no longer want see spaces. alternatively, can use control codes supported particular console (e.g. vt100, vt220...), have more advanced features such "clear-to-end-of-line". many libraries available detect terminal type , use codes supports, or synthesize advanced operations many simpler ones necessary: on linux , unix, ncurses library choice. c++ has no concept of console windows. opening sec...

c++ - Do virtual functions have to be public? -

here way have base class working: class aguiwidgetbase { //variables aguidockingenum dockingstyle; std::string text; aguirectangle clientrectangle; aguicolor tintcolor; aguicolor fontcolor; std::map<int,int,cmpintint> children; //private methods void zeromemory(); virtual void onpaint(); virtual void onaddchildcontrol(aguiwidgetbase *control); virtual void ontintcolorchanged(aguicolor color); virtual void ondockingstylechanged(aguidockingenum style); virtual void ontextchanged(std::string text); virtual void onthemechanged(const aguitheme &theme); void (*onpaintcallback)(aguirectangle clientrect); void (*ontintcolorchangedcallback)(); void (*ondockingstylechangedcallback)(); void (*ontextchangedcallback)(); void (*onthemechangedcallback)(); protected: aguiwidgetbase *parentwidget; public: aguiwidgetbase(void); ~aguiwidgetbase(void); void addchildcontrol(aguiwidgetbase *con...

ruby - Capture variable amount of matches with regular expressions? -

how if @ can use regex match string variable number of matches. the strings want parse like: 'every 15th of month' 'every 21st , 28th of month' 'every 21st, 22nd , 28th of month' ad infinitum... i want able capture ordinal numbers (15th, 21st etc) the language i'm using ruby it's worth. thanks, alex you can capture them array scan , match occurrences of regex: irb(main):001:0> s = 'every 15th of month' => "every 15th of month" irb(main):003:0> s2 = 'every 21st , 28th of month' => "every 21st , 28th of month" irb(main):004:0> s3 = 'every 21st, 22nd, , 28th of month' => "every 21st, 22nd, , 28th of month" irb(main):006:0> myarray = s3.scan(/(\d{1,2}(?:st|nd|rd|th))/) => [["21st"], ["22nd"], ["28th"]] irb(main):007:0> myarray = s2.scan(/(\d{1,2}(?:st|nd|rd|th))/) => [["21st"], ["28th"]] irb(main):00...

objective c - Rewrite in place - stdout -

because i'm setting new server use, i've been using lot of command-line programs curl , wget , , i've noticed interesting. when run in terminal, print current progress in place (e.g. 54% become 55% in place, instead of 55% being printed on next line - download large file , see mean). i've been wondering how programs can this. writing stdout nothing new me, i'm puzzled @ how work. i've tried writing stdout , seeking backwards , writing again; printing backspace characters ( '\b' ), , printing new things; etc, nothing seems work. is there no api in objective-c or c this? (c, instance, has ungetc() , no unputc() ). there hacks can achieve this? interesting know more about... thanks! the ncurses project might of interest you. once beyond simple stuff, want focussing on core of app's logic, not presentation! gnu ncurses used every pretty terminal ui application come across.

java - Why do I get null pointer exception in this code? -

public class test { integer i; int j; public static void main ( string [] args ) { test t = new test (); t.go(); } public void go() { j=i; system.out.println(j); system.out.println(i); } } output : exception in thread "main" java.lang.nullpointerexception @ test.go(test.java:12) @ test.main(test.java:8) that's not error. runtime nullpointerexception because you're unboxing null reference ( i ) primitive ( j ). see jls §5.1.8 . the reason i null instance fields initialized 0, null, or false default.

html - Google Chrome - buggy curved borders? -

i have relatively positioned div within centred div of width 50%... mean outer 1 set width: 50% , margin-left/right: auto. have div class headercontainer , 1 class header. there image class headerimg within header div. it seem that, when curved border of 30px set on header div , headerimg img tag, slight overlap of border appears on either side... dont know how describe it... basically, in google chrome, 30px curved border appears perfectly, (about 2 out of 3 or 3 out of 4 times) appears border, hits rightmost , leftmost points, extends few pixels. there slight slant @ tip of either end, other border straight. if possible upload image on here show - isnt cant without signing image hosting site... basically want know if happens else... know tiny thing - sites pixel-perfect, not odd pixel out of place here , there - looks bad. anyway source code follows (i have simplified as possible...): body { font-family:verdana, arial, helvetica, sans-serif; font-size: 11px; m...

pygtk - GTK Widget object naming -

i writting pygtk application. using glade interface designer layouts. i want know if there standard way of naming widget object. eg : button called "configure" how should name ? eg : configurebt, buttonconfigure, configurebutton, etc i want app accepted in default ubuntu/debian/gnome setup. want follow standards requirements it. there's no "official" standard, you'll save headaches if use lowercase, underscore separated names (eg. refresh_button ). way, signal handlers can called eg. refresh_button_clicked , , glade can automatically connect them. match nicely python coding standards.

python - Tkinter or wxpython -

i want simple gui 1 of may apps , noob when comes gui itself. tkinter , wxpython 2 standards in python see.. 1 simpler , more intuitive? tkinter has hardly changed on years stable. wxpython comes alternative. some discussions may of interest while choosing between tkinter , wxpython http://wiki.wxpython.org/choosing%20wxpython%20over%20tkinter here comparison side side of building simple gui in tkinter wxpython. take @ , might in deciding seems better abstraction , liking. http://sebsauvage.net/python/gui/ also wxpython comes gui builder may create simple app faster , done with. nice ide gui designer wxpython or tkinter

how do i access instance variable of one class into other class define in other file in ruby -

i have 1 file named class1.rb structure module person class amit def initialize @a=10 end end end another file named class2.rb module person class sumit < amit def aos puts "#{@a}" end end end i not able acess variable @a in sumit how do that?? you may have here(adding-an-instance-variable-to-a-class-in-ruby) .

Transition from one page to another in Silverlight -

while using silverlight, if have lot of pages, techniques can used transition 1 page another. basically, want create mainpage have different sections, let's topleft, topright, bottomright, mainarea. these different sections load different pages transition. edit> think question not clear @ have been... want "effect" while page loads in same area. "slide in", "slide out", etc. any suggestions? check fluid layout

serial port - how to use CSerialPort in Qt? -

when add cserialport files(serialport.h, serialport.cpp) qmake project, , compile it, ide(vc2008) throw lots of errors, how deal it? i installed vc2008, qt4.6 windows visualstudio, , visualstudio plugin qt, , cserialport works right in normal mfc projects. i know there qextserialport, in beta condition..

How to write SQL query for aggregate total value for a particular condition -

vote table pk_id ob_type ob_id vote user_id voted_on 1 100 1 1 nishant 02/08/10 2 100 1 1 devi 02/08/10 3 100 1 1 virendra 02/08/10 4 100 1 0 xyz 02/08/10 5 200 1 1 xcxcx 02/08/10 6 200 1 1 cxc 03/02/11 7 200 1 0 xccx 03/02/11 8 200 1 0 xccx 03/02/11 9 300 1 1 xccxxc 03/02/11 10 300 1 1 xccx 03/02/11 11 300 1 1 sd 02/08/10 12 300 1 0 xccxxcc 02/08/10 13 400 4 0 cxxcxc 02/08/10 14 400 4 0 xccx 03/02/11 15 400 4 0 cxc 03/02/11 16 400 1 1 cxc 03/02/11 here want calculate total no of vote on particular object type , id. select count (all [pk_id]) [total_vote], coalesce ( ( ...

transport - How can an Audio Unit detect start and stop of its host? -

how can audio unit component detect start , stop of audio unit host? within component's kernel process(), tried callhosttransportstate(...) method, returns whether host playing or not, therefore can detect first start; process() not called anymore when host stops, can't detect stop way. , since stop not detected, can't detect next start because state "stopped" has not been detected. any idea? thanks. well, doesn't seem there particular property can listen regarding host transport state changes, means need monitor them yourself. off top of head, easiest way create new runloop (ie using cfrunloop or nsrunloop depending on whether in c++/obj-c layer) , pass reference idle function, in turn pass state of host's transport plugin. this task accomplished overriding idle() in vst world, since audiounits pull-oriented instead of push-oriented, need pull information , push plugin hand.

sql server - difference between set @flag =1 and set @@flag = 1 -

hi difference between set @flag=1 , set @@flag = 1 in sql server? thank you nothing. in-built functions have names start double @ signs @@ convention. avoid confusion recommended not use names start @@ . source: msdn: using identifiers - rules regular identifiers .

.net library to draw shapes images text etc, using GDI+ -

a stupid question here: is there such library these stuff? want more advanced library system.drawing namespace. you can @ open diagram @ codeplex: http://opendiagram.codeplex.com/

.net - DataGridView sample binding issue -

i need add variable pair list in form (name-value). decided set in datagridview, , use simple binging manage ( .net 2 ): public class eventparameter { private string name; public string name { { return name; } set { name = value; } } private string value; public string value { { return this.value; } set { this.value = value; } } } ///////////////////// user control initialization private list<eventparameter> eventgridparams; public grideventsender() { initializecomponent(); eventgridparams = new list<eventparameter>(); this.datagridview1.autogeneratecolumns = true; this.datagridview1.datasource = eventgridparams; } ///////////////////// add parameter button private void btnaddparam_click(object sender, eventargs e) { eventgridparams.add(new eventparameter()); } when launch application, see 2 columns, name , value autogenerated, , grid empty. but when click on add parameter butt...

Populate a PHP Dropdown List from MySQL Database -

i'm trying populate dropdown list in web page mysql database table has 1 column (pathology_id). know there test data in there best can populate box field name, not row values. code have far below, can suggest how more column name? in advance. <?php $con = mysql_connect("localhost","dname","dbpass"); if(!$con) { die('could not connect: ' . mysql_error()); } $fields = mysql_list_fields("dbname","pathology",$con); $columns = mysql_num_fields($fields); echo "<form action = newcase.php method = post><select name = field>"; for($i = 0; $i < $columns ; $i++) { echo "<option value = $i>"; echo mysql_field_name($columns , $i); } echo "</select></form>"; if(!mysql_query($sql,$con)) { die('error: ' . mysql_error()); } else { echo "1 record added"...

objective c - Getting Program received signal: “SIGKILL” when closing my application in multi tasking bar in iphone sdk -

i getting program received signal: “sigkill” exception when close application in multitasking bar of device.can suggest me why happening , how resolve it? anyone's appreciated. thanks all, monish. maybe experiencing snow leopard feature? to support improved shutdown, application needs mark “dirty” or “clean,” depending on whether has unsaved changes , needs work before quitting, or can terminated without further notice. when system shuts down, clean applications terminated (via sigkill) without further interaction. http://developer.apple.com/library/mac/#releasenotes/macosx/whatsnewinosx/articles/macosx10_6.html -> improved shutdown