Posts

vim - Move to start and end of search lookup -

in vim/gvim able move front , end of current search lookup. possible? for example, file: a dog , cat hat , bat i able perform search, example /dog\sand , able move beginning of 'dog and' expression end , cursor starts on column 3, under letter 'd' of word 'dog' , moves column 9 under letter 'd' or word 'and'. the reason want able can search expression , use change command, c , combined movement command replace particular search expression. don't want use substitue , replace here, want perform operation using change command , movement key. you can change end of match c//e<cr> . , //<cr> take beginning of next match. work out kind of bindings make sense. instance tried following, , seems work nicely: :onoremap <silent>m //e<cr> so can cm change match. i'm not sure map //<cr> to, though. tried mapping n , , seemed work fine. don't know if problem you. :nnoremap <silent>n ...

postgresql - Postgres databases with different encoding -

i tried create databases different encoding in postgres (i'm using pgadmin database manager), when try create database non utf8 encoding, pgadmin shows me error saying can't create database because not match current locale "portuguese_brazil_1252" , lc_ctype configuration requires encoding "win1252". how configure in postgres? i'm running under locale test server windows xp (not choice). possible create databases different encoding or behavior postgres limitation? here had success managing that? thanks from docs : the character set encoding specified new database must compatible chosen locale settings (lc_collate , lc_ctype). if locale c (or equivalently posix), encodings allowed, other locale settings there 1 encoding work properly. [...] the encoding , locale settings must match of template database, except when template0 used template. you should able use create database either (or both): specify...

php - Recursively linking records -

i have table timeslots users can sign for. on administrative end, admin-user can choose 'link' 2 timeslots together, says end-user, 'if sign 1 of these timeslots, must sign other timeslots linked it.' these links stored in table has 2 columns, 1 being id of timeslot requiring link, , other being id of timeslot being linked to. how can make such when linking 1 timeslot another, both depend on other being selected. needs recursive other linked timeslots well, following example: admin says: #1 linked #2 #3 linked #2 therefore: #1 linked #2 #2 linked #1 #3 linked #2 #2 linked #3 #3 linked #1 #1 linked #3 what best way accomplish this? right i'm trying put information link table, if there's way can more php , less sql work also. provide code sample, don't think helpful. edit: conceptual answers fine. don't need code written me unless demonstrative purposes. one approach may table of 2 columns in form of: node_id, , link_id. in case, ...

php - Replace objects by other objects in-place -

suppose i'd build database abstraction layer, uses lazy loading mechanism. if ask layer load root object, loads external representation , constructs itself. it somehow identifies linked objects exist. since might costly load up-front, established proxies related objects. such proxies should able passed around. if first message called on such proxy, loads external representation , constructs itself. since references proxy may have been passed around, created object needs replace existing proxy-object in-place. can in-place replace object object in php? i don't believe it's possible object replace references object. instead, have proxy objects forward property access , method invocation using overloading . implement proxying on base proxy object (named e.g. ooproxy ), extend lazyproxy class lazily loads proxied object. long don't need examine type of object, has reference proxy won't able distinguish proxied.

iphone - Dynamic UIButtons with vertical spacing on a UIScrollView -

Image
i need space uibuttons out on uiscrollview. code have works, depending on amount of dataitems have, spacing not even. snippet in question cgrectmake(10, ((120 / (count + 1)) * (i + 1) * 3) ,300,50) specifically ((120 / (count + 1)) * (i + 1) * 3) working code int count = [dataitems count]; /* not specific value, can grow */ (int = 0; < count; i++) { uibutton* abutton = [uibutton buttonwithtype:uibuttontyperoundedrect]; [abutton settag:i]; [abutton setframe: cgrectmake(10,((120 / (count + 1)) * (i + 1) * 3) ,300,50) ]; [abutton settitle:[[dataitems objectatindex:i] objectforkey:@"feed"] forstate:uicontrolstatenormal]; [abutton addtarget:self action:@selector(viewcategories:) forcontrolevents:uicontroleventtouchupinside]; [scroller addsubview:abutton]; } screenshot the example on right should example on left far spacing goes. uibuttons sitting on uiscrollview , uiscrollview 's contentsize should grow if there more dataite...

mongoid - Creating short, unique object id's in MongoDB -

i'm making app similar instagram using rails/mongoid. want unique id can use in url http://instagr.am/p/djmu8/ what's easiest way that? can derive such id default bson objectid mongo creates? you may try use first 4 bytes of objectid (they represent timestamp). but, 100% safe, it's better produce unique short id, implementing counter. can use separate collection maintain current value of counter. more details on mongo's objectid structure can found here: http://www.mongodb.org/display/docs/object+ids as alternative can convert convert hex string id representation representation based on 36 symbols (26 latin letters + 10 digits). shorter. it seems, there ruby library, can such conversions http://rubyworks.github.com/radix/

DataForm doesn't work in Silverlight 5 -

reproduction: create silverlight project turn version 5 add references silverlight toolkit (using nuget or direct) add dataform page this exception dataform constructor throws: {system.io.filenotfoundexception: not load file or assembly 'system.windows.controls.data.input, version=2.0.5.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. system cannot find file specified. [io.filename_name] arguments: system.windows.controls.data.input, version=2.0.5.0, culture=neutral, publickeytoken=31bf3856ad364e35 debugging resource strings unavailable. key , arguments provide sufficient information diagnose problem. see http://go.microsoft.com/fwlink/?linkid=106663&version=5.0.60401.00&file=mscorlib.dll&key=io.filename _name @ system.windows.controls.dataform..ctor()} turn silverlight 4 now cool again weird note: work in vs/exp. blend 5 designers any ideas?? workaround??? found strange workaround: after returned sl version 4...