Posts

Showing posts from September, 2010

What is Object::private and Object::public in Ruby? -

what these methods , how bad override them? irb(main):001:0> object::respond_to?('private', true) => true irb(main):002:0> object::respond_to?('public', true) => true the problem comes in rails when trying define scope named private or public model. because of fix bug https://rails.lighthouseapp.com/projects/8994/tickets/4167-activerecord-named_scope-using-columns-as-the-name-is-buggered there's lot of warnings like: creating scope :public. overwriting existing method mymodel.public. the public , private methods ruby's access modifiers. basically, when this: class example public def end private def something_else end end the public , private keywords not keywords @ all, they're method calls. i'm pretty sure it's not idea override them, i'd name scopes in other way.

objective c - storing objects in stl containers in a garbage collect environment -

i have mac os x app need store objective-c objects in stl containers (as pointers). works fine until compile program garbage collection "supported" due custom framework need use. problem objects stored in stl containers released. there way tell compiler not collect away , i'll release them when i'm done them? is possible? there way have framework uses garbage collection , main program doesn't? solve problem. can recompile framework, heavily relies on gc. you can disable garbage collection individual objects using nsgarbagecollector 's disablecollectorforpointer: method. hang around until call -enablecollectorforpointer: on it. i believe (but i'm not totally sure) can use cfretain / cfrelease on nsobject subclasses more or less same effect.

openssl - How can I verify an X509 certificate in python including a CRL check? -

i'm trying verify x509 certificate using python. in particular need check crls when it. now, can use m2crypto this, can't find option corresponding openssl's -crl_check or -crl_check_all. alternatively, use pipe , call openssl directly: p1 = popen(["openssl", "verify", "-capath", capath, "-crl_check_all"], stdin = pipe, stdout = pipe, stderr = pipe) message, error = p1.communicate(certificate) exit_code = p1.returncode however, seems openssl verify returns exit code 0, have compare strings somehow tell if verification successful, i'd prefer not do. am missing simple here? thanks. ok, i've done this: p1 = popen(["openssl", "verify", "-capath", capath, "-crl_check_all"], stdin = pipe, stdout = pipe, stderr = pipe) message, error = p1.communicate(certificate) verified = ("ok" in message , not "error" in message) it...

c# - My custom MSI will not install on Windows 7 or Windows Server 2008 R2 -

i have several deployment projects of them being web deployment projects. msis have installed on both vista , windows server 2008. not install on windows 7 or server 2008 r2 unless run console window right clicked "run administrator" unless this, none of installers install. i cannot force customers have open console window have install software. workaround now, our customers doing need fix in future releases. i tried creating launch condition , setting condition adminuser didn't work. thanks help. this error related user access control (uac) default settings. detailed steps of workaround read post: http://rambletech.wordpress.com/2011/09/15/windows-server-2008-you-do-not-have-sufficient-privileges-to-complete-this-installation-for-all-users-of-the-machine/ hth, ozzie.

Android 3.0 emulator only showing a fraction of the app when loaded -

so i've searched answer found nothing. basically, whenever run simple little menu app android tablets using eclipse android emulator 3.0, 1/6th of app shown (the top center piece, if tablet held landscape.) i've done tutorials using 2.2 emulator , work fine, whenever launch 3.0, app (and app - android home runs fine) doesn't appear. when @ in main.xml layout folder, graphical layout shows way want appear. problem emulator? can't common problem, otherwise i'm sure have found solution now, there must switch or i'm not seeing that's making app appear if running on phone , not tablet. do have low resolution set 3.0 avd? if run avd manager , resolution show?

java - Serializable subclass of non-serializable parent class -

i hitting brickwall serialization of subclass of location in android/java location not serializable. have first subclass called falocation not have instance variables. have declared serializable. then have second class called waypoint looks this: public class waypoint extends falocation implements serializable { /** * */ private static final long serialversionuid = 1l; /* class variables *******************************************************/ private static int class_version=1; //used version parcels /* instance variables ****************************************************/ private transient string type=datahelper.pt_type_us; private transient string country; private transient string name=null; private transient string description=null; private transient int elevation = 0; private transient int population = 0; // afterthought, added match db structure /* constructors ********************************************...

java - SQLNestedException Exception - Native SSPI library not loaded -

i getting exception below in server logs. mean , how fix it? org.apache.commons.dbcp.sqlnestedexception: cannot create poolableconnectionfactory (i/o error: sso failed: native sspi library not loaded. check java.library.path system property.) please add more detail in question. this seems common jtds error occurs when connecting sql server using windows authentication. if case try adding x86/sso/ntlm.dll (or equivalent variant server architecture) jtds distribution java.library.path using -djava.library.path=path/to/dll on jvm startup

iphone - Memory bad acces: Questions with releases, protocols and delegates -

i have little question memory management ios... well define own view have 1 protocol. in other class, create instance of other class, add view other view , then, try release de instance. problem appear when call method of protocol because receive bad_accs error. this: - (void)viewdidload{ class1 *c1 = [[class1 alloc]init]; [c1 setdelegate:self]; [self.view addsubview:c1.view]; [c1 release]; } - (void)methodofprotocolclass1 { nslog(@"c1 method called") } the class1 have 1 button , when press call methodofprotoclclass1 , makes error. know how release object? thanks, david you don't have release c1, instead must retain it! addsubview not retain c1 instance, retains view! if refer c1 later bad access

sql - Transaction deadlock for select query -

occasionally, have following error stored procedure select query: transaction (process id 91) deadlocked on lock my initial understanding select query won't lock table, or won't cause deadlock if table tries query being updated/locked process, seems select query can cause deadlocks well. if set isolation level read uncommitted query, solve problem? my init understanding select query won't lock table, or won't cause deadlock this understanding wrong. select queries take shared locks on rows analyze. shared locks may conflict exclusive locks update/delete/insert statements. 2 select statements not going deadlock, select can deadlock update. when such deadlock occurs, select victim did not perform update going loose draw. as deadlock, need post exact schema of tables involved, exact t-sql statements , deadlock graph. see how to: save deadlock graphs (sql server profiler) . information can receive guidance how fix deadlock.

jQuery draggable / droppable issue -

i've been trying implement simple draggable / droppable code (link below) no success. items drag, revert , stay in containment. however, when dropped in droppable area item gives alert, should, no longer draggable. ideally, have item draggable between drag , drop areas. in case user moves droppable area , changes mind. once in droppable area, allow item movable in there. am overlooking obvious? found searching looked pretty basic , straightforward implement. i've been searching , trying few things, haven't had luck. http://jsfiddle.net/ysa3h/2/ <div class="build_board_text" id="build_board_text"> <div id="src_landscape_8-5x11"> <div id="draggable_1" class="draggable_item"> <br />text 1. </div> <div id="draggable_2" class="draggable_item"> <br />text 2. </div> </div><!-- ...

html - How can I get a div to be minimum width when it's inside another div? -

i have 2 divs. div 100% width div b inside of div a, has no width set , has few words of text inside it i tried set bottom border div b text appeared underline. seems div b extends full width of div a. there way can make div b width of text. hope problem clear. thanks, divs block level elements, means expand 100% of width of container. if you're looking put border around text, wrap in inline element such span , apply border span. alternatively, use display:inline on div in question, there's no point using div purpose

javascript - Pre-loaded images not displaying in Chrome -

i pre-loading images , using them in lightbox. problem have although images loading, aren't being displayed browser. this issue specific chrome. has persisted through chrome 8 - 10, , i've been trying on , off fix time , have got nowhere. i have read these similar questions, chrome not displaying images though assets being delivered browser 2 minor crossbrowser css issues. background images not displaying in google chrome? javascript preloaded images getting reloaded which detail similar behaviour in chrome mac. whereas happening in windows. all other browsers seem fine. if have firefox , chrome open, load page in firefox, , in chrome, images appear. once have manually loaded images, using webkit webdev toolbar thingy, show up all links images , such fine , working clearing chrome doesn't seem make difference (cache, history, etc) if has ideas fantastically helpfull, i'm literally out of options here. ps, apologies if there late replies, i'm...

php - MySQL How to SELECT data from table which recorded today? -

use php , mysql. in table, there date field (datetime) recorded now() sql function. example value of data in field 2010-10-07 10:57:36 . how can select data day-month-year today. try use code below: select * table date=???? select * table date(date)=curdate()

Hide virtual key board in android and use my own -

i have own virtual key board application..i want use whenever there edittext field appears in window..for eg, when log in gmail want enter username , password through virtual keyboard app..any appreciated.. about switch current ime yours: have install ime app first. if no, maybe problem. settings --> language , keyboard --> ime should there , turn on check box.

bluetooth - How to determine BT headset type (SCO or A2DP) in Android SDK? -

i have broadcast receiver in app logs every connection of bt device tracking android.bluetooth.device.action.acl_connected broadcast. need know if bt device isa headset, , more importantly, if it's sco or a2dp headset. can find out services connected device supports using bluetoothclass.service, don't know services supposed correspong each type of headset. here ones listed: audio capture information limited_discoverability networking object_transfer positioning render telephony can tell me of these determiny headset profile type (headset, hands-free, or a2dp? you can use bluetoothprofile.servicelistener , listen onserviceconnetced , notifications a2dp or sco connected. see here

linux - file read buffer is empty in nasm -

i managed build nasm tutorial code dealing files. outputs contents of file stdout fine, when try access data buffer, contains zeros. example in code below in middle loop ebx set 0, when should contain file bytes. section .data bufsize dw 1024 section .bss buf resb 1024 section .text ; declaring our .text segment global _start ; telling program execution should start _start: ; code starts getting exec'ed ; filename in ebx pop ebx ; argc pop ebx ; argv[0] pop ebx ; first real arg, filename ; open file mov eax, 5 ; open( mov ecx, 0 ; read-only mode int 80h ; ); ; read file mov eax, 3 ; read( mov ebx, eax ; file_descriptor, mov ecx, buf ; *buf, mov edx, bufsize ; *bufsize int 80h ; ); mov ecx, 20 loop...

jquery - Setting upload_max_filesize (etc) for large file uploads -

i'm trying upload files via jquery plugin: http://aquantum-demo.appspot.com/file-upload i able upload files 1.2gb without problem. next largest file i've tried 1.8gb , upload fails. have set: max_execution_time = 0 max_input_time = 0 memory_limit = 4000m post_max_size = 3500m upload_max_filesize = 3000m what should these values if isn't working? need upload video files 2gb via method. thanks in advance! possibly you're on shared hosting memory limited. , 1.8gb sounds me 2gb, limit on 32-bit system integer, applies php also.

rspec - Sinatra + Rack::Test + Rspec2 - Using Sessions? -

it's first time i'm working sinatra , can't sessions work in tests. have enable :sessions in app. i tried: get "/controller/something", {}, "rack.session" => {:session => "aa"} or get "/controller/something", {}, "session" => {:session => "aa"} but no session variables being set in request. i've looked around web , tried several suggestions nothing seems work. missing something? thanks! rack doesn't support passing in sessions via request anymore (rack >= v1.0). read post more detailed information on that. the best way set session variable in app call action inside of application set session variable. instance, if have route inside app sets session variable this: post '/set_sess_var/:id' session[:user_id] = params[:id] end let's pretend there's route wanted test using session variable this: get '/get_user_attributes' user.find(se...

Display error using google maps tile server and Google Maps utility in PHP -

i have question regarding map tile server , coordinates conversion in google maps using google maps utility library. my tile server accesses database thousands of gps coordinates (lat,lng), , every (lat,lng) point, checks if point inside geographical bounds of tile; if does, coordinates conversion (wgs84 -> mercator -> x,y offset inside tile) , paints corresponding pixel inside tile, using googlemapsutility library. in terms of code, following: $point = googlemaputility::getoffsetpixelcoords((float)$row['lat'], (float)$row['lng'], $zoom, $x, $y); which calls getoffsetpixelcoords function (and in turn functions below) library: public static function getoffsetpixelcoords($lat,$lng,$zoom, $x, $y) { $pixelcoords = googlemaputility::getpixelcoords($lat, $lng, $zoom); return new point( $pixelcoords->x - $x * googlemaputility::tile_size, $pixelcoords->y - $y * googlemaputility::tile_size ); } ...

jquery - pass parents function arguments in a nested function? -

i having problem arguments object in nested function, seems arguments.length taken parent function while arguments[0] taken nested function... can explain why happening ?and show me effective way pass parent foo's arguments bar? $.fn.foo = function(color1, color2, time ){ return this.each(function bar(){ for(var = 0;i < (arguments.length - 1);i++){ alert(arguments.length); //this taken foo function , returns 2 alert(arguments[i]); //this taken bar } }); }; simple solution: local reference arguments . $.fn.foo = function(color1, color2, time ){ var args = arguments; // create private reference return this.each(function bar(){ alert(args.length); //use private reference }); };

Compare 1 parameter to multiple fields in mysql -

i want in query: $query = $mysqldb->make_query("select * dvd name '%{$str_param}%' or category={$str_param} or type={$str_param} or book={$str_param} or page={$str_param}"); where use 1 parameter, , compared of fields. warning: mysql_fetch_assoc() expects parameter 1 resource, boolean given please help, in advance. you have error in query make_query returns false instead of resource . since str_param assumes string, should enclose single quotes: select * dvd name '%{$str_param}%' or category='{$str_param}' or type='{$str_param}' or book='{$str_param}' or page='{$str_param}' make sure use mysql_real_escape_string on user-provided data avoid sql injection.

php - How do I create a link to add an entry to a calendar? -

i'm working nightclub , making website them, they've got lots events , site built lot around events, today make facebook event of every event killer have "add calendar" button added ical or google calendar (or maybe outlook). i've managed figure out how make calendar feed added new calendar, thing people can "subscribe events" it's quite messy have calendar every event. know how implement function lets them add main calendar easily. think mailto: link calendars if that's possible. also while i'm @ subject if know if it's possible automatically import event facebook wordpress or export event wordpress facebook great, that's not important. update (free personal use): while answer below detailing how-to each service work, imo it's easier go third-party addthisevent [http://addthisevent.com] . lets customize lots of options add facebook , more. unfortunately, they've made paid service other personal use , enfo...

.net - C# getting cookie data in the preinit event -

i have been seeing alot of code examples online of retrieving cookie data during preinit event, don't understand why want/have there. steadfast rule should getting cookie data in preinit event? you don't have cookie data in preinit event, helps in 2 ways: you minimize potential of cookies getting modified in later events during page life cycle. if trying affect things in control tree using values read cookie, need value during pre-init ensure values have chance job. otherwise late , control collection have been built. if don't need values affect page structure, or control flow, can read them whenever want. happens people use cookies change things in page life cycle read during preinit.

c++ - Can I access to symbols of the host process from a shared object loaded in runtime? Any alternative? -

in scenario want plugin, shared object loaded in runtime, access symbols “host application” can add functionality application. i have tried have not found way , have no clue on whether possible or not. so, can somehow or there alternative applications use plugins use? i on fedora 15, linux 2.6.4. however, hope solution cross-platform. there 3 main approaches: pass structure of function pointers dll application, giving access whatever symbols want share. portable method, kind of pain create function pointers. like: // in shared header struct app_vtable { void (*appfoo)(); }; // in plugin: const app_vtable *vt; void set_vtable(const app_vtable *vt_) { vt = vt_; } void bar() { vt->appfoo(); } // in application: void foo(); const app_vtable vt = { foo }; void loadplugin() { void *plugin = dlopen("plugin.so", rtld_lazy); void (*pset_vtable)(const app_vtable *) = dlsym(plugin, "set_vtable"); pset_vtable(&vt); void (*pbar)(...

WPF Attached Property Data Binding -

i try use binding attached property. can't working. public class attached { public static dependencyproperty testproperty = dependencyproperty.registerattached("testproperty", typeof(bool), typeof(attached), new frameworkpropertymetadata(false, frameworkpropertymetadataoptions.bindstwowaybydefault | frameworkpropertymetadataoptions.inherits)); public static bool gettest(dependencyobject obj) { return (bool)obj.getvalue(testproperty); } public static void settest(dependencyobject obj, bool value) { obj.setvalue(testproperty, value); } } the xaml code: <window ...> <stackpanel local:attached.test="true" x:name="f"> <checkbox local:attached.test="true" ischecked="{binding (local:attached.test), mode=twoway, relativesource={relativesource self}}" /> <checkbox local:attached.test="true" ischecked="{binding (loca...

c# - Visual studio - can't remove project configurations -

have major problem project configurations. started when wanted add new solution configuration (named "dev_withsource") based on existing "debug" configuration , checked "create project configurations". reason project configurations registered inside sln file, showing in configuration manager, "propertygroup condition" blocks in csproj files weren't created. resulted in "outputpath not set ..." error. so, tried repeat whole procedure. after deleting lines mentioning "dev_withsource" sln file, "dev_withsource" project configurations still showing in configuration manager. searched csproj , sln file in solution. neither of them contain text "dev_withsource". after event tried developing add-in. can fetch phantom configurations project.configurationmanager.configurationrownames can't delete them. missing something? configurations stored in other files , not csproj/sln? thanks. 1)...

mysql - Select only the last inserted item related to another registry -

i modeled small database easier explanation: create table bands ( id integer unsigned not null auto_increment, name varchar(120) null, primary key(id) ) type=innodb; create table albums ( id integer unsigned not null auto_increment, band_id integer unsigned not null, album_name varchar(120) null, rating integer unsigned null, insertion_date timestamp null, primary key(id), index albums_fkindex1(band_id), foreign key(band_id) references bands(id) on delete no action on update no action ) type=innodb; now, pretending have bands , many albums registered in respective tables, want select last inserted album each registered band. ps: have use "album.insertion_date" field determine album last inserted. try joining 2 tables , filtering insertion_date , band: select al.* albums al inner join bands b on al.band_id=b.id al.insertion_date=( select max(insertion_date) albums band_id=b.id )

android - What goes into Source Control? -

given: http://developer.android.com/resources/faq/commontasks.html#filelist what best practices getting projects source control? ask because if right click on project, choose team, etc. end /bin & /gen folders, .classpath eclipse related items. if i'm inheriting project .../workspace/projectname et al. included how can clean include items relevant aforementioned url? i summarized findings in blog post can found here: http://www.aydabtudev.com/2011/05/what-goes-into-source-control-android.html i executed following commands within project folder them out of source control: svn rm --keep-local .classpath svn rm --keep-local .project svn rm --keep-local default.properties svn rm --keep-local proguard.cfg svn rm --keep-local bin/ svn rm --keep-local gen/ then executed following command add them ignore list: svn pe svn:ignore . add each item above without associated command so: .classpath .project bin/ ... i followed commit , update solidify changes. ...

Validation summary display separately for each text box. in a asp.net website -

<asp:textbox id="txt_subject" runat="server" cssclass="txt_box"></asp:textbox> <asp:requiredfieldvalidator id="valsubjectrequired" controltovalidate="txt_subject" errormessage="subject required field." enableclientscript="true" display="none" runat="server" /> <asp:validationsummary id="valsummary" headertext="" showsummary="true" displaymode="list" runat="server" style="z-index: 1; left: 437px; top: 118px; color: maroon; /> i have text box , validation controls. have many text box , every text box required field display error message in validation summary. have positioned validation summary below form. have text box , labels inside table tag. how can display error message next text box. have scroll down , find out req fields. instead want display next text box. ...

jsp - Print all bean properties in EL without need to override toString() every time -

i have list/map of beans in el, or @ least assume , i'm fed spending hours going through trying work out sections belong each other. print plain ${example} . football.beans.footballfixture@72bec69[match=football.domain.footballmatch@773aa1d5[id=360496,competition=premiership,seasonid=2011,groupname=,roundtype=,roundnumber=,matchperiod=full_time,matchday=3,venueid=33,venue=white hart lane,venuecity=london,hometeamid=t6,awayteamid=t43,homescore=1,awayscore=5,scorers=[football.domain.score@3d5bed54[567825,away,2011-08-28 14:05:05.0,34,goal,dzeko,,first_half currently overriding tostring() on beans every time. it'd great have similar php's print_r in jsp. know how stop eternal headache caused problem. import jackson json library , (assuming "mylist" list/map have defined): objectmapper mapper = new objectmapper(); system.out.println( mapper.defaultprettyprintingwriter().writevalueasstring(mylist) ); this print out complete list object stri...

python - Why does my image not appear? -

hi wonder why image doesn't appear. think stored both blobproperty , in blobstore since appears thumbnail on list page. address page image doesn't appear http://www.koolbusiness.com/servead/4125209 and thumbnail same image appears in list http://www.koolbusiness.com/li some of template code display image is: {% if ad.matched_images.get %} <table><tr> <td> <div class="ad_pict" id="display_image"><img src="{{url}}" alt="" onload="show_hidden_elements();return false;"></div> </td> <td> {% ifequal len 1 %} {% else %} {% im in imv %} <div id="thumb0" class="ad_thumb ad_border_solid_black" onclick="showlargeimage('{{im}}');thumbnailborder(this, 5 )"> <table class="clean_table shadowed_thumb" cellpadding="0" cellspacing="0"> ...

path - How to get Point.X at a Point.Y on a FlattenPathGeometry - WPF -

i have "flattenedpathgeometry" , want able specific point.x path based on specific point.y basically need x value @ given y. thanks in advance help. getflattenedpathgeometry gives polygonal have consider loop points , calculating minimum distance point. if can make assumption on geometry shape or point, can speed search. for example if path long, can speed intersecting shape circle/square centered in point. limit number of points of shape test careful intersection method expensive. you'll have measure performances stopwatch understand what's better in case.

java - why is it only painting one of the components? -

package puzzle; import java.awt.color; import javax.swing.*; import java.util.*; public class puzzle { integer x = 50; integer y = 50; int x2 = 100; int y2 = 100; int vnotx = 0; int vnoty = 0; float t = 0; float t2 = 0; jframe frame = new jframe(); move m = new move(x, y,color.green); move n = new move(x,y,color.orange); java.util.timer timer = new java.util.timer(); java.util.timer timer2 = new java.util.timer(); public puzzle() { frame.setundecorated(true); frame.setsize(400, 400); frame.add(m); frame.add(n); frame.addkeylistener(new java.awt.event.keyadapter() { public void keypressed(java.awt.event.keyevent evt) { formkeypressed(evt); } }); com.sun.awt.awtutilities.setwindowopacity(frame, 1f); timer.scheduleatfixedrate(new timertask() { public void run() { rd(); } }, 0, 20); timer2.scheduleatfixedrate(new timertask() { public void run() { t2+=.01; ...

android - Event on EditText -

i have 1 edittext name eid ..now want user enter eid value ..an edittext "oid" oid should automatically generate it's value out of value entered in eid ..so event should use perform above task.. plz new in android you can use textwatcher on edit text, gets changes in edit text, , triggers appropriate functions. eid.addtextchangedlistener(new textwatcher() { public void ontextchanged(charsequence s, int start, int before, int count) { } public void beforetextchanged(charsequence s, int start, int count, int after) { } public void aftertextchanged(editable s) { // set oid value oid.settext(eid.gettext().tostring()); } }); whenever text change of "eid" method aftertextchanged called , set value of oid also.

Delphi XE2: Is there a predefined conditional to identify VCL and FireMonkey? -

in delphi xe2, have use {$ifdef win32} {$ifdef win64} to identify platform in. is there predefined conditional may identify vcl , fmx? as others says, there not conditional directive determine if application vcl or firemonkey. think reliable way determine if app firemonkey or vcl using function instead of conditional directive. something uses rtti; function isvclapp:boolean; begin result:= comparetext(trtticontext.create.gettype(tapplication.classinfo).qualifiedname,'vcl.forms.tapplication')=0; end; function isfiremonkeyapp:boolean; begin result:= comparetext(trtticontext.create.gettype(tapplication.classinfo).qualifiedname,'fmx.forms.tapplication')=0; end;

sql - doing "points of interest along a route" in google maps -

i need allow travelers use google maps plot route, , query database of points of interest (let's say, mcdonald's locations) , show of these locations within mile or 2 of route taking. question is, how efficiently take "driving directions" information comes google (essentially array of lat/long pairs), , turn sql query locations fall within distance route? it not have super precise, , "as bird flies" distances routes fine. i'm concerned being reasonably efficient. in database, things set pretty each entry having latitude , longitude, can change database schema needed. as example, site want (if give starting point , ending point, show chevron stations near highway taking): http://www.chevron.com/products/stations/stationfinder/planyourroute.aspx http://karmatics.com/docs/locationsalongroute.png check out http://google-maps-utility-library-v3.googlecode.com/svn/tags/routeboxer/1.0/examples/routeboxer-v3.html here's documentati...

regex - Javascript Regexp loop all matches -

i'm trying similar stack overflow's rich text editor. given text: [text example][1] [1][http://www.example.com] i want loop each [string][int] found way: var text = "[text example][1]\n[1][http: //www.example.com]"; // find resource links var arrmatch = null; var repattern = new regexp( "\\[(.+?)\\]\\[([0-9]+)\\]", "gi" ); while (arrmatch = repattern.exec(text)) { console.log("ok"); } this works great, alerts 'ok' each [string][int] . need though, each match found, replace initial match components of second match. so in loop $2 represent int part matched, , run regexp (pseduo) while (arrmatch = repattern.exec(text)) { var findindex = $2; // 1 in our example new regexp("\\[" + findindex + "\\]\\[(.+?)\\]", "g") // replace original match hyperlink } this match [1][http://www.example.com] end result first example be: <a href="http:...

Executing Hudson jobs remotely -

i trying automate hudson hitting appropriate urls remotely. using python's urllib2 doing same. first of , trying build existing job , build status. a sample url build this: http://tomcaturl:8080/hudson/job/.net%20build/build however returns me html data. hudson docs can data in python/json/xml format, try hit http://tomcaturl:8080/hudson/job/.net%20build/build/api/json but no data @ all, although build happens successfully. is there way find out build started remote build request, can maintain one-to-one mapping. please note doing through remote python program , not have access hudson gui. first of all, if have security/login enabled have logged in remote hudson server /job/jobname/build. if allow starting build without being logged in, not problem. the /job/jobname/build request return html data. if not logged in repsonse redirecting login page , build not started. if request successful not redirect login, , can assume build queued. can check build...

Aptana 3.0.5 Problems View with JavaScript -

i've looked migrating off coda , on aptana. realtime javascript/html/css error , warning notifications, intellisense while programming. installed aptana 3.0.5 , set validation include jslint. notice warning icons next line numbers, no list of warnings or errors appear in problems view/panel , puzzles me. i'm running os x lion 10.7.1, , decide test on macbook pro. same thing occurs. locate snow leopard 10.5.8 system , try out, , same thing occurs. so i'm wondering; errors , warnings in javascript appear in problems view? , if not, mean have scroll , down file locate errors way? thanks [edit: went aptana 2.0 , validation view seems working correctly.] are opening file project in workspace or directly local filesystem? if latter, expected behavior, problems view handles markers workspace resources. you promote local folder become project using the instructions here , , opening js file in project make errors appear in problems view. hope helps. ...

c# - How to tell the difference between an HtmlGenericControl that is a DIV and one that is a UL? -

i have code below: foreach (control c in mycontrol.controls) { if(c.gettype().equals(typeof(htmlgenericcontrol))) { //do } } my problem both ul , div tags considered htmlgenericcontrol. there condition add, divs enter if statement? check tagname property: foreach (control c in mycontrol.controls) { if(c.gettype().equals(typeof(htmlgenericcontrol)) && string.equals((htmlgenericcontrol)c).tagname, "div", stringcomparison.ordinalignorecase) { //do } }

html - Pure CSS dropdown menu -

i'm trying fashion 100% css , html dropdown menu what's seen on http://phpbb.com . when hover on navigation links, new div appears below 1 hovered onto. what i'm trying make .submenu appear below <li> it's nested using #nav li a:hover submenu { . knowledge css selector should select .submenu div when a element hovered over? doesn't work. #nav { list-style-type: none; margin: -5px 0px 0px 5px; } #nav li { display: inline; } #nav li { display: block; padding: 3px; float: left; margin: 0px 10px 0px 10px; text-decoration: none; color: #fff; font-weight: bold; position: relative; } #nav li a:hover { text-shadow: 1px 1px #333; } #nav li a:hover submenu { display: block; color: red; } .submenu { position: absolute; display: none; } <ul id="nav"> <li><a href="/">home</a> </li> <li> <a href="/">skins</a...

iphone - Opacity of image in IB is not correct -

semi-transparent images added resources. when viewed in interface builder doesn't show transparent did when had in photoshop. made sure opacity way wanted , background transparent pixels. tried saving image png-24 preset , checked transparency box in ps mobile , web. , in interface builder made sure opaque box in view attributes unchecked. after image doesn't display proper opacity set as. you need save png-32, 24 bits (3*8) rgb, doesn't have alpha channel.

SQL Server : create future dates -

how create future dates in sql? example, want able use date range , show next month (purchase orders), 2 months out, etc. have used fn now() current date/time doesn't me @ showing records next month, etc. thanks this sql query in doing in sql server 2008 r2. if use mysql can use: select date_col your_table date_col between now() , date_add(now(), interval 1 month) for ms-sql (it should work): select date_col your_table date_col between getdate() , dateadd(month, 1, getdate()) for oracle (it should work): select date_col your_table date_col between sysdate , add_months(sysdate, 1)

objective c - making a button pause and play a sound code error -

-(ibaction)pause { if ([theaudio ispaused]) { [theaudio play]; else { [theaudio pause]; } } } i have no property ispaused in .h maybe why. ispaused turns purple anyways. if need property please provide me 1 im new c the else inside if. should be: if ([theaudio ispaused]) { [theaudio play]; } else { [theaudio pause]; }

Creating a static c lib for ios -

i'm want compile c library iphone. i'm totally unexperienced , googled around , found her: compile c lib iphone the original source code of project want build compiles fine on mac , result contains following directory structure bin include lib share so after want build stuff can use on iphone. first step copy , pasted configure command link above , hit enter. result: ./configure --build=arm-apple-darwin --enable-static=yes --enable-shared=no cc=/developer/platforms/iphoneos.platform/developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 cflags="-pipe -std=c99 -wno-trigraphs -fpascal-strings -o0 -wreturn-type -wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.1.2 -gdwarf-2 -mthumb -i/library/iphone/include -isysroot /developer/platforms/iphoneos.platform/developer/sdks/iphoneos4.0.sdk -mdynamic-no-pic" cpp=/developer/platforms/iphoneos.platform/developer/usr/bin/cpp ar=/developer/platforms/iphoneos.platform/developer/...

http - Why are my files not served from the cache? -

i think configured caching correctly domain still both fiddler , firefox webdeveloper show me images, css , js loaded on every request. this response header 1 of images: server nginx/0.8.36 date sat, 30 apr 2011 05:02:58 gmt content-type image/jpeg connction keep-alive last-modified fri, 08 apr 2011 22:11:34 gmt etag "16456ec39f6cb1:0" x-powered-by asp.net microsoftofficewebserver 5.0_pub ms-author-via ms-fp/4.0 content-length 2885 expires tue, 24 apr 2012 05:02:58 gmt cache-control max-age=31104000 x-cache hit accept-ranges bytes so, have expires header item , cache-control has max-age value (should 1 year). if you're wondering: files served asp.net there cdn in between adding header items. where mistake??? the request ist "http://images.mydomain.com/filename.jpg". there no unique querystring parameters attached. try add cache-control: public, max-age=31104000 you can find more cache-control here . can fin...

java - Modify build.xml for another path for tomcat -

this should easy, i'm stuck trying modify build.xml i'm getting tutorial. see below: <?xml version="1.0"?> <project name="springapp" basedir="." default="usage"> <property file="build.properties"/> <property name="src.dir" value="src"/> <property name="web.dir" value="war"/> <property name="build.dir" value="${web.dir}/web-inf/classes"/> <property name="name" value="springapp"/> <path id="master-classpath"> <fileset dir="${web.dir}/web-inf/lib"> <include name="*.jar"/> </fileset> <!-- need servlet api classes: --> <!-- * tomcat 5/6 use servlet-api.jar --> <!-- * other app servers - check docs --> <fileset dir="${appserver.lib}"> <include name="servlet*.jar...

javascript - drawing a line in google maps perpendicular to two points -

i have 2 coordinates draw perpendicular line of equal length. there either simple google maps offset or clean javascript approach might accomplish this? be? here have far. can see, plot 2 points markers , attempt draw line between them, except need line perpendicular line between 2 coordinates. var locations = [ ['', position.coords.latitude, position.coords.longitude, 1], ['', llat, llng, 2] ]; var marker, i; ( var = 0; < locations.length; i++ ) { marker = new google.maps.marker({ position: new google.maps.latlng(locations[i][1], locations[i][2]), map: map }); } var borderplancoordinates = [ new google.maps.latlng(llat, position.coords.longitude), new google.maps.latlng(position.coords.latitude,llng) ]; var borderpath = new google.maps.polyline({ path: borderplancoordinates, strokecolor: "#ff0000", strokeopacity: 1.0, strokeweight: 10, map: map...

java - cobertura - Annotation to ignore files in instrumentation phase -

we use cobertura measure code coverage in unit testing , integrated/system testing. some classes more note suitable getting coverage in plain unit test. (some require database, gui testing etc). while mock objects, stubs, gui-unit-testing framework here, considering way mark classes not included in instrumentation. cobertura provides pattern based processing include/exclude classes. there way annotate class , skip instrumenting? without above, have write custom annotation processor list of classes, , user result skip instrumenting phase. if using ant run cobertura uses fileset use excludesfile parameter specify file containing list of files ignore. this list of files produced custom annotation parser or stick unique comment in files , search maybe like for file in `find ./ -name '*.java'`; if grep --silent "some unique tag" $file ;then echo $file > excludefile.lst; fi ; done

How to read single values that contains commas in csv file using python -

i have csv file contains following values "spam2,pank",spam3,spam6,spam7 spam1,spam5,spam0,spam9 and using following python code read particular column for line in open('d:\eggs2.csv','rb'): columns = line.split(",") print columns[0] the output gives is:- "spam2 spam1 while expecting : spam2,pank spam1 please me out on this. you don't have reinvent wheel, python csv module perfect job. import csv csv_file = open('d:\eggs2.csv','rb') csv_reader = csv.reader(csv_file) row in csv_reader: print row[0] csv_file.close() @see python csv

c# - Multiple text format in a RichTextBox -

suppose there 2 lines. red line. blue line. can with. you use: void appendtext(richtextbox box, color color, string text) { int start = box.textlength; box.appendtext(text); int end = box.textlength; // textbox may transform chars, (end-start) != text.length box.select(start, end - start + 1); box.selectioncolor = color; // set box.selectionbackcolor, box.selectionfont, etc... box.selectionlength = 0; // clear } and then appendtext(rtb, color.red, "line1"); appendtext(rtb, color.blue, "line2");

c# - Is TAPI in the WinRT API? -

i've not had chance play winrt yet. wondered whether knew if tapi part of winrt api now? according ms tapi not part of winrt although information preliminary , rather change on time... details see http://msdn.microsoft.com/en-us/library/windows/apps/hh464945%28v=vs.85%29.aspx

When and why might I assign an instance of a descriptor class to a class attribute in Python rather than use a property? -

i'm aware property is descriptor, there specific examples of when using descriptor class might more advantageous, pythonic, or provide benefit on using @property on method function? better encapsulation , re-usability: descriptor class can have custom attributes set on instantiating. it's useful keep data confined in manner, instead of having worry getting set or overwritten on descriptor's owner.

javascript change element size doesn't work properly -

i'm trying create javascript function (onmouseover) increase elements height , width 10px (1px increase 10 times settimeout), instead element increases 200px in height , 100px in width. doesn't make sense. example on how it's not working properly: www.modwebsolutions.com/test3/ source code: var el; function changesize(id) { var elem=document.getelementbyid(id); el=elem; (var i=0; i<10; i++) { settimeout(changes,100); } } function changes() { var tempheight=el.offsetheight; var tempwidth=el.offsetwidth; el.style.height=tempheight + 1 +"px"; el.style.width=tempwidth + 1 + "px"; } // update: tried el.style.height=(parseint(tempheight) + 1) +"px"; el.style.width=(parseint(tempwidth) + 1) + "px"; this time adds 50px height , still 100px width... instead of 10px each way. update: seems i'm gonna have answer own question, i'm still not sure, think has iterations running ahead of settimeout , messin...

objective c - Capture mac screen -

what best way record mac screen cocoa? know there many examples @ apple developer reference library. sonofgrab explain how capture screen quartz isn't enough fast use grab many frames every second. openglscreensnapshot has same results isn't fast, too. openglscreencapture seems best way xcode prompts me many errors because it's made 10.4 , requires old quicktime commands think pushed qtkit can't find way convert it. send me someone's site converted project or tell me if there other ways it. in advance. opengl way go. should still able use openglscreencapture sample if architecture set 32-bit. (quicktime not available in 64-bit.) -ken

c# - System.Exception.Data Property -

the system.exception class (actually exception) has data property empty. while throwing exceptions, should field of use? or have internal use not aware of? the documentation seems clear enough use (emphasis added): gets collection of key/value pairs provide additional user-defined information exception . why exist in first place? assume it's same reason control has tag property . in days of .net (before every bob , betty programmer understood objects , inheritance) wanted make api simple enough figure out how add data things. however, point of creating custom exceptions derive system.exception not include additional information, make possible client limit exceptions catch only can handle. if know how handle set of defined exceptions code can throw, should able only catch exceptions, without having catch base system.exception class. should never require client code catch non-specific exception class , read property determine type of exception (and whet...

java - How to properly implement android.os.Handler class instead of Timer in Android application? -

so wanted implement timer in anroid program , found out better way using handler class. first decided write simplest program using handler - text set after 1 second. i'm totall beginner in android, went through tutorials on web 1 http://developer.android.com/resources/articles/timed-ui-updates.html , still application shows error ("application mtimer stopped"). so point out making mistake? gratefull, here's code: public class mtimer extends activity { textview tv; button button1,button2; handler mhandler; private runnable mytask = new runnable() { public void run() { tv.settext("text"); } }; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button1=(button)findviewbyid(r.id.button1); tv=(textview)findviewbyid(r.id.textview1); button1.setonclicklistener(new view.on...

c++ - Trying to use int in getline -

cout << "how many questions there going on exam?" << endl; cout << ">>"; getline(cin, totalquestions); this small piece of code comes function in class have created , need totalquestions int can run through loop , keep asking total amount of questions have asked. question q; for(int = 0; < totalquestions; i++) { q.inputdata(); questions.push_back(q); } where piece of code comes play? have idea make work? use cin >> totalquestions; check errors too if (!(cin >> totalquestions)) { // handle error }

multi-environment deployment with Vlad and nginx -

i'd able deploy staging , production environments vlad deployer. i've created separate task each environment, since each environment prepared differently. trying organize nginx configurations. should create 2 separate nginx configs, put them sites-enabled folder , include them in nginx.conf? i think depends on complexity of environments. files in sites-enabled folder allows have more clean structure. if have 2 servers , described 10 lines, isn't necessary.

Retrieve hashed PHP password from database and check against a submitted password in Javascript -

i have options page in project , in can change password. have form asks enter current password , new password , confirm password . check data errors , send server using jquery ajax . the problem have need check current password against password stored in database. the database password hashed using php sha1($database_password.$salt); i thinking pass php variables, $database_password , $salt javascript somehow , use sha1() js alternative sha1 javascript code see if current password matches database password . can give me pointers or there alternative ways? i think it's better leave password hash on server. can ajax request current password , have server validate it. way hash remains unknown user , brute force attack more difficult. of course should send current password (and new password) once user indicates has finished typing (ie. when clicks submit button).

java - Why is ServletConfig obj passed to init() of GenericServlet when the class implements the interface? -

genericservlet implements servletconfig interface means interface functions can invoked init() function of genericservlet . given context, why servlet container sends servletconfig object init() method? know if servletconfig object passed genericservlet.init(servletconfig) different genericservlet object. regards, ravi the genericservlet implements servletconfig methods delegating config object passed init method. implements servletconfig convenience - delegates. instead of calling getservletconfig().getinitparameter() can call getinitparameter()

python - How do you Identify the interface of a packet while listening to network traffic on all devices? -

Image
i writing python program needs listening traffic on networking devices , identify packets based on incoming interface. listen on interfaces started capture without specify device, unable denote interface of particular packet. how done? i assume mac address sufficient information you. the first 6 octets of packet destination mac address, followed 6 octets of source mac address. source

sql - Issue with complex Django join query -

i can't find valid way django omr in order : ( raw query fine ) the sites.sitename made analysis (analysi_items.name='somename' , analysis_items.value='somevalue') , (analysi_items_name='somename' , analysis_items.value='somevalue') , (analysis_items.name='somename' , analysis_items.value='somevalue'). class sites(models.model): region = models.charfield(max_length=1000) province = models.charfield(max_length=1000) sitename = models.charfield(max_length=1000, primary_key=true) class meta: verbose_name_plural = "sites" def __unicode__(self): return self.sitename class analysis_items(models.model): code = models.foreignkey('analysis') name = models.charfield(max_lenght=100) value = models.charfield(max_length=20) class meta: verbose_name_plural = "analysis type" class analysis(models.model): date = model...

android - Dynamically add or remove views -

for project need functionality dynamically add , remove views(textedit or buttons, etc). i saw similar functionality in android "add contact" screen, plus button add new fields , minus button delete fields. i found editcontactactitivity.java file behind "add contacts". i tried find methods called when plus or minus buttons pressed unable find it, seems "add contact" code spreaded on multiple files. having difficulty understanding android source code because documentation unavailable. advice? you can add , remove views calling .add() or .remove() on reference main layout , passing view wish add or remove; here simple example of oncreate method demonstrates adding , removing button: public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); linearlayout mymainlayout = (linearlayout)findviewbyid(r.id.yourmainlayout); button b = new button(this); //you can...

ide - Aptana Can Not find the Ruby Executable -

when try run ruby code, pop says "launching differences2.rb' has encountered problem. unable find ruby executable. when run 'gem environment' inside aptana this: gem environment rubygems environment: - rubygems version: 1.8.6 - ruby version: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux] - installation directory: /home/adamar/.rvm/gems/ruby-1.9.2-p290 - ruby executable: /home/adamar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby - executable directory: /home/adamar/.rvm/gems/ruby-1.9.2-p290/bin - rubygems platforms: - ruby - x86_64-linux - gem paths: - /home/adamar/.rvm/gems/ruby-1.9.2-p290 - /home/adamar/.rvm/gems/ruby-1.9.2-p290@global - gem configuration: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - remote sources: - http://rubygems.org/ when run 'ruby -v' inside aptana this: ruby -v ruby 1.9.2p290 (201...