Posts

Showing posts from April, 2011

python - Link two classes together by variables -

i learning python couple different books learn python hard way. i trying better understand classes , ran example : class dog(object): def __init__(self, name): self.name = name self.legs = 4 self.carry_weight = 0 class person(object): def __init__(self,name): self.name = name self.pet = none self.weight = 0 rover = dog("rover") rover.carry_weight = 180 frank.pet = rover print frank.name print frank.pet.legs if frank.weight < frank.pet.carry_weight: print "yes, frank can ride dog %s around neighborhood" % frank.pet.name so learned can link 2 instances of class , call attributes 1 other. wanted add attribute owner = none under dog. , when link frank rover links rover frank owner if know rover can pull frank. what have come idea: def assign_pet(self, petsname): self.pet = petsname petsname.owner = self.name this seems work fine wanted know if best way go this.

Clojure performance on set updates or large number computations -

i'm trying sum prime numbers euler project problem using sieve algorithm. i'm using mutable set store numbers aren't prime , using 'dosync' , 'commute' update set (otherwise ran out of memory if immutable) . performance linear till 1.2 million primes, performance terrible @ 1.5 million (7 seconds vs. 64 seconds). ideas i'm doing wrong? guess possibly numbers getting large, or maybe updating mutable sets inefficient. (defn mark-multiples [not-prime-set multiple prime-max] (loop [ counter (long 2) product (* counter multiple)] (if (> product prime-max) not-prime-set (do (dosync (commute not-prime-set conj product)) (recur (inc counter) (* (inc counter) multiple)))))) (defn sieve-summation [prime-max] (def not-prime-set (ref #{ (long 1) }) ) (loop [counter (long 2) summation (long 0)] (if (> counter prime-max) summation (if (not (contains? @not-prime-set counter)) (do

php - how to match numbers with dash or space in between -

this question has answer here: regular expression match 7-12 digits; may contain space or hyphen 4 answers i have following regex: preg_match_all('/(\d+)/', $bio, $matches); this match consecutive numbers such 1928371921, wanted match following format. 0812-123-1288 or 0812 123 1288 what best way modify above regex handle such cases? you can use following: preg_match_all('/\d+(?:[- ]\d+)*/', $bio, $matches);

ruby on rails - undefined method `session_path' -

i using rails + devise + omniauth + google oauth2. my user model (user.rb) contains: devise :registerable, :omniauthable, :omniauth_providers => [:google_oauth2] my routes.rb like: rails.application.routes.draw devise_for :users, controllers: { omniauth_callbacks: 'omniauth_callbacks' } devise_scope :user 'sign_in', :to => 'devise/sessions#new', :as => :new_user_session post 'sign_in', :to => 'devise/session#create', :as => :user_session 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session end 'services', to: 'static_pages#services' 'my_account', to: 'my_account#index' 'invite', to: 'invite#show' 'invite/:id', to: 'invite#show' root 'static_pages#home' end when go /sign_in, exception like: undefined method `session_path' #<#<class:0x007f9b7173af28>:0x007

asp.net web api - WebAPI v2 - JSON Serialization for OData expand causes $type to be incorrect -

i have updated mvc4/webapi v1 application mvc5 + webapi2.. seems after upgrade json.net serializer no longer include proper $type requests make use of odata $expand method. see below example of mean... correct: request: http://url.com/api/studies/277/sites response: { $id: "1" $type: "lgcydapi.domain.model.studysitewithcontacts, lgcydapi.domain.model" contacts: [ { $id: "2" $type: "lgcydapi.domain.model.contactrelatedtosite, lgcydapi.domain.model" contactid: -38445 }], siteid: 38445 } incorrect : request: http://url.com/api/studies/277/sites ?$expand=contacts response: { $id: "1" $type: "system.collections.generic.dictionary`2[[system.string, mscorlib],[system.object, mscorlib]], mscorlib" contacts: [ { $id: "2" $type: "system.collections.generic.dictionary`2[[system.string, mscorlib],[system.object, mscorlib]], mscorlib" contactid: -38445 }], siteid: 38445} along mvc , webapi assemb

Pass an ActiveRecord array through the params hash in Rails -

when pass @dispensers through params hash get: @dispensers = "[#<dispenser id: 38084, firstname: \"x\", lastname: \"a lane\", created_at: \"2014-06-24 20:33:30\", updated_at: \"2014-06-24 20:33:30\", user_id: nil, public: true, birth_date: nil, university_id: nil, business_id: 29, branch_id: 38057, latitude: 30.3509, longitude: -97.7505, score: nil, gmaps: nil, full_name: \"laura lane\", sex: \"f\", premium: false, slug: nil, public_reviews_on: true, bio: nil>, #<dispenser id: 38102, firstname: \"x\", lastname: \"woodall\", created_at: \"2014-06-24 20:33:31\", updated_at: \"2014-06-24 20:33:31\", user_id: nil, public: true, birth_date: nil, university_id: nil, business_id: 29, branch_id: 38075, latitude: 30.3379, longitude: -97.7593, score: nil, gmaps: nil, full_name: \"ashley woodall\", sex: \"f\", premium: false, slug: nil, public_reviews_on: tr

Spring MockMvc multipart reading in zip file IOException: Stream closed -

i want test multipart controller reads zip file in , goes through of entries. here's controller method it: @requestmapping(value = "/content/general-import", method = requestmethod.post) public modelandview handlegeneralupload( @requestparam("file") multipartfile file) throws ioexception { string signature = "retailer_group:*|channel:*|locale:de-at|industry:5499"; log.info("processing file archive: {} signature: {}.", file.getname(), signature); modelandview mav = new modelandview(); mav.setviewname("contentupload"); if (!file.isempty()) { byte[] bytes = file.getbytes(); zipinputstream zis = new zipinputstream(new bytearrayinputstream(bytes)); zipentry entry = null; while ((entry = zis.getnextentry()) != null) { // process each file, based on , whether directory etc. if (!entry.isdirectory()) { /

ruby on rails - Error running Heroku bundle -

i updated gemfile , upgraded rails 4.0.0 , ruby 2.0.0. ran bundle install , bundle update , pushed heroku. migrated db. the app works on localhost shows application error on heroku. so ran heroku run bundle update , gave following error: you trying install in deployment mode after changing gemfile. run `bundle install` elsewhere , add updated gemfile.lock version control. if development machine, remove gemfile freeze running `bundle install --no-deployment`. have added gemfile: * source: https://github.com/noamb/sorcery (at master) * source: rubygems repository https://rubygems.org/ * rails (= 4.0.0) * sass-rails (~> 4.0.0) * uglifier (>= 1.3.0) * coffee-rails (~> 4.0.0) * jquery-rails * turbolinks * jbuilder (~> 1.2) * sorcery * thin * pg * rails_12factor * sdoc * mailcatcher * rspec-rails * sqlite3 * foreman * quiet_assets have changed in gemfile: * sorcery `https://github.com/noamb/sorcery (at master)` `no specified source` this .gitignore fi

java - How do I open another app programmatically in Android? -

what want simple, don't know if it's possible. want app open specific area of app. specific area of other app form; app contains information complete form. want app open form information in editable text boxes. know if possible? the other app i'm trying open bitcoin client open source. code: https://github.com/schildbach/bitcoin-wallet/ google play: https://play.google.com/store/apps/details?id=de.schildbach.wallet if open app (the bitcoin client) , click on "send bitcoins", form i'm trying open appear. there 3 editable text boxes there , have information fill in app. that's guys, hope knows. ps: opened app using: intent launchintent = getpackagemanager().getlaunchintentforpackage("de.schildbach.wallet"); startactivity(launchintent); but didn't opened form, useless.

ios - Delegate not being set correctly -

im working on project , uiwebview class needs execute method downloadview class i using open source project https://github.com/robertmryan/download-manager when code executes method: downloadtableview *download = [[downloadtableview alloc] init]; [download queueandstartdownloads:_downloadurl]; this line doesnt set delegate right self.downloadmanager = [[downloadmanager alloc] initwithdelegate:self]; the whole start download method - (void)queueandstartdownloads:(nsurl *)url { nsstring *documentspath = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes)[0]; nsstring *downloadfolder = [documentspath stringbyappendingpathcomponent:@"downloads"]; if ([[nsfilemanager defaultmanager] fileexistsatpath:downloadfolder]) //does file exist? { if (![[nsfilemanager defaultmanager] createdirectoryatpath:downloadfolder withintermediatedirectories:no

How to convert System.Windows.Controls.image to System.Drawing.Icon c# -

i have images var = new system.windows.controls.image() { source = new bitmapimage(new uri(@"/accounts;component/resources/close.png", urikind.relative)) }; and need convert system.drawing.icon there way it???

java - An exception occurred while creating a query in EntityManager -

this query. list exp = entitymanager.getentitymanager() .createquery("select sum(u.expenseamount), u.wdexpensegroup.expensegroupname wdexpense u month(cast(u.expensedate date)) = month(now()) , year(cast(u.expensedate date)) = year(now()) group u.wdexpensegroup.expensegroupid") .getresultlist(); i'm getting below error. java.lang.illegalargumentexception: exception occurred while creating query in entitymanager: exception description: syntax error parsing query [select sum(u.expenseamount), u.wdexpensegroup.expensegroupname wdexpense u month(cast(u.expensedate date)) = month(now()) , year(cast(u.expensedate date)) = year(now()) group u.wdexpensegroup.expensegroupid], line 1, column 91: unexpected token [(]. internal exception: noviablealtexception(83!=[661:1: simpleconditionalexpressionremainder[object left] returns [object node] : (n= comparisonexpression[left] | (n1= not )? n= conditionwithnotexpression[(n1!=null), left]

c++ - Why does adding a '0' to an int digit allow conversion to a char? -

i've seen examples of on place: int = 2; char c = + '0'; string s; s += char(i + '0'); however, have not yet seen explanation why adding 0 allows conversion. if @ ascii table, asciitable , you'll see digits start @ 48 (being '0') , go 57 (for '9'). in order character code digit, can add digit character code of '0'.

ios - Rank in Game Center dosn't appear in current version? -

i used robovm-ios-bindings integrate game center in ios game , works !.however,when tested again after downloading app store,there's strange problem.as know, can tap rank app game center.that way ranking app. when tapped 5 stars rank app through iphone,it works!but when opened app store check out,the current version still gets no ranking old version did. say,the ranking count increased(+1) in old version except new one.of course,i using new version rank! why app still has no ranking on.i appreciate help! ps:how rankings users way apple doesn't refused? thanks! even though don't know why,but problem solved.may there wrong apple

node.js - javascript use response from function in calling function -

i've got basic example of of node-geocoder, can't response bubble calling function var address = userupdates.address + " " + userupdates.city + ", " + userupdates.state + " " + userupdates.zip; geocoder.geocode(address) .then(function(res) { console.log(res); }) .catch(function(err) { console.log(err); }); the console.log produces correct json [ { latitude: 35, longitude: -78.5, country: 'united states', city: 'clayton', state: 'north carolina', statecode: 'nc', zipcode: '27520', streetname: 'main st', streetnumber: '100', countrycode: 'us' } ] but can't assign res persist outside geocoder.geocode function have tried creating global variable outside of geocoder.geocode function hold value? var globalres = null; geocoder.geocode(address)

Garbage value coming using arrays in C -

#include<stdio.h> int i; float *calculateproduct(int *,int *,int ); int main() { int n; printf("enter length of array\n"); scanf("%d",&n); int x[100]; int y[100]; for(i=0;i<n;i++) { scanf("%d",&x[i]); } for(i=0;i<n;i++) { scanf("%d",&y[i]); } /*for(i=0;i<n;i++) { printf("%d ",x[i]); } printf("\n"); for(i=0;i<n;i++) { printf("%d ",y[i]); } printf("\n"); */ int *ptr; ptr=calculateproduct( x, y, n); for(i=0;i<n;i++) printf("%d ",*(ptr+i)); return 0; } float *calculateproduct(int *x,int *y,int n) { int z[100]; for(i=0;i<n;i++) { z[i]=x[i]*y[i]; } return z; } in above code want

javascript - Get id of clicked element using jquery -

this question has answer here: jquery: parent, parent id? 3 answers i have series of select boxes within table. html is: <td id="1"> <select id="a" name="xxx"> <option ... </option> </select> </td> <td id="2"> <select id="b" name="yyy"> <option ... </option> </select> </td> ... etc. when select box option changed, how can use jquery return id of select box , td? i think should like: $(document).ready(function() { $('select').change(function() { var id = $(this).attr('id'); return false; }); }); working fiddle you can use on function change event , find td using closest $(document).ready(function() { $('select').on('change',function() {

IOS storyboard uiview and uiscrollview position -

i created uiviewcontroller in storyboard , hierarchy follows : -- uiview --- uiview ( iboutlet -> scrollcontentview) ---- uilabel ---- uilabel .... in class function viewdidload : [_scrollcontentview removefromsuperview]; uiscrollview *scrollview = [[uiscrollview alloc] initwithframe:self.view.frame]; [self.view addsubview:scrollview]; [scrollview addsubview:_scrollcontentview]; [scrollview setcontentsize:_scrollcontentview.size]; [scrollview setdelegate:self]; run it, coordinates of starting point in middle of display screen _scrollcontentview. print _scrollcontentview point (0,0), why it's position wrong? i test add new uilabel scrollview, label's point (0,0), it's not iboutlet , it's display normal.

regex - Regular expression to match variable=value but ignore trailing blanks and comments -

i trying parse driver inf file , extract "variables" , "values" sections. have come basic regular expression: "(.+?)\s*=\s*(.+)" this matches variable fine matches after equals , whitespace. in these files there may optionally trailing comments begin semicolon , dont want match. thought i'd try: "(.+?)\s*=\s*(.+);?" but doesnt work. other issue there may white space before semicolon want ignore there may white space within value want match. here examples (using variable first match , value second): class=display (the variable should "class" , value "display" defaultdestdir = 11 ; system32 (variable="defaultdestdir" , value="11") cpuxyz = 16483,au zy xy open ; comment (variable = "cpuxyz" , value = "16483,au zy xy open") i'm looking expand initial regular expression "value" can cope of above examples. negative character cl

c# - LoadCompleted event in WPF WebBrowser is not working -

i have wpf webbrowser control. <webbrowser name="wbmap"></webbrowser> in code behind, calling function in constructor setting navigation path , calling script in loadcompleted event. private void loadmap() { if (designerproperties.getisindesignmode(this)) return; //get application execution path string appdir = system.io.path.getdirectoryname(appdomain.currentdomain.basedirectory); //combine application execution path map file name string mappath = system.io.path.combine(appdir, "map.html"); //navigate browser above path wbmap.navigate(mappath); wbmap.loadcompleted += wbmap_loadcompleted; } void wbmap_loadcompleted(object sender, system.windows.navigation.navigationeventargs e) { wbmap.invokescript("setlocation", "red"); } this javascript function set default location on google map. when invoking in loadcompleted event, cannot see marker. whereas, when put button , add in bu

Assignment of arrays in C++ like Matlab? -

so in matlab , if make n x n x n x n x 6 dimensional matrix, can assign values matrix in groups of 6 so: mymatrix(1,1,1,1,:) = [69, 3, 864, 21, 95, 20]; is there analogous way write n x n x n x n x 6 dimensional matrix in c++ in groups of 6? also, there analogous way set 6 elements equal 6 elements i.e myarray(n,n,n,8,:) = myarray(n,n,n,6,:)? (no std::vector solutions please- need keep matrix in array form existing code built arrays using c++/cuda , extremely complex) with #include <algorithm> , may use std::copy : int mymatrix[n][n][n][n][6]; const int src[6] = {69, 3, 864, 21, 95, 20}; std::copy(std::begin(src), std::end(src), mymatrix[0][0][0][0]); and equivalent of myarray(n,n,n,8,:) = myarray(n,n,n,6,:) be: std::copy(std::begin(mymatrix[n-1][n-1][n-1][5]), // source start std::end(mymatrix[n-1][n-1][n-1][5]), // source end std::begin(mymatrix[n-1][n-1][n-1][7])); // dest start note indexing in c/c++ start @ 0 , not @

node.js - Change nodejs temporary directory -

i want make file upload using nodejs, fs.rename() cannot move file between 2 different disks/partitions, don't want copy uploaded file temporary directory. want change temporary directory fs.rename() work. how can that? thanks! the module responsible formidable , , can set uploaddir , per readme: form.uploaddir = "/my/dir"; sets directory placing file uploads in. can move them later on using fs.rename() . default os.tmpdir() .

jdbc - Weblogic jdbcdrivers.xml entry for jtds -

this entry setting jdbc sqljdbc4.jar <driver database="ms sql server" vendor="microsoft" type="type 4" databaseversion="2005 , later" forxa="false" classname="com.microsoft.sqlserver.jdbc.sqlserverdriver" urlhelperclassname="weblogic.jdbc.utils.mssql2005jdbc4driverurlhelper" testsql="select 1"> <attribute name="dbmsname" required="true" inurl="true"/> <attribute name="dbmshost" required="true" inurl="true"/> <attribute name="dbmsport" required="true" inurl="true" defaultvalue="1433"/> <attribute name="dbmsusername" required="true" inurl="false"/> <attribute name="dbmspassword" required="true" inurl="false"/> </driver> whats appropriate urlhelperclassname

Swift: Generics & downcast to AnyObject -

i have following situation: (just copy playground) import cocoa protocol uid { var uid: int {get set} } class : uid { var uid = 01 } class manageuid<t: uid> { let cache = nscache() func adduid(aobj: t) { cache.setobject(aobj, forkey:aobj.uid) } func deleteduid(aobj: t) { cache.removeobjectforkey(aobj.uid) } } this lead error "could not find overload setobject ..." well know problem type of aobj in adduid, not clear compiler. on way say func adduid(aobj: t) { cache.setobject(aobj a, forkey:aobj.uid) } but in case can skip generic topic completely. try downcast aobj anyobject or nsobject did not work. any ideas? i nice have generic version of cache :) update: on solution add @objc attribute on protocol, therefore protocol usable classes lead general restriction protocol. local solution in class manageuid. i found solution, primary derived answer of question here: https://devforums.apple

jquery - Change only jqGrid Subgrid header styles -

Image
i've jqgrid , grid subgrid . want have different header style (say background color) subgrid. i've tried change .ui-jqgrid-htable,.ui-widget-header classes,but it's impacting both main grid , subgrid headers. how can change subgrid header styles? you can set background css style on .ui-jqgrid .subgrid-data .ui-th-column example overwrite default background image , background color used in column headers. for example the following demo remove default background image , set yellow background color respect of following css .ui-jqgrid .subgrid-data .ui-th-column { background: yellow } the results on picture below updated : 1 can consider remove column headers subgrid @ all. interesting example in case when subgrid have 1 column (one can use autowidth: true option in subgrid additionally) or in case when subgrid have the same column headers main grid. see the answer more information.

c# - .NET Connection pool doesn't recover after short forced single user mode of target DB -

our app connecting our db using following connection string: data source=<ip>;initial catalog=<dbname>;user id=<account>;password=<password> it uses try store data in loop can simplyfied following pseudocode: bool stored; { (using)(sqlconnection conn = new sqlconnection(staticconnectionstring)) { try { conn.open(); //create sp command , execute here stored = true; } catch(exception e){/* log , sleep few secs */} } }while(!stored) we experienced issues blocking , extremely high disk i/o due wrongly designed index. put db single user mode: alter database <dbname> set single_user rollback immediate go and fixed issue , flipped db multi_user. after other instances of our exe reconnected fine db - exe trying insert quite lot of data (previous loop running in dozens parallel threads different records) hasn't recovered hour after (than restarted). continuously get

c++ - Exceptions with new and exceptions without new operator -

as title says, difference between these 2 ways of throwing exception? void method1() { //... throw new myexception(); } void method2() { //... throw "my exception"; } i afraid of memory leaks. in method1 must free memory allocated new? in method2, string allocated on heap (again frees it?)? or passed return value on stack? there many reasons throw value , catch reference if throw pointer dynamic memory, you'll have manually deal memory management on catch site. as proposed in c++ coding standards : if feel must throw pointer, consider throwing value-like smart pointer such shared_ptr<t> instead of plain t* .

iphone - Inserting Images in Specific Album on Picasa in iOS -

i working ios application in upload images on picasa web albums ios application.when create album firstly check whether album same name exist or not fetch albums name , album id below code. for (gdataentryphotoalbum *albumentry in feed) { nsstring *title = [[albumentry title] stringvalue]; nsstring *title1 = [albumentry gphotoid]; nslog(@"file title: %@ | id: %@",title,title1); } i album name , albumid . check current album name given user. if ([title isequal:albumname]){ //do not create new album // return album id } else{ //create new album } everything working fine ,but problem how can send albumid uploading method below mentioned: - (void)_startupload:(uiimage *)image:(nsstring *)filepath{ nslog(@"album feed %@",albfeed); // user/11106615845/albumid/6029121 gphotoid:60291215413 //gdatafeedphotoalbum *albumfeedofphotos = [self photofeed];

c++ - fork() system call within a daemon using _exit() -

there lot of questions on fork() little bit confused in code.i analyzing code in c++ in have got function. int daemon(int nochdir, int noclose) { switch (fork()) { case 0: break; case -1: return -1; default: _exit(0); /* exit original process */ } if (setsid() < 0) /* shoudn't fail */ return -1; /* dyke out switch if want acquire control tty in */ /* future -- not advisable daemons */ printf("starting %s [ ok ]\n",agent_name); switch (fork()) { case 0: break; case -1: return -1; default: _exit(0); } if (!nochdir) { chdir("/"); } if (!noclose) { dup(0); dup(1); } return 0; } so fork create exact copy of code fork() has been called. so, is switch executed twice or once? if twice in switch if child executes first? break or go other statements? what if parent executes? main process terminated , child continue? edit: switch

text - How do I replace a word in a string in python? -

let have string c = "a string , roberta a thanks" i want output as ' string , roberta thanks" this trying c.replace('a', ' ') ' string nd robert thnks' but replaces each 'a' in string so tried c.replace(' ', ' ') 'a string , roberta thanks' but leaves out 'a' in starting of string. how do this? this looks job re : import re while re.subn('(\s+a\s+|^a\s+)',' ',txt)[1]!=0: txt=re.subn('(\s+a\s+|^a\s+)',' ',txt)[0]

jar - Error Executing Batch file of BlazeDS -

Image
i'm trying see samples of blazeds in web brower shown in tutorial on webpage. after have started tomcat open localhost link 8400/samples in browser shown below.after entering url following page in browser.. after try start sample database according instructions given in box @ starting of webpage. after run specified command on command prompt following error message.. i can't seem understand error.even though have set java_home variable follows still getting error.. is error due firewall problem? or else?? please help.. java not internal command of cmd.exe . as command without file extension , without full path, windows searches first in current directory c:\blazeds\sampledb java.* find either java.com , java.exe , java.bat , java.cmd , other file extensions. the file extensions defined in environment variable pathext separated semicolons can viewed in command prompt window command set pathext if there no such file file name java in curre

javascript - Menu button with dropdown -

Image
i want create menu dropdown dropdown won't work. it fiddle. there code button don't show. don't know why. here fiddle: jsfiddle <ul class="dropdown-menu" role="menu"> <li><a href="#">action</a></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> <li class="divider"></li> <li><a href="#">separated link</a></li> </ul> i use bootstrap 3.0 here image how looks : remove overflow:hidden of div , img css , assign .wrapper working demo .wrapper{ border: 1px solid black; margin: 4em auto; position: relative; width: 502px;overflow:hidden; }

javascript - Why doesn't my high-chart load on subsequent jquery-ajax call? -

Image
here how passing php array data through jquery ajax , after process on called php script loads succesfully first time further request not showing updated data. i have 2 questions 1: if load page(mydomain.com/new.php) directly check chart functioning (here manually setting $_post value of $myarray) , loading fast , quick, when called via ajax taking lot of time.? this question know how things works 2: first time loads though taking own time, when again click button call chart, remaining text gets loaded not chart? mypage.php <?php $acoders = array(); $acoders['ed']['age'] = 25; $acoders['ed']['languages'] = array('php', 'mysql', 'javascript', 'objective-c', 'html', 'css'); $acoders['sarah']['age'] = 25; $acoders['sarah']['languages'] = array('html', 'css'); ?> /* html part */ <b

Editing Regex Code -

i hoping can me think regex problem. i have program takes piece of html code , extracts phone numbers , separates them semi colons. change extracts between 2 specific text strings backslashes in between. example stringone/******/stringtwo stringone/876876876876876/stringtwo stringone/abcdefghijklmnopqrstuvwxyz/stringtwo before , after total string there may or may not spaces, letters, numbers or special characters. i have tried regex can't figured out. assume (and instinct) line needs changing one: .pattern = "(\+([\d \(\)-]+){10,15})|((\d( |-))?\(?\d{2,4}\)?( |-)\d{3,4}( |-)\d{3,4})|(\d{3,4}( |-)\d{7})" but entire code follows: function main ( strtext ) dim strresult strresult = extract_phone_numbers ( strtext ) main = strresult end function ' function extracts phone numbers specific string using pattern matching (a regular expression). function extract_phone_numbers ( strtext ) dim strresult set regularexpressionobje

version control - how to install scmtools on linux machine? -

i wanted install scm tools on linux machine ( red hat 5 ) without eclipse ide. the following steps followed: i didn't install eclipse on machine? installed java 1.6 version on linux machine. set java_home installed scm tools related rtc version 4.0.4. when trying use scm commands error thrown: unrecognized option: -xdump:system:events=systhrow,filter=java/lang/outofmemorye rror,request=exclusive+prepwalk could not create java virtual machine . scm: jvm terminated exit code=1 /usr/lib/jvm/java-1.6.0-sun-1.6.0.37.x86_64/jre/bin/java -xmx512m -dosgi.requiredjavaversion=1.6 -xdump:system:events=systhrow,filter=java/lang/outofmemoryerror,request=exclusiv e+prepwalk -jar /install/rtc/jazz/scmtools/eclipse//plugins/org.eclipse.equinox.launcher_1.

javascript - Appending to URL end with JS request on form change -

my code follows: <h1>sort by</h1> <form> <select name='myfield' onchange='this.form.submit()'> <option value="relevance">relevance</option> <option value="date">date posted</option> </select> <noscript><input type="submit" value="submit"></noscript> </form> whenever change form , auto-submits, new field "myfield" added url end. how can url remain same, , add "myfield" query end of url, not deleting existing url query strings? store url parameter values in hidden field same name ex: url: http://localhost/test.php?myfield1=x <h1>sort by</h1> <form> <input type='hidden' name='myfield1' value='<?php echo $_get['myfield1']; ?>' /> <select name='myfield' onchange='this.form.submit()'> <option value="relevance">r

javascript - jQuery UI resizable overlap issue -

i getting issue resizable class in jquery ui ( http://jqueryui.com/resizable/ ) when resizing start, of below div move overlap div getting resized. using js console in chrome, i've noticed resizable put in csstext. (position: absolute; top: 24px; left: 593.90625px; height: 218px; width: 161px;) removing it, overlapping stop, div not resized anymore. html : <div id="widget1" class="widget taille-2-2 drag"> val : <span id="span1">10</span> </div> <div id="widget2" class="widget taille-1-1 drag"> val : <span id="span2">20</span> </div> <div id="widget3" class="widget taille-2-1 drag"> val : <span id="span3">30</span> </div> css : .widget { padding: 2px; border: 2px solid #ccc; float: left; overflow: hidden; } .taille-1-1 { width: 47px; height: 47px; } .taille-2-1 { width:

laravel - How can I set value for extra field on Eloquent pivot table -

$recourse->pivot->field = 'value'; gives error: indirect modification of overloaded property pivot available in context of relation: // won't work $model = model::first(); $model->pivot; // null // work $anothermodel = anothermodel::first(); $relatedmodel = $anothermodel->relation()->first(); $relatedmodel->pivot; // pivot object but trying use additional param in save method: $product = product::find($item->id); $order->product()->save($product, ['price' => 12.34]); for existing relation: $product = $order->product()->find($productid); $product->pivot->price = 12.34; $product->pivot->save(); // or $order->product()->updateexistingpivot($productid, ['price'=>12.34]); and suggest use products kind of relation in order make easier read.

php - Changing the visibility scope of parent methods in child classes -

i've got validator class , uservalidator class extends it. my validator has public method setrule(...) public visibility. when extend want change visibility of setrule(...) parent method private/protected within child it's visible child , no outsiders can call method from child. is possible? if so, how achieve it? from architectural point of view not recommended. stated in comments clean way set method protected children can access it. i cannot think of single use case put me in need call public method on parent class not allowed call on child class. that's against open/closed principle. classes should open extension, not modification. since not question i'll provide way how can achieved though. note: this method makes use of class responsible instantiation it's hack. solution not make use of php's native language features when throwing accessibility errors. first let's define classes had <?php class validator {

android - Asynctask define a Constructor -

in app, trying build asynctask should, in background each row sql database , write csv file. in activity have button onclicklistener executes asycntaskrunner so: //this task run in background , transmit data csv asynctaskrunner runner = new asynctaskrunner(); runner.execute(); then in asynctaskrunner class have following: public class asynctaskrunner extends asynctask { protected string doinbackground(string... params) { // create new csv file based tid of newest test log.e(csv, "async task runner string started"); return null; } @override protected object doinbackground(object... params) { log.e(csv, "async task runner object started"); filenamecsv = mcreatenewcsvfile(); log.d(csv, "the new csv file " + filenamecsv); return null; } public string mcreatenewcsvfile() { sqldatabase nexttest = new sqldatabase(this); nexttest.open(); string csvfilename = sqldatabase.getrunningtests(); nexttest.close(); return c

query performance - Multi Thread in SQL? -

i have sql query like select column1, column2, column3, **ufn_hugetimeprocessfunction**(column1, column2, @param1) column4 table1 this ufn_hugetimeprocessfunction function run against large table (in terms of number of rows) , there several calculation behind return value. am able force sql compiler run function in thread (process)? edited : function data 3 different databases. that's why planing run "in parallel", not possible change indexes on other databases if server computer on sql server running has multiple cpu's sql server can run single query in parallel using multiple threads. in addition running user queries on multiple processors sql server can use multiple threads build indexes. when examining textual or graphical execution plans notice exchange operators distribute streams, repartition streams , gather streams if query using more 1 processor. typically queries make heavy use of cpu cycles candidates parallel execution. example qu

Rails Couldn't find user with auth_token -

i have started rather strange issue rails 3.2.18 app i using authentication cookies described on railscasts. past year (until upgraded 3.2.18) has been well. however have following issue. can log on successfully, , navigate few pages. however, after undetermined number of page clicks 500 internal page error. in production log see following error (i have changed actual token code) activerecord::recordnotfound (couldn't find user auth_token = xxxxxxxxxxxxxx): app/controllers/application_controller.rb:28:in `current_user' when @ database entry user see correct auth_token entry. line of code being referenced in application controller is @current_user ||= user.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token] so yes, need replce witth rather find_by statement things woork in rails 4, this, don't think, should causing issue, odd inital authentication , few pages clicks work, , doesn't work. to able login in again have shutdown browser sessi

c# - When should I provide a generic and non generic version of an interface? -

i understand difference between deep , shallow clone of object, according simon's answer on this (copy-constructor-versus-clone) question, generic , non-generic version should supplied. why? you can define 2 interfaces, 1 generic parameter support typed cloning , 1 without keep weakly typed cloning ability when working collections of different types of cloneable objects: i mean it's trivial enough make different interfaces, in generic-heavy paradigm of modern c#, finding difficult come valid reason why ever want use non-generic , weakly-typed version. heck, can have t:object , same thing! i write interfaces this: public interface ishallowcloneable { object clone(); } public interface ishallowcloneable<t> // should derive ishallowcloneable? { t clone(); } public interface ideepcloneable { object clone(); } public interface ideepcloneable<t> // should derive ideepcloneable? { t clone(); } and class implement this: public class

neural network - JNA class not Found Error using FANNJ for Ubuntu in Eclipse -

i'm trying use fannj in eclipse (on ubuntu), trying create toy program keeps giving error shown below. code: package mypackage; import com.googlecode.fannj.fann; public class mainclass { public static void man(string[] args) { system.out.println("1"); fann fann = new fann("/home/sahil/desktop/intern/java/eclipse/workspace/usingfann/ann_net_output1.net"); } } error: exception in thread "main" java.lang.noclassdeffounderror: com/sun/jna/platform @ com.googlecode.fannj.fann.<clinit>(fann.java:51) @ mypackage.mainclass.main(mainclass.java:9) caused by: java.lang.classnotfoundexception: com.sun.jna.platform @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.jav

How to extract type definitions from OCaml code -

is there way extract type definitions bunch of ocaml files? can cut , paste them separate editor tab, it's easy stare @ them in way fits information on screen @ possible. however, chore , i'd prefer make automated. to make precise, emacs , tuareg mode shows me types of functions, i'd want able collect nice cheat sheet of each type is. modules, there's mli-file, else collecting them 1 place overview of bunch of code annoying. it's difficult understand you're asking for. maybe if collect everybody's suggestions 1 place. as nlucaroni points out, can't have solution modules want works else. there nothing else. ocaml code part of module. you mli files ok. if module doesn't have mli file, can generate mli file ocamlc -i camlspotter says. if doesn't work, give example of ocaml code , extracted definitions want see it.

google apps script - How to store global values correctly using Properties service in GAS? -

i have problem using google apps script. have menu in spreadsheet 2 options (set password , add time record). these options raise ui service user interfaces prompt data respectively. access add time record ask before if user authenticated. use scriptproperties = propertiesservice.getscriptproperties() , setproperty('authenticated', false) save initial value of authenticated. 1- click set password, login ok , close ui. 2- click add time record , expect receive addtime record ui (because set password first) instead receive set password ui. if login again receive same ui …again , again. is authenticated reset false every time click in menu option no matter action did before. expected behavior? or i’m doing wrong? lot help. var scriptproperties = propertiesservice.getscriptproperties(); scriptproperties.setproperty('authenticated', 'false'); function onopen() { var ui = spreadsheetapp.getui(); ui.createmenu('proworkflow') .additem(

Mirroring a git subdirectory in a SVN subdirectory -

yes, know there ton of version control questions on here, none of proposed solutions want them , can't find way hack 1 together. i've been looking week now. my setup: windows 7 machine (with cygwin-- though haven't touched problem), remote password-protected git repo , svn repo. gradually switching using svn git new projects (no 1 has used git before) , need shuffle code , forth. what want: i , several other people should able work in gitproject/path/to/sharedcode , have our commits automatically update svnproject/trunk/path/to/sharedcode . should affect 2 subdirectories, rest of repos should remain independent. i'm looking one-way, permanent link git subversion. history needs preserved in git, not in svn, no development take place there. additionally, repeatable in future can set anothersvnproject/trunk/path/to/sharedcode mirror in same way. possible solutions: a script checks changes in gitproject/path/to/sharedcode (runs git diff ) and, if finds