Posts

Showing posts from May, 2014

java - Using BigInteger Multiply operator -

i wondering if there way multiply biginteger variables together, because * operator cannot applied biginteger . so wondering if possible multiply 2 bigintegers without using * operator. you use biginteger s multiply() method so: biginteger int1 = new biginteger("131224324234234234234313"); biginteger int2 = new biginteger("13345663456346435648234313"); biginteger result = int1.multiply(int2) i should have pointed out while ago biginteger immutable. result of operation has stored variable. operator or operand never changed.

python - Determine if a dice roll contains certain combinations? -

i writing dice game simulator in python. represent roll using list containing integers 1-6. might have roll this: [1,2,1,4,5,1] i need determine if roll contains scoring combinations, such 3 of kind, 4 of kind, 2 sets of 3, , straights. is there simple pythonic way of doing this? i've tried several approaches, have turned out messy. reorganize dict value: count , test presence of various patterns.

Is there a do-until (postcondition) loop in Scala 2.8? -

an algorithm of mine better readable if use postcondition (do-until) loop instead of precondition (while) loop. there such feature in scala 2.8? sure. scala> var = 0 i: int#4363 = 0 scala> { | println(i) | += 1 | } while (i < 10) 0 1 2 3 4 5 6 7 8 9 res0: unit#3773 = ()

iphone - Crash on CGPDFDocumentCreateWithURL -

i exc_bad_access on code: nsurl *pdfurl = [nsurl urlwithstring:path]; pdf = cgpdfdocumentcreatewithurl((cfurlref)pdfurl); cfrelease(pdfurl); 'path' nsstring path the file loading documents directory. have chanced ensure path correct. running on simulator don't see why should make difference in situation. any ideas why crash occurring? thanks don't release pdfurl. urlwithstring: returns autoreleased object.

svn - backing up subversion repositories -

centos 5.3 subversion 1.4.2 i forgot add. total repository size 5gb, grow on time. we have our source code , documents on our internal server running centos 5.3 , using subversion 1.4.2. we looking backup strategy. want perform daily backups. have 30 repositories backup of differing sizes. i create script file , recursively backup using svnadmin dump. however, looking automated backup system run nightly 12am each day. does know of backup systems open-source? think company reluctant pay system. many advice, there more open source solutions name, application choice rsync , cron job. here overview of open source options (some more desktop oriented). edit the nice thing rsync, can directly sync folder storing repo. downside of approach sync corrupt repository. doing dump , storing incremental backups protect this. despite recommended above, personal preference avoid subversion altogether. dvcs git or mercurial, ever developer's has full working ...

not able to include one html file in another -

a.html abc b.html <!--#include file="a.html" --> xyz access b.html: file:///home/kurz/desktop/b.html it shows xyz is not way include files in html? what you're attempting called server-side include (ssi). such, requires pages running on webserver, rather local file. when you're requesting page server, server sees <!--#include file="a.html" --> preprocessor , performs ssi. when you're referencing directly filesystem, such file:///home/kurz/desktop/b.html , browser doing loading raw html , interpreting that.

WPF DataGrid: How to clear selection programmatically? -

it simple task in grid, can't make happen in wpf datagrid. there unselectall or unselectallcells methods, don't work. also, setting selecteditem = null or selectedindex = -1 don't work either. there post here disable selection, that's not want. want clear current selection (if any) , set new selection programmatically. datagrid.unselectall() for rows mode

ruby on rails - calling actions in other controller -

i have controller called twits controller .. here have few actions communicate 3rd party api.. has few actions authenticate , few actions values of api. have controller called home , in index page of controller have call actions of twits controller , should happen while index page getting rendered. please advice. calling actions of 1 controller bad idea. should extract functionality module or class , use in both controllers. so in case, should writing wrapper class communicating 3rd party api , use wrapper. note wrapper class not abstracted wrapper general use, functionality legacy code provides, intend reuse. hope helps. if isn't, try posting code , maybe can suggest more.

java - Rounding a value in JDOQL -

i've got data in gae data store. want write jdoql against data takes 1 of columns , rounds value of it. can this? do mean, can update data in datastore have rounded value? if so, sure. query them, update property, , store them in datastore. if mean, can write query filters based on rounded value instead of real value, yes. you'd adjust queries , filter values. example, if want entities rounded value >= 5, you'd use 4.5 filter value: query query = pm.newquery(foo.class, "property >= 4.5"); if want entities rounded value of 5 exactly, you'd query between 4.5 , 5.5: query query = pm.newquery(foo.class, "property >= 4.5 && property < 5.5");

google app engine - Created HTTP response to be the same as accessing .jpg in Python -

i want server image file accept attributes processing before hand using python , google app engine. where have 'http://www.domain.com/image/desiredimage.jpg' as image server. i want able add tracking can similar to 'http://www.domain.com/image/desiredimage.jpg?ref_val=customerid' i figured best way have "proxy" image requests like 'http://www.domain.com/imageproxy?img=imgid&ref_val=customerid' and have imageproxy url process ref_val value , serve image based off imgid value datastore db.blob value. when access proxy url shows image , processes fine. when used url in other 3rd party javascript json requests looking image url, nothing show up. i guess root of question how accessing 'http://www.domain.com/image.jpg' different accessing 'http://www.domain.com/script_that_returns_image' where latter url python script outputs self.response.headers['content-type'] = 'image/jpeg' sel...

php - JQuery Validation not working on Ajax Control....! -

hi there have problem code want validate states generated ajax response.text here jquery state field: $(document).ready(function () { var form = $("#addstudentfrm"); var state = $("#state"); var stateinfo = $("#stateinfo"); state.blur(validatestates); state.keyup(validatestates); function validatestates() { if (state.val() == '') { state.addclass("error"); stateinfo.text("please select/enter state"); stateinfo.addclass("error5"); return false; } else { state.removeclass("error"); stateinfo.text(""); stateinfo.removeclass("error5"); return true; } } }); here php function states in respected country: public function getallcountrystates($post){ $que = "select * ".wmx_country." code = '".$post[value1]."...

sql server - Why must QUOTED_IDENTIFIER be on for the whole db if you have an indexed view? -

yesterday added indexes on view in mssql 2008 db. after seems store procedures need run quoted_identifier set on, don't use view in question. why so? can configure on db or have update stored procedures set quoted_identifier on? think rather weird required stored procedures not using view. do these stored procedures relate base table(s) view based upon? quote creating indexed views : after clustered index created, connection tries modify base data view must have same option settings required create index. sql server generates error , rolls insert, update, or delete statement affect result set of view if connection executing statement not have correct option settings. more information, see set options affect results. and it's kind of obvious, when think - you're potentially going updating contents of view whenever touch these base tables, , inherit same responsibilities when created index. you can set defaults @ multiple levels ...

c# - create file and save to it using memorystream -

how can create file , write using memory stream? need use memorystream prevent other threads trying access file. the data i'm trying save file html. how can done? (presuming mean how copy file's content memory stream) if using framework 4: memorystream memorystream = new memorystream(); using (filestream filestream = new filestream(filepath, filemode.open, fileaccess.read)) { filestream.copyto(memorystream); }

asp classic - How to debug Python inside a WSC -

we're programming classic asp big (legacy) web application. works quite using wsc (windows script components) separate gui business logic; wscs contain business logic, classic asp used displaying returned information. wsc's return stringvalues, ado recordsets , in cases vbscript-objects. currently we're trying switch using vbscript inside wscs python (pyscript), @ least language used modern , has more modern features available (like soap, orm solutions or memcached). using python code in classic asp works fine using pywin32 , registering python scripting language, we're experiencing 2 fundamental problems: in wsc, using "implements" tag should make of iis' standard objects (server, session, request, response, etc.) available code inside wsc. when using python, doesn't seem work. maybe i'm using incorrect syntax, or need definitions in python code, can't seem figure out how these objects. more info on wsc's: http://aspalliance.com...

Are nhibernate entities part of the BL? -

i looking right n-tier modal adapt new nhibernate project. quite new it. have several entities , corrosponding mapping classes. can't seem figure if entities should act bl level classes, or merly object oriented part of dal. can shed light on this? thank you. your entities defenetly part of bl layer. should reflect business meaning. example if writing online shop have user entity , have list of order entities , on. you can have @ different examples , best practices of nhibernate usage, such sharp architecture , nhibernate best practices putting entities in business layer while mappings in data access.

MySQL query help needed to get clients who haven't bought anything in more than 180 days! -

i have table orders stores info orders(including ordersname,orderssurname,ordersemail,ordersphone) info need get. it contains field ordersfinishedtime datetime field stores data when order finished. what need select ordersname,orderssurname,ordersemail,ordersphone orders table users haven't bought in more 180 days. that - need find unique users who's last unique purchase more 180 days ago. thanks in advance! edit: i know how find records order 180 days, need records 180 days older , there no more orders(for particular user) after date! edit2: not reading question through. need find unique users haven't purchased in more 180 days. don't need orders older 180 days, need user info stored in orders. my current sql query this: select distinct o. ordersemail ,o. ordersname ,o. orderssurname ,o. ordersphone ,o. ordersfinishedtime (select ordersphone , max( ordersfinishedtime ) ordersfinishedtime orders year( ordersfinishedtime ) >= 2010 group orders...

javascript - XmlHttpRequest.responseText while loading (readyState==3) in Chrome -

i trying "streaming" (from server client) in javascript ajax (by xmlhttprequest (=xhr). using modified handleresponse function described in cross-browser implementation of "http streaming" (push) ajax pattern function handleresponse() { if (http.readystate != 4 && http.readystate != 3) return; if (http.readystate == 3 && http.status != 200) return; if (http.readystate == 4 && http.status != 200) { clearinterval(polltimer); inprogress = false; } // in konqueror http.responsetext null here... if (http.responsetext === null) return; while (prevdatalength != http.responsetext.length) { if (http.readystate == 4 && prevdatalength == http.responsetext.length) break; prevdatalength = http.responsetext.length; var response = http.responsetext.substring(nextline); var lines = response.split('\n'); nextline = nextline + response.lastindexof('\n') + 1; if (response[respon...

visual studio 2008 - c/c++, mfc: Not passing open files / handles to a spawned process -

in unix know routine: between fork() , exec() in child close except stdin/out/err, open ports or files not passed program want run. but how do in windows? in case i'm implementing dll in c/c++, , need close both files opened (indirectly via objects) , sockets opened application loaded dll, these open file handles not passed application i'm spawning. app doesn't pass handles dll, code shouldn't need those... so far code calles _spawnl(_p_nowait, "foo.exe", "foo.exe", "arg1", "arg2",null); visual studio 2008 if matters. thanks help. hmm - sorry guessing here little, sure spawnl in windows passes open file handles? if so, maybe want @ createprocess, , startupinfo - these allow finer control on gets passed/inherited new process

c# - Theater Seating application in WPF -problems in databinding -

i new wpf, , want develop application theater seating in wpf- c#.net. did research lost not know how each seat's data (sold or not, price, in row) should bound field in table in sql express. should using observablecollection populate contents of datatable in it? also, should using grid of buttons? or rectangles? how should proceed if want front left , front right buttons inclined bit instead of being horizontal? should using wrappanel if want have 3 areas seats? left area, space alter, middle area, space alter , right area? if can give me hints me start, more glad. in advance... you're asking lot of questions @ once, , impossible answer them without writing program you, i'll offer high-level approach take. you'll have spend time dig details. plenty of info on stackoverflow , otherwise on these details. anyways- database, 3 tables seatstatus table id, int, primary key name, string (e.g. available, sold, broken) pricepoint table id, int, ...

android - How can I set the width and height of an ImageView to another ImageView's width and height on the XML? -

i have layout. <imageview android:id="@+id/icon" android:layout_gravity="left" android:layout_marginleft="5px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"/> <imageview android:id="@+id/header_avatar" android:layout_gravity="left" android:layout_marginleft="5px" android:layout_width="?????" android:layout_height="?????"/> i want second imageview have same size of first imageview resizes pictures set in second view (header_avatar) same of first view (@drawable/icon). posible or have programmatically? cannot reference first view's width , length on second view? thanks in advance. using relative layouts trick. if not, programatically in oncreate method of activity.

c# - Accessing rows PK after Insert (SqlDataSource) -

i need able primary key of nserted row in c#, , far i'm unsure how. i've put select scope_identity() sql query, how access sqldatasource_inserting method, can store in auditing table? in method how access parameters (e.command.parameters) edit: my parameters stored in asp.net file (some extracts): insertcommand="insert [nominalcode] ([vaxcode], [reference], [costcentre], [department], [reportingcategory]) values (@vaxcode, @reference, @costcentre, @department, @reportingcategory)" <insertparameters> <asp:controlparameter controlid="detailsview1" name="vaxcode" propertyname="selectedvalue" /> <asp:controlparameter controlid="detailsview1" name="reference" propertyname="selectedvalue" /> <asp:controlparameter controlid="detailsview1" name="costcentre" propertyname=...

qt - QApplication exec() creates new thread / process? -

in qapplication if call exec() new process / thread start? no, calling exec will: enters main event loop , waits until exit() called, returns value set exit() (which 0 if exit() called via quit()). it necessary call function start event handling. main event loop receives events window system , dispatches these application widgets.

svn - comparing different subversion respositories -

subversion 1.4.2 we have repository. going repository our server. however, our customer wants know if restore repository, how know if has tried change or bad repository. we keep repository on our development server. , backup repository our backup server. how can confirm both repositories same? many suggestions, a possible solution use svnadmin dump backuping. can calculate md5 or other hash sum on dump files , compare them.

Flex tree space default event listener -

i have noticed when select tree node if space clicked selected node gets opened... how remove event? it doesn't there's way prevent event , if there 1 i'm not sure it's wise since tree's keydownhandler little bit more opening node. i solved creating custom tree. sadly had copy few lines of code tree's keydownhandler. public class mytree extends tree { override protected function keydownhandler(event:keyboardevent):void { if (event.keycode == keyboard.space) { // code copied tree's keydownhandler // if user has moved caret cursor selected item // move cursor selected item if (caretindex != selectedindex) { // erase caret var renderer:ilistitemrenderer = indextoitemrenderer(caretindex); if (renderer) drawitem(renderer); caretindex = selectedindex; } ev...

Array initializing in Scala -

i'm new scala ,just started learning today.i know how initialize array in scala. example java code string[] arr = { "hello", "world" }; what equivalent of above code in scala ? scala> val arr = array("hello","world") arr: array[java.lang.string] = array(hello, world)

OpenGL ES 2.0 Extensions on Android Devices -

as this page opengl es 1.x, collect opengl es 2.x extensions android devices on page. listing can found benchmark tool gpubench . information can many game developpers. thanks help, motorola xoom vendor:nvidia corporation driver:opengl es 2.0 render:nvidia tegra nv_platform_binary oes_rgb8_rgba8 oes_egl_sync oes_fbo_render_mipmap nv_depth_nonlinear nv_draw_path nv_texture_npot_2d_mipmap oes_egl_image oes_egl_image_external oes_vertex_half_float nv_framebuffer_vertex_attrib_array nv_coverage_sample oes_mapbuffer arb_draw_buffers ext_cg_shader ext_packed_float oes_texture_half_float oes_texture_float ext_texture_array oes_compressed_etc1_rgb8_texture ext_texture_compression_latc ext_texture_compression_dxt1 ext_texture_compression_s3tc ext_texture_filter_anisotropic nv_get_tex_image nv_read_buffer nv_shader_framebuffer_fetch nv_fbo_color_attachments ext_bgra ext_texture_format_bgra8888 ext_unpack_subimage

c++ - struct reference and operator= -

i have class this: template <class t> class bag { private: typedef struct{t item; unsigned int count;} body; typedef struct _node{_node* prev; body _body; _node* next;}* node; struct iterator{ enum exception{notdefined, outoflist}; body operator*(); explicit iterator(); explicit iterator(const iterator&); iterator& operator=(const iterator&); iterator& operator++(int); iterator& operator--(int); bool operator==(const iterator&) const; bool operator!() const; private: node current; friend class bag; }; node head; node foot; iterator _begin; iterator _end; /* ... */ public: /* ... */ bag(); const iterator& begin; const iterator& end; }; in bag() have set reference beg...

debugging - No "walkers" in mdb (Solaris modular debugger) -

every , use mdb debugger examine core dumps on solaris. 1 nice article looked @ speed on possibilities mdb http://blogs.oracle.com/ace/entry/mdb_an_introduction_drilling_sigsegv author performs step-by-step examination of sigsegv crash. in article author uses "walkers" kind of add-on mdb can perform specific tasks. my problem don't have of walkers in mdb. using "::walkers" command, walkers available can listed , list empty. question is, how can install/add/load walkers such ones used in above article? don't know supposed loaded from, if have download , add them somewhere or if it's configuration step when installing solaris? mdb automatically loads walkers , dcmds appropriate you're debugging, /usr/lib/mdb , similar directories (see mdb(1) details). if run "mdb" itself, you'll nothing. if run "mdb" on userland process or core dump (e.g., "mdb $$"), you'll walkers , dcmds appropriate userland deb...

.net - I need to create 2D array in C# -

i need create 2d jagged array. think of matrix. number of rows known, number of columns not known. example need create array of 10 elements, type of each element string[]. why need that? number of columns not known - function must allocation , pass array other function. string[][] creatematrix(int numrows) { // function must create string[][] numrows first dimension. } update i have c++ background. in c++ write following (nevermind syntax) double ** createarray() { double **parray = new *double[10]() // create 10 rows first } update 2 i considering using list, need have indexed-access both rows , columns. you can write: string[][] matrix = new string[numrows][]; and produce 2d array of null elements. if want fill array non-null items, need write: for (int row = 0; row < numrows; row++) { matrix[row] = new string[/* col count row */]; } you need specify column count each row of matrix. if don't know in advance, can either. leave matrix ...

shell - How does Bash parameter expansion work? -

i'm trying understand bash script. stumbled upon this: dir=${1:-"/tmp"} what mean? :- operator says if $1 (first argument script) not set or null use /tmp value of $dir , if it's set assign it's value $dir . dir=${1:-"/tmp"} is short for if [ -z $1 ]; dir='/tmp' else dir="$1" fi it can used variables not positional parameters: $ echo ${home:-/tmp} # since $home set displayed. /home/codaddict $ unset home # unset $home. $ echo ${home:-/tmp} # since $home not set, /tmp displayed. /tmp $

iphone - Why does animating a modal view controller onscreen cause a crash here? -

this piece of code works fine. however, if change animated parameter yes crashes. accountviewcontroller *accviewcontroller = [[accountviewcontroller alloc] initwithnibname:@"account" bundle:nil]; [self.navigationcontroller pushviewcontroller:accviewcontroller animated:no]; [accviewcontroller release]; what wrong? are doing while other animation going on? i've seen crashes here in type of situation (for example, while 1 view being dismissed, pushing or presenting crash.)

oop - Python: How to distinguish between inherited methods -

newbie python question. have class inherits several classes, , of specialization classes override methods base class. in cases, want call unspecialized method. possible? if so, what's syntax? class base(object): def foo(self): print "base.foo" def bar(self): self.foo() # can force call base.foo if foo has override? class mixin(object): def foo(self): print "mixin.foo" class composite(mixin, base): pass x = composite() x.foo() # executes mixin.foo, perfect x.bar() # indirectly executes mixin.foo, want base.foo you can make call want using syntax base.foo(self) in case: class base(object): # snipped def bar(self): base.foo(self) # call base.foo regardless of if subclass # overrides # snipped x = composite() x.foo() # executes mixin.foo, perfect x.bar() # prints "base.foo" this works because python executes calls bound methods of for...

html - Apply image in bottom right corner -

i need apply small image, little badge, (bottom right) on thumbnails of gallery. code generate automatically plugin , looks this. can't change order of tags can edit 2 lines marked * (i.e. adding classes, changing span div) works top not bottom (top: 0px; right: 4px) don't know why. <a href="/photos/fullpic.jpg"> <span> *<span style="position: relative; display: block;"> <img src="/photos/mythumbnail.jpg" alt="thumbnail"> *<img src="/photos/plugins/badge.png" style="position: absolute; bottom: 0px; right: 4px;"> </span> </span> edit: forgot add. each thumbnail has different height/width can't declare height container. needs stick bottom right regardless dimension of container. it works fine me have remove display:block; <span> what "wrapper" <span> ?

Twitter button 'url' parameter does not contain a valid URL -

i passing url http://new.wadja.com/petty01#bad religion to twitter button , receive 'url' parameter not contain valid url. below have example of tweet button -- hmm...stack-overflow not displaying frame below anyway -- end of frame any ideas? using url encode in js. thanks in advance. try http://new.wadja.com/petty01#bad%20religion . plain spaces in urls must encoded.

dynamic forms asp.net -

today i'm using crystal reports create parameterized forms , save them pdf, isn't there other alternatives? what want do? well, have form information "placeholders" (that's how i'm using crystal) ... in code set placeholder data binded ... save pdf , voila... but crystal pain maintain , fields don't grow automatically. thank u all.. tiago. there multiple ways generate pdf's without crystal. itextsharp one. can use xsl formatting objects transform

How does one find out if a Windows service is installed using (preferably) only batch? -

i need check if windows service installed batch file. can dip other batch if need to, prefer not to. there way this? you can run "net stop [servicename]" if fails "the service name invalid" service isn't installed

C++ templates: Query regarding which is better of way of using and why -

i have got question. better of doing it. typedef enum{ 1 = 1, 2 = 2 } number; template< typename t, number num > void foo( const t& param ) { } or template< typename t > void foo( const t& param, number num ) { } what looking is, how these 2 methods different? if have use of these 1 should choose , why? it depends on want do. if num value template parameter must specified @ compile time. if function parameter can specified @ runtime. what use case?

javascript - Jquery: Automate Mousemove every 20seconds -

i make script in jquery automove cursor every 20 seconds in random position of screen. if not possible make in jquery,how can make in javascript? you can't move user's mouse in javascript (or built on it)...this quite annoying...and used evil pretty quickly. for example: imagine advertiser's javascript moving mouse ad randomly in hopes click.

Safari for iPhone can't evaluate correctly jQuery? -

i'm trying make work functionality exists on website works bad on safari iphone. well, have "li" element: .. <li><input id='showorhide' type='button' value='show or hide'/></li> <li><input type='text' value='ok'/></li> .. when click on 'show or hide' button, text input should appear or disappear. then, have jquery function binds click: $("#showorhide").click(function(){ if($(this).parent().next().is(':visible')) $(this).parent().next().hide('slow'); else $(this).parent().next().show('slow'); }); the problem that, if element appears, safari hides shows it. so think safari checks wether element visible or not. if it's visible, hides it, go "else" selection. there, checks if element visible or not. find it's not visible, make appear. is there solution without using extrernal javascript framework (but jq...

asp.net - Can I use both DevExpress and Telerik on the same web page -

will there problems if use devexpress controls , telerik controls on same web page. imagine nesting them insider 1 another. i wondering if conflict each other during ajax calls. yes can use both of them. there no conflict. because web.config has different arguments these controls. maybe page more slower. devexpress running slowly.

Regex sub-expression matching with Find + emacs-regex mode -

i'm trying find compressed log files, , operations on them. can't use ls because thousands of files in directory , bash throws 'argument list long' error. has brought me find, i'm having trouble regex. here whole find command find $i -regex '.*logfile_mp[0-9]-gw0[0-9]_2010-09-\(\([7-9]\)|\(1[0-9]\)|\(2[0-3]\)\)-.*' -exec ls {} \; i need go through several log directories, $i comes bash loop go through directories. right now, i'm trying list files, know have right ones; i'll amend -exec statement once working. the problem relates parentheses section: \(\([7-9]\)|\(1[0-9]\)|\(2[0-3]\)\) i'm trying match range of days (7-23). understand emacs-regex mode, have escape parentheses. rest of regex working because if replace parentheses section number (ex. 7), works fine. can me create regex sub-expression match 7-23? thanks. i think you're on right track, missing \ in front of each of | : \([7-9]\|1[0-9]\|2[0-3]\) ...

icalendar - How Do I create an .ics file with rails and ri_cal? -

i using rails 3 , ri_cal gem. not able produce valid .ics file. gets generated, applecalendar or googlecalendar it's empty. did wrong? appreciated, in advance :) my controller class websitescontroller < applicationcontroller def index respond_to |format| format.ics end end end and index.ics.builer rical.calendar event description "ma-6 first manned spaceflight" dtstart datetime.parse("2/20/1962 14:47:39") dtend datetime.parse("2/20/1962 19:43:02") location "cape canaveral" add_attendee "john.glenn@nasa.gov" alarm description "segment 51" end end end i able succeed in getting ics created def index cal =rical.calendar event description "ma-6 first manned spaceflight" dtstart datetime.parse("1962-02-20") dtend datetime.parse("1962-02-20") location ...

Converting newlines to spaces in Latex -

i'm writing document , have few chapter titles appear 2 lines chapter title, 1 line in table of contents. there simple command filter out newline character this? chapter title first line: second more informative line toc: first line: second more informative line you can define alternative chapter titles toc: \chapter[toc title]{regular title}

php - Regular expression for Text, Numbers and Decimals -

i trying regular expression text, decimals , decimal numbers. expression must match @ once. the main problem had write analyzer zend_search_lucene in order able search decimal digits. right can search texts , numbers. guess match decimal numbers make them tokens , regular expression in question. okay feel stupid anyways. got wanted. this, [a-za-z0-9.]+ did trick. imagine how short was.

arcgis - Adding Values to an Array and getting distinct values using Python -

i have python code below loop through table , print out values within particular column. not shown form in user selects feature layer. once feature layer selected second dropdown populated column headings feature , user chooses column want focus on. within python script, print out each value within column. want store each value in list or array , distinct values. how can in python? also there more efficient way loop through table go row row? slow reason. many thanks # import system modules import sys, string, os, arcgisscripting # create geoprocessor object gp = arcgisscripting.create(9.3) gp.addtoolbox("e:/program files (x86)/arcgis/arctoolbox/toolboxes/data management tools.tbx") # declare our user input args input_dataset = sys.argv[1] #this feature layer user wants query against atts = sys.argv[2] #this column name user selected #lets loop through rows values particular column fc = input_dataset gp.addmessage(atts) rows = gp.search...

C++ simple polymorphism issue -

ok admit it, i'm total c++ noob. i checking book data structures , algorithms in c++ adam drozdek, in section 1.5 : "polymorphism" proposes next example: class class1 { public: virtual void f() { cout << "function f() in class1" << endl; } void g() { cout << "function g() in class1" << endl; } }; class class2 { public: virtual void f() { cout << "function f() in class2" << endl; } void g() { cout << "function g() in class2" << endl; } }; class class3 { public: virtual void h() { cout << "function h() in class3" << endl; } }; int main() { class1 object1, *p; class2 object2; class3 object3; p = &object1; p->f(); p->g(); p = (class1*)&object2; p->f(); p->g(); p = (class1*)&object3; p-...

grouping - WPF ItemsControl ItemTemplate border with GroupStyle -

Image
this first time i've posted pic, turns out (a picture worth thousand words, , don't want type thousand words). but, image below i'm trying accomplish. i have collection of objects i'm needing grouped property "group". i'm using collectionviewsource bound data source doing grouping me. i'm using itemscontrol control (but use control) display information. i'm able group information property i'd able surround entire group border. i'm not wanting surround each item in group entire group. how accomplish picture below border around entire group? something should trick. use group style. want customize more, should able general idea snippet. the main thing know binding groupitem. there 3 properties on groupitem. name (of group), itemcount (how many items in grouping) , items themselves. <controltemplate targettype="{x:type groupitem}"> <border borderbrush="black" borderthickness="1...

objective c - Access static variables in ObjC categories -

i'm trying implement category of existing class. there static variable in existing class. if try access static variable category, i'm getting error static variable undeclared. is possible access static variables in objc categories ? just clear, objective-c doesn't associate static variables classes. static variables scoped default whatever file they're declared in. to make static variable visible in other files, add declaration in corresponding header file prefixed keyword extern . example, if had defined following static variable somewhere in 1 of .m files int seconds = 60; you add following declaration in .h file: extern int seconds; then, .m file imports .h file see static variable.

ruby on rails - Delayed::Jobs keeps sending emails if it fails -

i used delayed_jobs send emails. except think if fails send 'every single email' tries , reruns entire batch again. how make skip email address if not correct? if exception occurs delayed_job treat job failed , keep rerunning it. should capture exceptions make sure @ end job considered succesful.

.net - Get the latest updated sub-directory -

am trying find latest sub-directory parent director. public static directoryinfo getlatestsubdirectory(string parentdirpath) as of implementation uses bubble sort algorithm find latest comparing creation time. if (subdirinfo.creationtimeutc > latestsubdirinfo.creationtimeutc) am wondering if there's more efficient way this? linq?? return new directoryinfo(parentdirpath) .getdirectories() .orderbydescending(d => d.creationtimeutc) .first()

ruby - What alternatives to IRB are there? -

in python world, there number of alternative python interpreters add cool additional features. 1 particularly useful example bpython, adds dynamic syntax highlighting, automatically pulls documentation, , displays live autocomplete information. in ruby world, have yet uncover projects add basic irb interpreter subset of these features. not looking hard enough, or ruby community lacking? what coincidence. rubyflow yesterday announced irbtools gem, meta-gem containing lots of cool irb enhancement gems. contains: colorized , output comment wirb , fancy_irb nice irb prompt , irb’s auto indention includes stdlib’s fileutils: ls , cd , pwd , ln_s , rm , mkdir , touch , cat many debugging helpers: ap , q , o , c , y , object#m , object#d ap – awesome_print q – p , on 1 line object#m – ordered method list (takes integer parameter: level of nesting) object#d – puts object, returns self (using tap ) “magical” information constants: info, os, rubyversion, rubyeng...

.net - Visual Studio setup project along-side self-updating logic? -

i'm looking implement setup package multi-project solution installs windows service winforms application. both service , application have ability update via custom web-based utility wrote. basically, windows service updates own dll's on regular basis if sees upgrade on web server. winforms application updates if sees upgrade on webserver upon launch. not use standard installer upgrade process replaces .dll's in place before consumed. i understand how make windows not repair installation (using not reinstall flag) if manually upgrade few dll's project. however, if enable files not repaired, run problem them not being uninstalled or upgraded when user manually upgrades or repairs installation. so, need this: 1) windows not try repair manually upgraded .dll's automatically w/o explicit user request 2) windows uninstall including self-upgraded .dll's - when user chooses uninstall 3) windows repair if user manually chooses repair installation is poss...

c++ - Error compiling in release mode but not in debug mode -

when compile on vs 2008 in deubg mode works fine. when compile same thing in release mode not works. far can tell include directories same , there no additional preprocessor symbols. any help? 1>zlib.cpp 1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\xutility(419) : error c2664: 'cryptopp::allocatorwithcleanup::allocatorwithcleanup(const cryptopp::allocatorwithcleanup &)' : cannot convert parameter 1 'cryptopp::allocatorwithcleanup' 'const cryptopp::allocatorwithcleanup &' 1> 1> [ 1> t=std::_aux_cont 1> ] 1> , 1> [ 1> t=cryptopp::huffmandecoder::codeinfo 1> ] 1> , 1> [ 1> t=std::_aux_cont 1> ] 1> reason: cannot convert 'cryptopp::allocatorwithcleanup' 'const cryptopp::allocatorwithcleanup' 1> 1> [ 1> t=cryptopp::huffmandecoder::codeinfo ...

.net - Save screenshot of WPF web browser Frame -

i have frame element displaying html page in wpf application, , save screenshot of frame image. with of google, have code: size size = new size(previewframe.actualwidth, previewframe.actualheight); previewframe.measure(size); previewframe.arrange(new rect(size)); var renderbitmap = new rendertargetbitmap( (int)size.width, (int)size.height, 96d, 96d, pixelformats.pbgra32); renderbitmap.render(previewframe); but ever blank image. any thoughts on how fix code, and/or way capture web page image in app? turns out gdi graphics class has copyfromscreen method works , captures frame 's contents: var topleftcorner = previewframe.pointtoscreen(new system.windows.point(0, 0)); var topleftgdipoint = new system.drawing.point((int)topleftcorner.x, (int)topleftcorner.y); var size = new system.drawing.size((int)previewframe.actualwidth, (int)previewframe.actualheight); var screenshot = new bitmap((int)previewfr...

c# - Calculate days in years and months? -

how calculate days in years , months in c#? per example : if 1. days = 385 need display year= 1.1 (i.e. 1 year 1 month) 2. days= 234 need display year =0.7 (i.e 0 year 7 months) how can calculate in c#? i did days=234 /365 , result coming 0.64 (i.e. 0 year 6 months). 7 months. how accurate year , months. assuming month of one-twelfth of year, , want ignore partial months (based on saying expect 7 example 7.688 months, then: int days = 234; double years = (double)days / 365.242199; int wholeyears = (int)math.floor(years); double partyears = years - wholeyears; double approxmonths = partyears * 12; string horribleformat = string.concat(wholeyears, ".", approxmonths);

relative path traversing, is this valid? -

i have xml file need 2 dirs file (from water fire) <album basepath="albums/water/images"> <img src="001.jpg" /> <img src="002.jpg" /> <img src="../../fire/images/005.jpg" /> </album> so question if albums/water/images/../../fire/images/005.jpg is valid path? yes, it's valid path

redirect and get the output of console of eclipse to string or output text java -

i tired redirect output of eclipse output text , principale idea output of eclipse console , th result maven description, want redirect output such hudson console in output text public class redirecttest { public static void main(string[] args) throws ioexception { printstream ps = new printstream(new bufferedoutputstream(new fileoutputstream(new file("output.txt"))), true); system.setout(ps); system.out.println("test"); } }

How do you unlink a symlink created with Microsoft's linkd.exe tool? -

i'm using microsoft linkd.exe tool create symlinks, typed linkd -d , created link called "-d" now cant remove "-d" lol sucks. so renamed ddd wouldnt think option. but still need know how unlink things =/ this makes appear contents of bar directory inside foo directory: linkd foo bar and breaks link: linkd foo /d you have careful, actions delete contents of bar instead of breaking link. example, don't delete things.

python: turning textwrap into a list -

i have variable: row='saint george 1739 1799 violin concerti g 029 039 050 symphonie concertante 2 violins g 024 bertrand cervera in 024 039 christophe guiot in 024 029 , thibault vieux violin soloists orchestre les archets de paris' i doing this: textwrap.fill(row,55) i list line have line[0]='saint george 1739 1799 violin concerti g 029 039 050' , line[1]='symphonie concertante 2 violins g 024 bertrand' etc..... please me conversion textwrap list please note textwrap breaks things \n use textwrap.wrap instead of textwrap.fill

c++ cli - C++/CLI pointer issue = fun! -

i've been converting bunch of old c++ code c++/cli code, , think i've coded myself corner. my goal take unmanaged c++ library , bunch of header files , expose functionality c# solution. reading on internet, standard way to: create 2 c++ classes: 1 managed, other unmanaged. the unmanaged class wrangle objects in c++ library provide desired functionality. the managed class wrap of public methods in unmanaged class. each wrapper method handle necessary conversions string^ string, etc.. but, scenario isn't complex, decided try , implement in 1 class. wrestling peculiar problem generates accessviolationexceptions. my header file looks this: public ref class managedclass { public: managedclass(); void createunmanagedobject(string^ param1); void useunmanagedobject(); unmanagedobject *myunmanagedobject; } and cpp file looks this: void managedclass::createunmanagedobject(string^ param1) { /* convert params, use them in way. */ /* capture outp...

jquery - How can I pass data from an ajax request to a global variable? -

ok. i'm totally baffled. here's code: $(document).ready(function(){ var newtoken = 1; $.get("junk.php", function(newtoken) { alert(newtoken); // alerts "junk" }); alert(newtoken); // alerts "1" }); as per comments, first alert of newtoken "junk" (the output of junk.php). once outside .get, newtoken reverts "1". need variable set output junk.php. not possible? i've tried everything, , searched everywhere. thanks. you're shadowing first newtoken variable new newtoken variable used argument: problem: $(document).ready(function(){ var newtoken = 1; // <== newtoken number 1 $.get("junk.php", function(newtoken) { // <== newtoken number 2. // since it's first argument // in success function // data returned. alert(newtoken); // <== alerts data returned. newto...

Using VBScript how can I check if the Spooler service is started and if not start it? -

i'd use vbscript check if spooler service started , if not start it, code below checks service status need modifying can check if started. strcomputer = "." set objwmiservice = getobject("winmgmts:" _ & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colrunningservices = objwmiservice.execquery _ ("select * win32_service") each objservice in colrunningservices wscript.echo objservice.displayname & vbtab & objservice.state next many steven how this. command start if isn't running. no need check in advance. dim shell set shell = createobject("wscript.shell") shell.run "net start spooler", 1, false

google maps - Is there any way I can put turn by turn navigation using mapview in android? -

i have situation here. want put turn turn navigation using mapview in android app, google maps provides us. not able find kind of turning info in th kml file returned google, wonder possible or not ?? thanks in advance. i got solution in kml file only. provides me strings turnings. parsed , it'll do.

Zend Framework - How to place a text right to the text box? -

how place text right text box in zend framework ? using zend_form component in project. want display small text right side of text box. example want display example phone number right side of phone number text box field. how can this? please me!!!! use element's description $element = $this->createelement('text', 'phone') ->setlabel('phone number:') ->setdescription('ex: 123-456-7890'); $this->addelement($element);

c# - Is there anyway of consolidating similar data bindings and/or triggers in XAML? -

i have user control hosts other controls. way implemented via data templates define control should associated specific view-model. these view-models have similar properties , interaction triggers. please see xaml snippet below. the problem approach have copy-paste data bindings if want support new view-model. there way of consolidating similar data bindings and/or triggers 1 template? don't want type/copy-paste same data binding definitions each control. (yes, know, i'm lazy.) <usercontrol.resources> <datatemplate datatype="{x:type vm:someviewmodel1}"> <textblock canvas.left="{binding left}" canvas.top="{binding top}" rendertransform="{binding transform}" height="{binding height}" width="{binding width}"> <i:interaction.triggers> <i:eventtrigger eventname="mousee...

iphone - Fires EXC_BAD_ACCESS -

hi trying implement captcha functionality. following code, have used generating random word: -(void) createcaptchaword{ lettersarray = [[nsmutablearray alloc] initwithobjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"o",@"p",@"q",@"r",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z", nil]; randomword = @""; for(nsuinteger i=0;i<5;i++){ nsuinteger randomnumber = arc4random()%[lettersarray count]; randomword = [randomword stringbyappendingstring:[lettersarray objectatindex:randomnumber]]; //randomword = [nsstring stringwithformat:@"%@%@",randomword,[lettersarray objectatindex:randomnumber]]; } nsstring *captchaurl = [nsstring stri...

c# - How to test whether or not a given type is a static class? -

var types=from m in system.reflection.assembly.load("system").gettypes() m.isclass // check whether or not type static class. select m; i want fillter out static class result. var types = m in system.reflection.assembly.load("system").gettypes() m.isclass && m.isabstract && m.issealed select m; from this thread . edit: check m.issealed

SQL Server query help... need to convert varchar to date -

i writing query fetch results values in column of varchar type.. less '29/08/2010' (date) my query: select * employees column1 < '29/08/2010' here column1 of varchar type. using sql server 2005 is there way make possible..?? pls me. thanks in advance have tried select * employees convert(datetime, column1, 103) > convert(datetime, '29/08/2010', 103)

iAd in iPhone animates when not loaded -

i have added banner view implementing iad in bottom of screen. when running on simulator banner view above frame fixed it. appears transparent strip , not selectable. after sometime automatically comes bottom black strip saying test advertisement. i want banner view stick bottom , not animate. here code. adview declaration code: adview = [[[adbannerview alloc] initwithframe:cgrectoffset(cgrectzero, 0, 350)] autorelease]; adview.frame = cgrectmake(0,340,320,25); adview.requiredcontentsizeidentifiers = [nsset setwithobject:adbannercontentsizeidentifier320x50]; adview.currentcontentsizeidentifier = adbannercontentsizeidentifier320x50; adview.autoresizingmask = uiviewautoresizingflexibletopmargin | uiviewautoresizingflexiblerightmargin; adview.tag = 111; [self.navigationcontroller.view addsubview:adview]; adview.delegate = self; self.bannerisvisible = no; adview.hidden = yes; here delegate methods. - (void)bannerviewdidloadad:(adbannerview *)banner { if (!self.bannerisvis...

bash - Best/conventional method of dealing with PATH on multiple UNIX environments -

the main question here is: there standard method of writing unix shell scripts run on multiple unix platforms. for example, have many hosts running different flavours of unix (solaris, linux) , @ different versions different file system layouts. hosts have whoami in /usr/local/gnu/bin/, , in /usr/bin/. all of our scripts seem deal in different way. have case statements on architecture: case "`/script/that/determines/arch`" in sunos-*) whoami=`/usr/local/gnu/bin/whoami` ;; *) whoami=`/usr/bin/whoami` ;; esac with approach know binary being executed, it's pretty cumbersome if there lots of commands being executed. some set path (based on arch script above) , call commands name. convenient, lose control on command run, e.g. if have: /bin/foo /bin/bar /other/bin/foo /other/bin/bar you wouldn't able use both /bin/foo , /other/bin/bar . another approach think of have local directory on each host symlinks each binary needed on each host. ...

android - how to scan barcode using phonegap -

i need scan barcode using phonegap in android , iphone. there way this? this link leads page can learn how implement phonegap barcode scanner plugin in application

php - Using OR in a IF -

any ideas why isn't working? if($page->slug != 'water-filters' || $page->slug != 'pet-care' || $page->slug != 'books') { //do } i think mean , instead of or because you're using not equals. by using not equals in way statement true, if $page->slug equals 'water-filters' doesn't equal 'pet-care' , hence if statement whole returns true. if($page->slug != 'water-filters' && $page->slug != 'pet-care' && $page->slug != 'books') { //do }