Posts

Showing posts from January, 2015

the fastest way to get xml and use it in php -

until doing @simplexml_load_file , on returned xml going xpath the website got big traffic , taking alot of time xml load. the host told me try get_file_contents don't know in order read returned content xml object they said try curl or wget me same first 1 i'm stuck with what can in order xml, fest possible partners api, , still able read xml? the fastest xml library in php xmlreader . it's pretty obscure ( i think has few php users understand , able use it ) blazing fast because: the xmlreader extension xml pull parser. reader acts cursor going forward on document stream , stopping @ each node on way. which means xml document not preloaded in memory. part it's parsing loaded in memory.

design patterns - python pool apply_async and map_async do not block on full queue -

i new python. using multiprocessing module reading lines of text on stdin, converting them in way , writing them database. here's snippet of code: batch = [] pool = multiprocessing.pool(20) = 0 i, content in enumerate(sys.stdin): batch.append(content) if len(batch) >= 10000: pool.apply_async(insert, args=(batch,i+1)) batch = [] pool.apply_async(insert, args=(batch,i)) pool.close() pool.join() now works fine, until process huge input files (hundreds of millions of lines) pipe python program. @ point, when database gets slower, see memory getting full. after playing, turned out pool.apply_async pool.map_async never ever block, queue of calls processed grows bigger , bigger. what correct approach problem? expect parameter can set, block pool.apply_async call, queue length has been reached. afair in java 1 can give threadpoolexecutor blockingqueue fixed length purpose. thanks! just in case 1 ends here, how solved problem: stopped using

c# - GUI code generation based on class -

i looking sw tool generate somehow c# source code user interface input form based on existing classes. to more specific, have class represents person, eg. person object based on class simple having, string properties id, name, surname number properties age, height, weight, date properties birthday , methods read, write, delete etc. make generic like. now looking generate source code windows form (web form follow similar way) mapping eg. string properties text boxes, numbers same, methods buttons , actions etc. nice if 1 can use configuration , options tune code generation. if have ever used devexpress, looking or similar gui generator commercial tool have. thanks in advance time , support. semag seems me binding simple property sheet place start.

How do you paint a stroke in Gimp with Python-fu? -

i'm using python-fu's gimp.pdb.gimp_paintbrush_default(layer, 2, [10,10, 20,20]), no matter how many strokes tell paint, ever paints first (x,y) (in case, (10,10)). expecting different format? documentation function isn't python plugin, , says third parameter expects variable of type floatarray. assume python version uses list here, doesn't seem ahead values after first two. how can paint more 1 control point? the second parameter pass - in case "2" indicates gimp length of list in following parameter - although, when coding in python used called function don't have problem finding length of list, these calls in gimp python scripting 1:1 mapping gimp api several other languages, , written in c. in c there no way 1 know length of array passed, unless explicitly passed, so, there need parameter. try doing instead: points = [10,10, 20,20] pdb.gimp_paintbrush_default(layer, len(points), points)

java - JTable swing import database sql -

could provide me example or tutorial on how import data mysql database within jtable within use of gui. tried looking example have not found anything. hopefully can put question rest connection db = drivermanager.getconnection( jdbc:mysql://192.168.0.3:3306,<user>,<password>); statement stmt = db.createstatement(); preparedstatement psmt = con.preparestatement("select * db"); resultset rs = psmt.executequery(); // column names int len = rs.getmetadata().getcolumncount(); vector cols= new vector(len); for(int i=1; i<=len; i++) // note starting @ 1 cols.add(rs.getmetadata().getcolumnname(i)); // add data vector data = new vector(); while(rs.next()) { vector row; = new vector(len); for(int i=1; i<=len; i++) { row.add(rs.getstring(i)); } data.add(row); } // create table jtable table = new jtable(data, cols);

amazon web services - Use CurrentLocation for Continent iPhone -

is there way find out users location continent? need set aws entry point based on if open app in us, or europe. etc. is there way without taking gps coordinates , making ranges out of them? if in ios5, can use glgeocoder retrieve information abotu current location: [self.clgeocoder reversegeocodelocation: locationmanager.location completionhandler: ^(nsarray *placemarks, nserror *error) { clplacemark *placemark = [placemarks objectatindex:0]; //placemark contains address }]; clplacemark reference: https://developer.apple.com/library/ios/#documentation/corelocation/reference/clplacemark_class/reference/reference.html glgeocoder reference: https://developer.apple.com/library/ios/#documentation/corelocation/reference/clgeocoder_class/reference/reference.html

c++ - Access base class function from derived class -

i wanted ask if im understanding process right: http://doc.trolltech.com/qq/qq17-ratecontrol.html#whoneedstrafficcontrolanyway in example there rctcpsocket derived qtcpsocket in member function of qtcpsocket overwritten, namely qint64 rctcpsocket::bytesavailable() const. following line call member function direclty base class: qtcpsocket::bytesavailable() i mean qtcpsocket additional functions , overwritten function bytesavailable(). call non-overwritten function? this syntax forms indeed allows call ascendant implementation of function , not overridden one. most usefull if want add code own class implementation still let parent class "core stuff"

iphone - How To animate image using uibuttons -

i have 3 uibuttons named 1,2 , 3 , right @ bottom of buttons have arrow image indicates current button pressed. want when press of button arrow starts animating , slides @ bottom of button pressed. (void)setimage:(uiimage *)image forstate:(uicontrolstate)state; and select uicontrolstate from enum { uicontrolstatenormal = 0, uicontrolstatehighlighted = 1 << 0, // used when uicontrol ishighlighted set uicontrolstatedisabled = 1 << 1, uicontrolstateselected = 1 << 2, // flag usable app (see below) uicontrolstateapplication = 0x00ff0000, // additional flags available application use uicontrolstatereserved = 0xff000000 // flags reserved internal framework use }; typedef nsuinteger uicontrolstate;

sql server - Move database tables, doing some transformations - SSIS -

i need move data 1 ms sql database another. however, destination database bit different. example, table has same rows, different data types , on. read, looks ssis tool, however, how process , components toolbox use example above? concern might have create 1 data flow source each table or that. anyway, less time consuming option? thank you! given it's disposable task , data volume low, i'd use import/export wizard generate basics of moving tables. can either right-click on database in ssms, tasks, export... or run dtswizard.exe commandline/start->run either way, you'll have wizard walking through variety of screens. of them self-explanatory never stops me commenting. first 2 screens define source , destination. default of both of of "sql server native client 10.0" correct, define source , destination server names , database/catalogs. 3rd screen accept default of copoy data 1 or more tables or views. 4th screen allows pick source tables , d

How do I get rid of unwanted nodes returned by findnodes from Perl's XML::LibXML module? -

following small fraction of xml working on. want extract attributes, tag name , texts under substree. <?xml version='1.0' encoding='utf-8'?> <warehouse> <equipment id="abc001" model="tv" version="3_00"> <attributes> <location>chicago</location> <latitude>30.970</latitude> <longitude>-90.723</longitude> </attributes> </equipment></warehouse> i have coded example this: #!/usr/bin/perl use xml::libxml; use data::dumper; $parser = xml::libxml->new(); $chunk = $parser->parse_file("numone.xml"); @equipment = $chunk->findnodes('//equipment'); foreach $at ($equipment[0]->getattributes()) { ($na,$nv) = ($at -> getname(),$at -> getvalue()); print "$na => $nv\n"; } @equipment = $chunk->findnodes('//equipment/attributes'); @attr = $equipment[0]->childnodes; print dumper(@attr); foreach $at (@

python - File not being released -

ok have run queries in access 07 compact , repair it. using python , win32com this. code i'm using this. import os; import win32com.client; db1 = 'db1.mdb' db2 = 'db1n.mdb' db3 = 'db2.mdb' dbr = r'db1.mdb' access = win32com.client.dispatch("access.application") access.opencurrentdatabase(dbr) db = access.currentdb() access.docmd.openquery("1") access.docmd.openquery("2") access.docmd.openquery("3") access.closecurrentdatabase() access.application.quit(); os.system('copy "db1.mdb" "db2.mdb"') access = win32com.client.dispatch("access.application") access.compactrepair(db3,db2) access.application.quit(); os.remove("db2.mdb") os.remove("db1.mdb") os.rename("db1n.mdb","db1.mdb") the problem error. windowserror: [error 32] process cannot access file because being used process: 'db1.mdb' i dont know why getting error see

Collation To Code Page (SQL Server) -

how can determine code page particular collation on sql server uses? the collationproperty function can used code page. here code page every possible collation: select [name], [description], [codepage] = collationproperty([name], 'codepage') ::fn_helpcollations()

Size of Safari jQuery Slider plugin -

i'm using this fantastic jquery slider plugin, optimized mobile devices , works scales , numbers. now want increase handles , slider itself, know how it? you need edit both image assets , .css file, below portion of css editing.. //---------------------------------------------// .jslider .jslider-pointer { width: 13px;//<-- increase width here match new image... height: 15px;//<-- increase height here match new image... background-position: 0 -40px; // you'll editing here based on changes make image, imagemap of multiple different distinct image elements in jslider. changes here need applied throughout other elements position: absolute; left: 20%; top: -4px; margin-left: -6px; cursor: pointer; cursor: hand; } //---------------------------------------------// .jslider .jslider-bg i, .jslider .jslider-pointer { background: url(../img/jslider.png) no-repeat 0 0;//<-- edit image dimensions need } //

sql - Stored procedure for adding a movie -

i'm creating stored procedure adding movie (i'm working on application stores , lists movies information), , before getting started input on how create it. i have following tables: "movie" (movieid, name, year, length, summary) "genre", list of genres (genreid, genre) "moviegenre", list of movies , genre/s. (moviegenreid, genreid, movieid) "movierole", stores name of actors/directors etc (movieroleid, name) "movieroletype", stores different kinds of roles movie, actor (movieroletypeid, movieroletype) "cast", list of movies cast's (castid, movieroletypeid, movieid, movieroleid) when adding movie must provide information movie, @ least 1 movie role (eg. actor) , genre. should create several sp:s , execute them 1 sp, or how should do? note: i'm not asking write whole sp me, asking guideline. thanks in advance! i create several separate stored procedures , use transaction make sure ins

Embed flash stream for android web browser -

i have been scratching head several days on issue. attempting embed flash stream own3d.tv in html page view-able in android web browser. no matter flash object goes white several seconds after page loads. have tried copying exact code using swfobject have had no luck. more confusing part able view same stream on homepage fine. (own3d.tv). here details: what using: android 4.0.1 on google galaxy nexus swfobject 2.0 flash 11 always use stream id online the code: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <style type="text/css"> * { margin: 0; padding: 0; } body { text-align: center; } html, b

objective c - Saved Core Data does not persist after app closes 80% of the time -

i started dealing core data lately, , in tests, i've found 20% of time data gets saved db. rest of time, it's saved temporarily, while app running. if restart, last data saved gets lost. does know problem be? here's code: //save data nsentitydescription *users = [nsentitydescription insertnewobjectforentityforname:@"users" inmanagedobjectcontext:document.managedobjectcontext]; [users setvalue:@"name test" forkey:@"name"]; [users setvalue:[nsnumber numberwithint:20] forkey:@"age"]; [users setvalue:@"some country" forkey:@"location"]; //debugging //no error ever shows nserror *error; if(![document.managedobjectcontext save:&error]) { nslog(@"error: %@", error); } //this show problem may not uimanageddocument (self.document), since nslog never gets called. if(self.document.documentstate != uidocumentstatenormal) { nslog(@"document not opened"); } //end of debugging //fetc

history - Jquery Asual Address - Back Button PopState -

i trying use asual address plug in button works on ajax calls. confused on how work , every tutorial find says impliment different. haven't been able of them work. i have simple ajax page. calls in image: javascript: <script type="text/javascript"> $("a").live("click", function(event) { url = $(this).attr("href"); $.address.value($(this).attr('href')); event.preventdefault(); $.ajax({ type: "get", url: "/"+url+".php", data: "", datatype: "html", success: function(html){ jquery('#right_content').hide().html(html).fadein(1000); }, }) }); </script> my html looks this: <body> <a href="push1" onclick="return false;" >image 1</a> <a href="push2" onclick="return false;&q

Rails Nested Attributes and Model Inheritance -

looking @ example of form_for rails docs , see example: <%= form_for @person |person_form| %> first name: <%= person_form.text_field :first_name %> last name : <%= person_form.text_field :last_name %> <%= fields_for @person.permission |permission_fields| %> admin? : <%= permission_fields.check_box :admin %> <% end %> <%= f.submit %> <% end %> i tried copying template, noticed in order update work correctly, had change field_for line to <%= person_form.fields_for @person.permission |permission_fields| %> any idea why showing fields_for without parent form variable in front ( person_form )? the examples later in docs show parent form variable. thanks it correct person_form . think of formtag , assign inputs form. names of form set (person[attribute]). fields_for without person_form create other name (permission[admin]) - fail because permission object not connected person. through person

mod rewrite - cakephp slow because of mod_rewrite? -

i have web made cakephp 1.3.10. web seems slower every time new folders/pages added (which happens pretty often). i believe reading somewhere mod_rewrite found in 3 .htaccess files may have it. is true? i'm trying work without htaccess files, links messed up. there way avoid having edit links in website? seems have add /app/webroot/ before every file i'm linking (css, js, etc) , add /index.php before every link in website. is way? have measured how time spent in mod_rewrite , how in php? in experience problem time cake spends looking files in file system, gets progressively worse when add files , directories. you can use xdebug profile application, or add calls print time in appropriate places in framework see how time has passed since beginning of request.

javascript - How to catch exceptions thrown in callbacks passed to jQuery? -

i'd catch exceptions thrown callbacks passed jquery (either event handlers click , or jqxhr methods such then or always ). i've identified 2 options: window.onerror handler - partial solution because isn't supported on android 1 of target platforms handling exceptions within each individual callback - not dry @ all! the other thing can think of overriding jquery methods can result in problems time upgrade jquery. ajax handlers, possibly use $.ajaxsetup (per answer exceptions thrown in jquery ajax callbacks swallowed? ) i'm not sure allow me catch everything. are there other options? you can wrap each callback this: function cbwrapper(fn) { return function() { try { return(fn.apply(this, arguments)); } catch(e) { // handle exceptions here } }; } so, when go pass callback ajax call, instead of passing actual callback, pass cbwrapper(callback) . $.get(url, cbwrapper(myrealcallback));

objective c - Can't capture masks within view layer -

so i'm applying image mask uiview layer following code: calayer *masklayer = [calayer layer]; uiimage *maskimage = self.image.image; masklayer.contents = (id)maskimage.cgimage; masklayer.frame = cgrectmake(0.0, 0.0,1235, 935); self.bgview.layer.mask = masklayer; everything fine , dandy, mask covers view content , works. however, trying take screenshot let user save image. i'm using following code: uigraphicsbeginimagecontext(captureframe.size); [self.bgview.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *viewimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); uiimagewritetosavedphotosalbum(viewimage, nil, nil, nil); the frame fine, , saving photo library. problem mask applied layer not show in jpg. have tried nesting bgview uiview, , trying renderincontext: that, same thing. appears if mask not being applied in final jpg. any ideas? thank you. it's unfortunate, that's how works. documentation -[calayer

php - which is the best way - to store form values in xml -

my current website html based. my xml: <markers> <marker nn="00001" name="starbucks" address="street1" lat="-22.9063" lng="-43.2098" category="café" /> <marker nn="00002" name="tchibo" address="street2" lat="-22.9013" lng="-43.2048" category="café" /> ... </markers> the best way deal xml avoid @ cost . sane alternatives: simple custom text(utf-8) formats sexprs csv json ndb-like the case against xml

How to implement customize list view for multiple screen size in android -

i have tried customize list view multiple screen size, couldn't achieve that. can tell me how implement customize list view multiple screen size in android? have used dip in layout. when use dip, work? have given layout folder name layout layout-small layout-large ,layout-xlarge. thanks hope 1 http://geekswithblogs.net/bosuch/archive/2011/01/31/android---create-a-custom-multi-line-listview-bound-to-an.aspx http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/widget/listview.java?av=h http://www.java2s.com/open-source/android/android-core/platform-frameworks-base/android/widget/listview.java.htm http://www.smashingmagazine.com/2011/08/09/designing-for-android-tablets/

javascript - How to export canvas to HTML in Fabric.js? -

is there way export canvas element multiple objects html javascript code using fabricjs?i know can export tojson or toobject isnt html. i found http://canvimation.github.com/ has function(file>export canvas html) export canvas drawing native html code.is possible fabricjs? fabric supports export (its own) object representation , json (basically serialization of object representation), , svg . if goal create in fabric, export use in environment doesn't support canvas, maybe can use svg — long svg supported in environment. you have understand there's no such thing "native html code". there different versions of html — html4, html5, etc. canvas considered part of current html standard (html5) . drawing on canvas considered "using native html code" ;) if want recreate fabric rendering without canvas and without svg there's nothing fabric can with. unnecessarily complicated try provide canvas-less rendering of complex svg shapes, im

c++ - How to handle JPEG #41 error -

Image
i have project in c++ builder6. there's opendialog upload images project. i'd project safe , because accepts .jpg or .bmp images decided make restriction. far i'm concerned can recognize .jpg file setting stream reader 4th position. if find "jfif" here, it'll .jpeg file. , on. here's code if(opendialog1->execute()) { tfilestream *stream = new tfilestream(opendialog1->filename, fmopenread); if(stream != null) { if(stream->size < 10) { delete stream; return; } char str[10]; stream->read(str, 10); if(ansistring(str + 6).setlength(4)=="jfif") { showmessage("it's jpeg"); } else if ( ansistring(str).setlength(2)=="bm") { showmessage("it's bmp"); } else { showmessage("it can not downloaded"); return;

gnu screen - Tmux Macro/Function -

i'm trying make function in tmux when desired, can bring command prompt (ctrl-b, :) , type in , have tmux spawn new window in existing session number of panes running few specific commands. is possible? how this: create file called ~/foo.conf neww -n foo send-keys -t foo cd ~/ c-m send-keys -t foo vim c-m split-window -t foo we'll use neww create new window, we'll issue commands new window. using c-m sends enter key command executes. pass command neww directly. then in ~/.tmux.conf , bind key bind z source-file ~/foo.conf this 1 way pull off. particular scenario names window, little ingenuity, i'm sure can come workaround that. every tmux command can issued .conf files, , can issued passing tmux itself. hope helps!

c# - How to consume a ColdFusion web service with dotnet -

i'm not experienced @ in soap , web services. i'm trying call coldfusion web service c# (.net 4.0). i'm generating proxy wsdl svcutil.exe. web service works when call listcases soapui, when call proxy map single mapitem, , mapitem has null item , value. guess isn't working because wsdl doesn't include definition querybean. if problem i'll try , author of web service add definition, otherwise have options other parsing xml manually? <wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://syndication.v63" xmlns:intf="http://syndication.v63" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/xmlschema" targetnamespace="http://syndication.v63"> <!-- wsd

objective c - How to resolve Duplicate symbol between 2 libraries? -

here error logs between libfacebook_ios_sdk.a , libmmsdk.a duplicate symbol _objc_metaclass_$_sbjsonparser in /users/ragopor/desktop /objective c/archive project/my project/svn/ios temp/iportals/code/classes /facebook-ios-sdk/libfacebook_ios_sdk.a(sbjsonparser.o) , /users/ragopor/desktop/objective c/archive project/my project/svn/ios temp /iportals/code/classes/mmadview/libmmsdk.a(sbjsonparser.o) architecture armv7 since libraries compiled project, can remove sbjson files facebook sdk (or mmsdk, i've done facebook before), clean , rebuild dependency. keep in mind facebook sdk ships old version of sbjson , may have tweak of method calls uses if mmsdk ships newer one.

c++ - Exception: STATUS_ACCESS_VIOLATION - pointer referencing -

i starting c++ (that after 10 years of java!). following examples stroupstrup book. i put following code segments book. #include <iostream> #include <map> #include <string> #include <iterator> using namespace std; map<string, int>histogram; void record (const string &s) { histogram[s]++; //record frequency of "s" cout<<"recorded:"<<s<<" occurence = "<<histogram[s]<<"\n"; } void print (const pair<const string, int>& r) { cout<<r.first<<' '<<r.second<<'\n'; } bool gt_42(const pair<const string, int>& r) { return r.second>42; } void f(map<string, int>& m) { typedef map<string, int>::const_iterator mi; mi = find_if(m.begin(), m.end(), gt_42); cout<<i->first<<' '<<i->second; } int main () { istream_iterator<string> ii(cin); i

extjs - Apply grid filter programmatically from function -

using ext.ux.grid.filtersfeature, have remote filters , trying write function apply date filter on grid column programmatically (rather clicking on filter drop down menu in column header). first time run function grid store gets reloaded without filter. when run function second time (and every time thereafter) works totally fine, store reloads filters. here gist of function have: // filter object testing afilter = {type: 'date', field: 'a_date_field', comparison: 'gt', value: '2012-03-08 00:00:00'} var grid = ext.create('ext.grid.panel', { store: store, features: [{ ftype: 'filters', }], columns[{ header: 'id', dataindex: 'id', itemid: 'id', width: 40, }, { xtype: 'datecolumn', header: 'date', dataindex: 'a_date_field', itemid: 'a_date_field', width: 75, form

iphone - find road distance between current location and specified location -

i wants calculate road distance between current location , other location. (xml/json google direction or anyother) api use (if any) or right way this.? before try following. wants road distance thanks. cllocation *location1 = [[cllocation alloc] initwithlatitude:lat1 longitude:long1]; cllocation *location2 = [[cllocation alloc] initwithlatitude:lat2 longitude:long2]; nslog(@"distance in meters: %f", [location1 getdistancefrom:location2]); use google direction json api have provide intital location detail , final location. inside leg array of json distance dictionary in have distance between 2 locations.

c++ - How to use stdext::hash_set for custom type in VC++ 2010? -

i want use stdext::hash_set custom type. in fact realized how so, not sure if correcly (it compilable, looks dirty). the code follows: // custom type struct point { point(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {} int x, y, z; bool operator< (const point& other) const { if (x != other.x) return x < other.x; if (y != other.y) return y < other.y; return z < other.z; } }; // helper class struct pointhashcompare { // value copied ms sources static const int bucket_size = 1; size_t operator() (const point& p) const { return p.x * 31 * 31 + p.y * 31 + p.z; } bool operator() (const point& a, const point& b) const { return < b; } }; and declaration of variable following: stdext::hash_set<point, pointhashcompare> hset; what bucket_size in pointhashcompare mean? microsoft documentation exist explain bucket_size , suggestions value , why required

Get control id using pageid in jquery mobile -

i new jquery mobile. i using multipage template various transition effect. here way control id using page id. $(" .page1.submit ").live("click", function (event, ui) { }); $(" .page2.submit ").live("click", function (event, ui) { }); because using 5 6 pages in single html. avoid duplicate need above that. thanks in advance

Connecting to multiple Rails DBs, SQLite3 and SQLServer 2008 -

i’m trying connect sql server called demand using gem: https://github.com/rails-sqlserver/i 'm i'm following recipe #3 book 'rails recipes' http://pragprog.com/book/rr2/rails-recipes here’s database.yml file: demand: adapter: sqlserver host: 172.21.148.01 port: 1433 database: demand username: deapp password: @pp1user timeout: 5000 from rails console, when test connection demand.connection following: (i know addy , pw i'm connected via toad currently, created model 'demand' rails have object) > tinytds::error: login failed user ‘deapp’. > /users/drewgilliam/.rvm/gems/ruby-1.9.2-p290/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68:in > `connect’ > /users/drewgilliam/.rvm/gems/ruby-1.9.2-p290/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68:in > `initialize’ > /users/drewgilliam/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.1.6/lib/active_record/connection_adapters/sqlserver_adapter.rb:400:in > `new

regex - Regular expressions in a Bash case statement -

i using following script, uses case statement find server. #!/bin/bash server=$1; echo $server | egrep "ws-[0-9]+\.host\.com"; case $server in ws-[0-9]+\.host\.com) echo "web server" ;; db-[0-9]+\.host\.com) echo "db server" ;; bk-[0-9]+\.host\.com) echo "backup server" ;; *)echo "unknown server" ;; esac but not working. regex working egrep not case. sample o/p ./test-back.sh ws-23.host.com ws-23.host.com unknown server any idea ? bash case not use regular expressions, shell pattern matching only. therefore, instead of regex ws-[0-9]+\.host\.com should use pattern ws*.host.com (or ws-+([0-9]).host.com , looks bit advanced , i've never tried :-)

c# - How can I insert a table row with a FK referencing an enum equivalent db table in Fluent Nhibernate‏ -

i hope can scenario. have 2 db tables. first 1 called status , not change. contains 2 columns, 1 id , called status contains values "queued", "in process" "treated" the second table called activity , uses fk constrain status of activity using fluent nhibernate, if want insert new row table.activity need reference entity(table) 'status' in entity activity , associated mapping, example: public virtual status status { get; set; } // activity entity class references(a => a.status); // activity mapping class and if did how save new session session.save(new activity { name = "activity a1dd", status = new staus { id = 1 } // can't cause expecting object } the alternative can see represent fk integer , create enum class represents table , don't worry relationship using fluent? thanks gb either use existing status session.save(new activity { name = "activity a1dd", status = s

objective c - iPhone:facebook "misconfiguration" error -

Image
in application use sharekit facebook integration. shows me error msg shown in below image. i want clear have used latest library of sharekit , have referred following link referred link and shown in fig. when tap "log in facebook" button able send msg facebook. but why message generate don't know. any kind of appriciated..

javascript - Touchstart vs Click. What happens under the hood? -

first, excuse me please, not programming question, think wont fit theoretical cs , , cs non programming still in private beta. after updating phonegap applications listen $(selector).bind("touchstart",function()); instead of $(selector).click(function()); (here jquery),and performance improved remarkably, want know touchstart different, despite of fact designed mobile devices environments. looked w3c document on touchstart, doesnt provide information. if has link further explanation or can explain how works, appreciate it on iphone touchstart event fires finger touches screen, whereas click event fires 300 ms after touch screen , lift finger off screen. 300 ms time delay safari can wait see if intend double tap screen in succession simulate zoom gesture.

checkout - magento changing customer group of guest user -

i have custom field in onepage checkout, used in model\observer.php set customer group using following: $customer = mage::getsingleton("customer/session")->getcustomer(); $customer->setgroupid($newgroupid)->save(); this works great, , i'm doing change tax in cart. however, people checking out guest throws error: customer email required is there way of setting customer group guest, second not logged in group example? check user session set customer email address. $session = mage::getsingleton('customer/session'); $customer = $session->getcustomer(); if($session->isloggedin()) { $customer->setgroupid($newgroupid)->save(); } else { $customer->setemail($customer->getdata('email')); $customer->setgroupid('2'); // assuming 'guest' groupd id 2 $customer->save(); }

gnupg - gpg --export-secret-keys -

whenever decrypt file gpg, asked passphrase. e. g. gpg -d file.gpg however can export private key without getting asked passphrase: gpg --export-secret-keys --armor --output secretkeysfile.asc is exported private key in generated file secretkeysfile.asc still encrypted passphrase? or has access file able decrypt encrypted files? anyone imports secret keys need enter appropriate passphrases use them, now. test creating new user , importing secretkeysfile.asc file, etc.

How can I call JavaScript code from an XForms action? -

i'm trying call javascript on button click in xform. seems easy task but... i've programmed described here , have added xml : <xforms:trigger> <xforms:label>increment foo javascript</xforms:label> <xxforms:script ev:event="domactivate"> alert("test!") </xxforms:script> </xforms:trigger> but error wher page has loaded : fatal error: prefix "ev" attribute "ev:event" associated element type "xxforms:script" not bound did miss thing? this means namespace prefix ev not visible <xxforms:script> element. as @grtjn mentions in comment, have add proper xml namespace declaration. example @ top of document: <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ev = "http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xxforms="http://orbeon.org/oxf/xml/xf

r - Binning dates into decades, by column, in a matrix -

i have simulated matrix of dates generated probability function. each column represents single iteration. i bin each run separately decades , dump them new matrix each column length of decades single run number dates binned decade. i have done single vector of dates, not matrix: "dates" vector of observed data representing when trees established in population #find min , max decade mindecade <- min(dates) maxdecade <- max(dates) #create vector of decades alldecades <- seq(mindecade, 2001, by=10) #make empty vector of same length decade vector bin.vec <- rep(0,length(alldecades)) #populate bin.vec (empty vector) number of trees in each decade (i in 1:length(alldecades)) { bin.vec[i] <- length(which(dates==alldecades[i])) } bin.vec: 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 2 0 1 3 0 1 3 8 5 9 8 5 5 4 10 3 6 9 17 32 37 35 25 31 41 41 44 45 40 50 43 59 42 46 28 16 18 20 16 11 4 7 1 th

How do you access a custom view's android:layout_width and android:layout_height parameters? -

how access custom view's android:layout_width , android:layout_height values? sample xml: <com.example.custombutton android:id="@+id/btn" android:layout_width="150dp" android:layout_height="70dp" /> in custombutton: @override protected void onmeasure(int widthspec, int heightspec) { int measuredwidth = measurespec.getsize(widthspec); int measuredheight = measurespec.getsize(heightspec); // how can measure based on android:layout_width, android:layout_height? // implementation measures off parent's values setmeasureddimension(measuredwidth, measuredheight); } you must layout params of view: custombutton.layoutparams viewparams = yourview.getlayoutparams(); and can access or modify width or view: viewparams.height; viewparams.width; hope helps!

java - Client-Server UDP connection -

i trying send data server client 1 bit @ time. client should respond ack whenever received bit server. what happening when client sends initial requests server, data getting passed server. when server sending required data client, data getting looped , client left in indefinite waiting hang. i've attached code below client , server. please have @ , advise on going wrong. client side: import java.io.ioexception; import java.net.*; import java.util.scanner; class udpclient extends thread implements runnable { datagramsocket clientsocket; inetaddress ipaddress; public static void main(string args[]) throws exception { try { udpclient t1 = new udpclient(); thread t = new thread(t1); t.start(); } catch (exception e) { system.out.println("error

c# - Create Unique Image (GUID to Image) -

Image
i'd profile pictures of new users. seems create unique image based on value. how can repeatedly create same unique image guid? i'm open doing on server, prefer client side solution create on fly. something these: edit: how can repeatedly create same unique "nice looking" image guid? what looking called identicon . i think post might either give want want or give sample code @ in order generate own images. http://www.puls200.de/?p=316

java - AppEngine frontend to DB latency temporarily ~10 secs every ~20 calls? -

Image
this (see chart below) happening since 3/7. sure can because of instances loading , unloading. know other reasons gae behaving this? it's not high replication instance. , during testing had 5 instances f2 running our test client calls. there db calls, image processing , memcache usage. there 2 issues equal: http://code.google.com/p/googleappengine/issues/detail?id=4180&sort=priority&colspec=id%20type%20component%20status%20stars%20summary%20language%20priority%20owner%20log http://code.google.com/p/googleappengine/issues/detail?id=6309&sort=priority&colspec=id%20type%20component%20status%20stars%20summary%20language%20priority%20owner%20log and there's entry in forum: https://groups.google.com/forum/#!topic/google-appengine/js5cerwlqz0/discussion logging (shay requested) shows persistence manager seems take 6 seconds initialize: 2012-03-11 15:32:47.543 /api/yyy 200 16811ms 0kb xxx/1.1 cfnetwork/548.1.4 darwin/11.0.0 78.53.230.114 - - [11/mar/2