Posts

Showing posts from July, 2013

javascript - How to use live method with zclip plugin? -

how use live method -> http://www.steamdev.com/zclip/ edit: $(document).ready(function(){ $('a#copy-description').zclip({ path:'js/zeroclipboard.swf', copy:$('p#description').text() }); i need use live method cuz a#copy-description generate via javascript. try use livequery instead of live. way you'll able bind zclip when appears in dom. $(document).ready(function(){ $('a#copy-description').livequery(function(){ $(this).zclip({ path:'js/zeroclipboard.swf', copy:$('p#description').text(); }); });

Lucene .NET not returning search results -

for reason lucene not returning results when should be. here 'search' code dim util new indexerutil() dim dir lucene.net.store.directory = fsdirectory.open(new directoryinfo(util.getindexdir())) dim indexsearcher new indexsearcher(dir, false) dim indexwriter new indexwriter(dir, new simpleanalyzer(), false, indexwriter.maxfieldlength.unlimited) dim term new term("id", "346") dim query new termquery(term) dim topdocs topdocs = indexsearcher.search(query, 100) there no scoredocs (results) in topdocs. know fact there document in index id field equal 346 reason search not finding it. here how "id" field being created doc.add(new field("id", id, field.store.yes, field.index.analyzed)) //id integer i have other fields search on , work fine (e.g. if search on subject field results should) simpleanalyzer uses lettertokenizer , returns letters. consider using keywordanalyzer instead id field.

math - PHP Formula For a Series of Numbers (Mathy Problem) -

my apologies if wrong site problem, more math-related programming. i trying write series of 7 page links, in google-esque fashion. essentially, 7 numbers, s ( s + 6), s starting value. having trouble calculating starting value, given limited amount of information. in advance, know maximum value in series, variable, greater 7. in formula-writing attempts, have been calling value g , g > 7. i know page number user has selected. have been calling value p so, example, if g 8, need generate these series of numbers, bolded number equal p : 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 2 3 4 5 6 7 8 2 3 4 5 6 7 8 2 3 4 5 6 7 8 2 3 4 5 6 7 8 as long can determine starting value using information available, else falls place. can advise on how calculate starting value using information available? if relevant, writing formula in php. thanks in advance input. this simulation code testing. <? $g=16; for($p=1;$p<17;$p++){ $sta...

sql server - SQL Scheduled job query, duration of last runs? -

previously used sql agent jobs, how document information sql scheduled jobs. how can find out duration of last run each job? need seconds, minutes, , hours (hopefully not, i'm afraid). can give insight how query this? assuming you're not going have jobs run longer 999 hours, should give starting point: select j.name, h.run_status, durationhhmmss = stuff(stuff(replace(str(h.run_duration,7,0), ' ','0'),4,0,':'),7,0,':'), [start_date] = convert(datetime, rtrim(run_date) + ' ' + stuff(stuff(replace(str(rtrim(h.run_time),6,0), ' ','0'),3,0,':'),6,0,':')) msdb.dbo.sysjobs j inner join ( select job_id, instance_id = max(instance_id) msdb.dbo.sysjobhistory group job_id ) l on j.job_id = l.job_id inner join msdb.dbo.sysjobhistory h on h.job_id = l.job_id , h.instance_id = l.instance_id order ...

iphone - iOS: Can I override pinch in/out behavior of UIScrollView? -

i'm drawing graph on uiview , contained uiscrollview user can scroll horizontally around entire graph. now want zoom graph when user pinches in 2 fingers, instead of zooming in view same rate x , y direction, want zoom in x direction changing x scale, without changing y scale. i think have catch pinch in/out gesture , redraw graph, overriding default zooming behavior. but there way this? i've been having difficult time catch pinch gesture on uiscrollview , cancels touches when starts scroll. want zooming work after uiscrollview cancels touches. :( thanks, kura although cannot delete existing pinch gesture recognizer, can disable , add own: // disable existing recognizer (uigesturerecognizer* recognizer in [_scrollview gesturerecognizers]) { if ([recognizer iskindofclass:[uipinchgesturerecognizer class]]) { [recognizer setenabled:no]; } } // add our own uipinchgesturerecognizer* pinchrecognizer = [[uipinchgesturerecognizer alloc] i...

WPF Binding to Proxy -

i have number of collection classes implement own custom update notification. should pretty easy translate these notifications inotifycollectionchanged implementation in proxy class. inotifypropertychanged taken care of; question collection proxies. so, i'm looking way of creating proxies relatively easy use xaml. particularly true sub-collections. custom collection classes part of library cannot modified (nor derived from). it's not possible replace collection types inotifycollectionchanged -compatible equivalents, because data-updating code outside control. i'd prefer solution works sl well, it's not strict requirement. so far, believe following approaches viable: define typedescriptionprovider registered collection classes adds proxy property. allows binding paths dot-into proxy. seems solution easiest xaml perspective, not sl-compatible. define value converter creates proxies. work bit more work xaml side. should work sl. however, may require ...

python - UnicodeDecodeError: 'ascii' codec can't decode -

i'm reading file contains romanian words in python file.readline(). i've got problem many characters because of encoding. example : >>> = "aberație" #type 'str' >>> -> 'abera\xc8\x9bie' >>> print sys.stdin.encoding utf-8 i've tried encode() utf-8, cp500 etc, doesn't work. i can't find right character encoding have use ? thanks in advance. edit: aim store word file in dictionnary, , when printing it, obtain aberație , not 'abera\xc8\x9bie' what trying do? this set of bytes: bytes = 'abera\xc8\x9bie' it's set of bytes represents utf-8 encoding of string "aberație". decode bytes unicode string: >>> bytes 'abera\xc8\x9bie' >>> print bytes aberație >>> abberation = bytes.decode('utf-8') >>> abberation u'abera\u021bie' >>> print abberation aberație if want store unicode string ...

Is it possible to show multiple displays in Android 3.x Emulator? -

is possible display multiple displays in android 3.x emulator? i run multiple activities 1 on main display , other on 2nd display. wondering if can test in android emulator. videoguy android not support multiple displays. device manufacturers have created dual-display devices have done on own. hence, there no way use multiple displays emulator @ time.

ios - Memory consumption spikes when resizing, rotating and cropping images on iPhone -

i have "imagemanipulator" class performs cropping, resizing , rotating of camera images on iphone. at moment, works expected keep getting few huge spikes in memory consumption cause app crash. i have managed isolate problem part of code check current image orientation property , rotate accordingly uiimageorientationup . image bitmap context , save disk. this doing: cgaffinetransform transform = cgaffinetransformidentity; // check orientation , set transform accordingly... transform = cgaffinetransformtranslate(transform, self.size.width, 0); transform = cgaffinetransformscale(transform, -1, 1); // create bitmap context image passed can perform rotation cgcontextref ctx = cgbitmapcontextcreate(null, self.size.width, self.size.height, cgimagegetbitspercomponent(self.cgimage), 0, cgimagegetcolorspace(self.cgimage), cgimagegetbitmapinfo(self.cgim...

php - Is (int)$var same as intval($var)? -

possible duplicates: fastest way convert string integer in php php: there particular difference between intval , (int)? is (int)$var same intval($var) ? apparently both same thing. is there situation in return different results? (int) seem bit faster intval , don't have overhead of function call. intval allows set optional base convert to, might useful: int intval ( mixed $var [, int $base = 10 ] )

php - Payments Library for CodeIgniter -

i started github project few months ago when needed api integration paypal payments. original idea 1 should able use 1 interface process transactions through multiple payment systems. i've been looking payments ecosystem , trying figure out make library code payments interface. 2 things ran across chargify , spreedly . let use api accept payments , process through payment gateways on world - mantra being build app, we'll handle billing. are there other similar sites / services should integrate know of? if php framework user, have add need or want see in payments library? potential "gotchas" or "hey, think this" can add? i appreciate it! very helpful - libraries come close looking for: active merchant ruby on rails payment process 2 php

c# - get the new selectedValue of the listBox using the OnSelectedIndexChanged event -

i have listbox in asp.net web form. onload add items listbox , add onselectedindexchanged event handler: public void onselectedindexchanged(object sender, eventargs eventargs) { streamwriter sw = new streamwriter(@"c:\users\me\desktop\log.txt"); sw.writeline(listbox.selectedvalue); sw.flush(); sw.close(); } the stream writer can see output... i have autopostback set true on listbox everytime select new item reloads page print out first item in list instead of item clicked on. have idea of im doing wrong? thanks onload runs every time page loaded. check page.ispostback make sure adding items list first time load page. i.e. if (!page.ispostback) { fillmylistbox(); }

using JSON in Rails, Backbone and Mustache - formats seem to differ -

i trying put rails app, backbone.js , mustache templating. finding json required backbone isn't compatible json required mustache. (i started out following tutorial cloudedit -a backbone.js tutorial example , want use mustache using jst. for backbone must set activerecord::base.include_root_in_json = false. model (person firstname , surname) data sent rails /people looks this: [{"firstname":"jane","surname":"jones"},{"firstname":"janet","surname":"jensen"}] my mustache template looks this: <h3><a href='#new'>create new</a></h3> <h4>people</h4> <ul> {{#people}} <li>{{firstname}} {{surname}}</li> {{/people}} </ul> and mustache docs expect wants see is {"people":[{"firstname":"jane","surname":"jones"},{"firstname":"janet","surname":"jensen...

orm - Extending the MembershipUser class -

i extending membershipuser , membershipprovider classes. using orm. i wondering - membershipuser class has no password property, yet there methods return password , change password , on. had first thought that, using orm approach, do: user.password = newpassword; session.commit(); but seems membershipuser not supposed have password property or field , instead must set via sql (so have create query)? to make question clearer: if membershipuser class has password field, in updatepassword method of membershipprovider: user user = database.getuser(username, oldpassword); user.password = newpassword; session.commit(); but if can't have password field, have use sql: update password set.. etc etc... can't , change objects database objects don't have fields need change (such password field). if creating own derivative of membershipuser class, should thinking creating own membershipprovider. your exact question unclear, if implement own membership pro...

ruby on rails - How to accomplish an update_attributes without actually saving the changes -

possible duplicate: rails update_attributes without save? fundamentally, want activerecord "update_attributes" while leaving activerecord changes pending. there way accomplish this? read on if wondering why want this. i have form consisting of 3 parts: static portion (text fields independent of each other), set of selections (grows entries filled in), , section showing effects of selections upon group of dependent objects. changing selections requires round trip server determine effects , of selections affect choices future selections. selections modeled has_many association basic model. e.g. (note [] entries designate html-selects) include [section] exclude [subsection] exclude [subsection] include [section] exclude [subsection] ... i have set form typical nested-attributes form. when selection changed, post fields ajax such i'm getting typical params hash (e.g. params[:basemodel][associated_models_attributes][0][:field_name]). i'd...

php - How to show hide a textbox with label in zend framework? -

i have element in zend form $item1 = $this->createelement('text','item1'); $item1->setlabel('enter item 1:') ->setrequired(true) ->setattrib('class','hide_textbox'); here hide_textbox class in css file makes display none . it's hiding text box not label, want hide textbox label,(i don't want use removedecorator('label') ) later want show label , textbox using javascript add class 1 of wrapper decorators. the specifics of entirely depend on decorator scheme. not done using standard decorators label , element inside different wrappers ( <dt> , <dd> respectively). here's quick example assumes rest of form decorated not use definition lists... $item1->setdecorators(array( 'viewhelper', 'errors', 'label', array('htmltag', array('tag' => 'div', 'class' => 'h...

iphone - How to get the font-size or a bold-version of UIFont instance -

how font-size of uifont instance? or, if can implement method uifont? - (uifont *)boldfont; uifontdescriptor pretty powerful class , can used bold version of font want. should totally safe , future proof requires usage of public api , doesn't depend on string modifications. here code in swift 3: extension uifont { func bold() -> uifont? { let fontdescriptorsymbolictraits: uifontdescriptorsymbolictraits = [fontdescriptor.symbolictraits, .traitbold] let bondfontdescriptor = fontdescriptor.withsymbolictraits(fontdescriptorsymbolictraits) return bondfontdescriptor.flatmap { uifont(descriptor: $0, size: pointsize) } } } here code in objective-c: @implementation uifont (raboldfont) - (uifont *)ra_boldfont { uifontdescriptor *fontdescriptor = [self fontdescriptor]; uifontdescriptorsymbolictraits traits = fontdescriptor.symbolictraits; traits = traits | uifontdescriptortraitbold; uifontdescriptor *boldfontd...

documentation - Start playing with Lift framework on Linux/Fedora -

is there up-to-date documentation can follow start creating, build, deploy, debug , test lift based project? couldn't find such info on official lift site, neither on books offered (simply lift , exploring lift). seems road blocker starters on linux based systems. compare with, play! framework doing job on documentations. yes. can use lifty plugin sbt , running quickly. excerpt: lifty adds scaffolding sbt (simple build tool) , includes templates lift including new projects, adding snippets, models, comet actors, , other templates lift-base projects. i recommend using giter8 sbt, , comes lift template: $ g8 --list | grep -i lift tjweir/liftproject giter8 template lift 2.2 application

javascript - setting the store of a combobox in EditableGrid in ExtJs based on another combo -

Image
i using ext designer . (ext version 3.x) have combo in form autoref 'worker_type' then there editable grid, add employees the grid has employee selection combo illustrated in image i want change store of combo based on 'worker_type' selection. goal here list employees of worker type only. but unable access editable grid combo box in code anyway. any assistance highly appreciated. thanks put select listener first combo, , on selecting value, load data store of second combo. way: var firstcombo = new ext.form.combobox({ mode : 'local', store : firststore, ...... listeners : { scope : this, select : function(combo){ // here load "secondstore" selected combo value // combo value combo.getvalue() } } }); var secondcombo = new ext.form.combobox({ mode : 'local', store : secondstore, ...... });

ruby on rails 3 - Rails3: What REST URLs for the different pages of a multi-pages wizard? -

i new rails , all-rest concept. i writing exam website rails3. during examination, user has answer questions spread on 4 pages (kind of wizard). how translate in rest? have examination model /examinations/new url, need 4 urls each of 4 pages, how achieve in rails3? odds http://railscasts.com/episodes/217-multistep-forms answer question.

xslt - how to sort elements and group them based on unique element or ID, which has namespace -

i have asked same question not namespace i have xml like..this <?xml version = '1.0' encoding = 'utf-8'?> <finaldbgetuserid> <finaldbgetuseridoutputcollection xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/db/finaldbgetuserid" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/finaldbgetuserid"> <ns0:userubscribers> <ns0:user_id>237</ns0:user_id> <ns0:businessentity> <ns0:nevada_business_id>nv0511201114</ns0:nevada_business_id> <ns0:business_entity_id>207</ns0:business_entity_id> </ns0:businessentity> </ns0:userubscribers> <ns0:userubscribers> <ns0:user_id>237</ns0:user_id> <ns0:businessentity> <ns0:nevada_business_id>nv0511201119</ns0:nevada_business_id> <ns0:business_entity_id>212</ns0:business_entity_id>...

plsql - Column names in an empty Oracle REF CURSOR -

in pl/sql, can use trick 1 here find out name/value pairs every column in row ref cursor : to_char of oracle pl/sql table type that's awesome trick. doesn't work when ref cursor empty, such 1 here (that's example. real cursor doesn't select dual ): open cursor select 1 dual 1 = 0; does empty ref cursor have column name/type information? yes, i've tried solution without rows, , you're right. limited point of view, think here need two different methods retrieve columns' names , values. 1) dbms_sql package retrieve columns' names. 2) tbone method retrieve data. procedure create or replace procedure demo(sqltext in varchar2) refcur sys_refcursor; curid integer; cnt number; ret dbms_sql.desc_tab; rectab dbms_sql.desc_tab; format_string constant pls_integer := 20; procedure printdesctab(desctab in sys.dbms_sql.desc_tab) begin -- want columns in 1 .. desctab.count ...

Deployment of a .NET application making use of SQL Server 2008 -

i have searched internet thoroughly type of issue, there responses hasn't found concrete solution yet. i have application makes use of sql server 2008 r2 , makes connections database file have set up. application executes successfully, makes connections database , retrieves/inserts/updates data , fro database. however when come create deployment project i.e. setup project, fail transfer database files other computers , make database connections. have checked sql server 2008 prerequisite in publish settings of application , has included database files. can suggest best way type of setup? thanks if using built in visual studio stuff, generates default connectionstring: data source=|datadirectory|\database.sdf i possibly try change connectionstring absolute file path make sure able find database, possible |datadirectory| not being translated findable path. you stated fails transfer database files other computers , make connections.. i'm not sure if mean ...

xcode - IOS: copy a file in documents folder -

in project have 2 file .txt (in resources folder), how can copy them inside documents folder? copies txtfile resource document if not present. nsfilemanager *filemanager = [nsfilemanager defaultmanager]; nserror *error; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *txtpath = [documentsdirectory stringbyappendingpathcomponent:@"txtfile.txt"]; if ([filemanager fileexistsatpath:txtpath] == no) { nsstring *resourcepath = [[nsbundle mainbundle] pathforresource:@"txtfile" oftype:@"txt"]; [filemanager copyitematpath:resourcepath topath:txtpath error:&error]; } if want overwrite every time try this: if ([filemanager fileexistsatpath:txtpath] == yes) { [filemanager removeitematpath:txtpath error:&error]; } nsstring *resourcepath = [[nsbundle mainbundle] pathforresource:@"txtfile" oftype:@"txt...

php - Fetching remote XML file returns strange string -

i've got weird problem. when go url in browser, nicely formatted xml structure in return. <root> <contents/> </root> (fake data though) but when use curl, file_get_contents (or wget in linux) sort of serialized data wich unusable me.`` {"root:{"contents etc. anyone knows why , how fix it? it's json. use json_decode function parse it.

Making colors of table join together (HTML) -

i'm trying these different colors in table join each other, (so there isn't small gap between them). <!---content--> <center> <table width = "75%"> <tr> <td width = "33%" bgcolor = "d word"> <center> <p>hi there here n0w</p> <img src = "images\cstrike.gif" width = "200" height = "200"> </center> </td> <td width = "33%" bgcolor = "blue"> <center> <p> blah blah blah bl0h</p> <img src = "images\mauser3.gif" width = "200" height = "200"> </center> </td> <td width = "33%" bgcolor = "grey"> <center> <p>ko</p> </ce...

configuration - User rights needed for IIS 7.5 application pool user (domain user, not the AppPoolIdentity) -

we have active directory domain (let's call foodomain ) , domain user account ( foodomain\fooapppooluser ) used iis application pool identity. we want run app pool under user account , not under network service or new apppoolidentity have access sql server , have multiple applications on iis (with own app pools) accessing different databases. the problem can't find clear how-to explaining, user rights have set user account , how iis has setup work. first got errors (unfortunately can't remember ones), added fooapppooluser local admin group ( administrators , know, test), worked. removed user again, restarted iis , still works. so i'm confused bit , know, how configuration/setup has to have working. somwhere read, account needs have " impersonate client after authentication " user right. that's reason added account admin group (the user rights assignment blocked via group policy, can sure changed if needed. i hope clear enough questio...

java - How can I figure out which of the 200 linked JARs, my Eclispe project actually needs? -

i working in old java eclipse project has lot of jars linked it's build path. i have noticed several of them aren't being used project more, meaning old libraries has been forgotten when code has evolved on years. a standard way determine if library used, remove , see if there compilation errors. however, have noticed libraries in build path invoked reflection, meaning if remove library won't compilation errors. project crash due not finding code anymore. problem don't know when can happen. is there tool can use figure out of linked jar libraries can safely remove, without getting compilation or reflection errors? check classpathhelper .

xaml - WPF Background Two Tone -

i'm trying simple cannot anywhere it. i've been trawling net trying find clear example or tit bit of information every article find showing exact same simple example. all want have background list box item 2 tone without gradial blend between them. far have: <setter property="background" > <setter.value> <lineargradientbrush startpoint="0,0" endpoint="0,1"> <gradientstop color="#acc6e0" offset="0"/> <gradientstop color="#dce7f5" offset="1"/> </lineargradientbrush> </setter.value> </setter> i've tried plenty of different things end variant of gradual gradient not 2 tone equal split. many thanks paul just add 2 stops @ same offset: <lineargradientbrush startpoint="0,0" endpoint="0,1"> <gradientstop color="#acc6e0" offset="0"/...

c# - Creating a form for a Tablet PC -

i in middle of creating form work tablet pcs. right need see best practices 1 can have when creating them. when creating forms referring forms user fills in data presses next similar survey application. have helpful links or suggestions me understand best practices tablet pcs? although isn't directly c# related, found fine example of how forms tablets in manner describe, user can hit next or button navigate thru form in user-friendly environment: http://jqtouch.com/ i started converting site designed tablet users earlier today , managed finish 20+ field form point i'm ready plug in existing .net form fields first thing on monday. if can, i'll post example after it's ready go

Codeigniter multilanguage - select from ajax - session problem -

i want make site multi languages , selecting language ajax , different words selected database , want use session[lang],and don’t want use get[lang]. i’m trying 5 days make try many variants , i’m confused now now i’m here: i have model -> langs -> function set_langs($arg) { $this->session->unset_userdata(‘lang’); $this->session->set_userdata(‘lang’, $arg); return $arg; } function get_langs() { return $this->session->userdata(‘lang’); } in home controller -> public function index(){ if($this->session->userdata(‘lang’)==’‘){ $this->langs->set_langs(‘en’); $glang[‘lang’] = $this->langs->get_langs(); }else{ $glang[‘lang’] = $this->langs->get_langs(); } $this->load->view(‘header’, $glang); } public function set() { if($_post && $_post[‘lang’] != null) { $this->langs->set_langs($_post[‘lang’]); $return[‘error’] = false; $return[‘msg’] = $this->session->userdata(‘la...

iphone - iOS Core Animation: CALayer bringSublayerToFront? -

how bring calayer sublayer front of sublayers, analogous -[uiview bringsubviewtofront] ? this variation of @mattdipasquale's implementation reflects uiview's logic more precisely: - (void) bringsublayertofront:(calayer *)layer { [layer removefromsuperlayer]; [self insertsublayer:layer atindex:[self.sublayers count]]; } - (void) sendsublayertoback:(calayer *)layer { [layer removefromsuperlayer]; [self insertsublayer:layer atindex:0]; } note : if don't use arc, may wish add [layer retain] @ top , [layer release] @ bottom of both functions make sure layer not accidentally destructed in case has retain count = 1.

magento - Call a custom phtml file in ajax layer popup -

i have custom .phtml file want call in ajax layer (lightbox) onclick, how can that? thanks. you need make controller in app/code/local/mynamespace/mymodulename/controllers then call controller action in ajax call, in case; $block = $this->getlayout()->createblock('catalog/product_view') ->setdata('product',$product) ->settemplate('catalog/product/quickview.phtml'); echo $block->renderview();

getting a limited number of files from imageMagick -

i'm trying make compilation of 3 thumbs cover top of image. i'm using following command line command that: convert cap/test.jpg -resize 300x -crop 100x135 -strip cap/t.jpg this resizes image , cuts in 100x135 tiles. more top 3 only. don't need those. can keep first 3 , delete rest, feels inefficient programming. there way limit number of files written imagemagick 3? eventually fixed making 1 image fixed width , height cut in 3 separate images. seems double work though, since images processed twice. can't quality either. here's workaround: convert cap/test.jpg resize 300x -gravity north -crop 300x135+0+0 -crop 100x135 -strip cap/t.jpg but said, processes image more absolutely necessary think. if knows better solution i'm interested!

java - make custom JTextField (JCurrencyField) -

i making jcurrencyfield use in program, finished creating i've faced issue. jcurrencyfield normal jtextfield cannot accept character not number or decimal point . , made specifications jcurrencyfield: the user cannot insert more 1 decimal point . . the user cannot insert more 2 digits after decimal point. the issue i've faced not being able insert digits before decimal point if there 2 digits after decimal point. here code: import javax.swing.*; import javax.swing.text.*; public class jcurrencyfield extends jtextfield { public jcurrencyfield() { ((abstractdocument)getdocument()).setdocumentfilter(new numberonlyfilter()); } private class numberonlyfilter extends documentfilter { public void insertstring(documentfilter.filterbypass fb, int offset, string text, attributeset attr) throws badlocationexception { if(!containsonlynumbers(text)) return; fb.insertstring(offset, text, attr); ...

PHP Optimization performance -

i have following code, but. it's slow <?php class ngram { const sample_directory = "samples/"; const generated_directory = "languages/"; const source_extension = ".txt"; const generated_extension = ".lng"; const n_gram_min_length = "1"; const n_gram_max_length = "6"; public function __construct() { mb_internal_encoding( 'utf-8' ); $this->generatengram(); } private function getfilepath() { $files = array(); $excludes = array('.', '..'); $path = rtrim(self::sample_directory, directory_separator . '/'); $files = scandir($path); $files = array_diff($files, $excludes); foreach ($files $file) { if (is_dir($path . directory_separator . $file)) fetchdir($path . directory_separator . $file, $callback); else if (!preg_match('/^.*\\' . self::source_extension . '$/', $file)) continue; e...

C# Form's background image as pictureBox parent? -

i have picturebox transparency. found out can use picturebox.parent set parent image, works when parent picturebox. if want form's background image picturebox's parent? picturebox1.parent = picturebox2; //works fine (of course if there pbox2) picturebox1.parent = form1; //??? magic goes here if understood well, want background transparent. if so, use: picturebox1.backcolor = color.transparent;

javascript - Facebook invite users to an app's page -

i've got facebook app i've added facebook page. want allow user invite friends go page app on , interact app there. i've can invite friends app this: fb.ui({ method: 'apprequests', message: '...' }); but invite them page app on rather app itself. i allow users send message friends instead using link like: https://www.facebook.com/dialog/send?app_id=... allow me include link facebook page, wondered if there better way of doing so? in particular apprequests ui displays checkboxes friends. there way can use ui, promote page rather app? there no official posibility invite friends directly page, since app unique can inserted in more 1 page. what have check in context app been called. don't know if using php backend, server side code neccessary. you have signed_request facebook sending you, , if there page in it. save context in session . if familiar php, may you: $signed_request = $fb->getsignedrequest();...

android - Using LayoutInflater to create dynamic view -

i have created xml file wish repeat number of times , populate within main view. have read layoutinflater way go having issues getting work first question. xml item created has number of textview within it. can done or can xml contain 1 textview? scrollview mainlayout = (scrollview) findviewbyid(r.id.scrollview1); layoutinflater inflater = (layoutinflater)getsystemservice(context.layout_inflater_service); view view = (view) inflater.inflate(r.layout.sightmarks_item, null); textview textview1 = (textview) inflater.inflate(r.id.textview1, null); edittext editview1 = (edittext) inflater.inflate(r.id.editview1, null); edittext editview2= (edittext) inflater.inflate(r.id.editview2, null); i running round loop on array , setting text each values above , adding view mainlayout view currently erroring on inflated view. doing correctly? thanks there problem in code. element of view use findviewbyid method scrollview ...

Display total weight of cart in the magento header -

i have simple products want show total weight of cart in header section after "my cart" link. could me resolve issue? this should work: $items = mage::getsingleton('checkout/session')->getquote()->getallitems(); $weight = 0; foreach($items $item) { $weight += ($item->getweight() * $item->getqty()) ; } echo $weight; a better way: $weight = mage::getsingleton('checkout/session') ->getquote() ->getshippingaddress() ->getweight();

memory - How to Assign a Variable Name in a #define (Boost related Mem Leak)? -

i've ran memory validator on application we're developing, , i've found macro expressions we've defined @ root of 90% of leaks. #define o_set. now, our macros defined follows: #define o_set_value(valuetype, value) boost::shared_ptr<valuetype>(new valuetype(value)) . . #define o_set o_set_value however, according boost web site (at: http://www.boost.org/doc/libs/1_46_1/libs/smart_ptr/shared_ptr.htm ): a simple guideline eliminates possibility of memory leaks is: use named smart pointer variable hold result of new. every occurence of new keyword in code should have form: shared_ptr p(new y); is, of course, acceptable use smart pointer in place of shared_ptr above; having t , y same type, or passing arguments y's constructor ok. if observe guideline, naturally follows have no explicit deletes; try/catch constructs rare. this leads me believe indeed major cause of our memory leaks. or being naive or out of depth ...

Getting XML with Grails REST plugin -

i'm having trouble working rest plugin in grails. trying convert xml request map in controller. the data source trying data returns xml looks (this shortened simplicity): <process id="345"> <correctedby>joanne w.</correctedby> <editby>joanne w.</editby> <editdate>2009-12-23 00:00:00.0 est</editdate> <produceby>stephen</produceby> <producedate>2010-01-14 00:00:00.0 est</producedate> </process> in controller have code make request service def getrest = { def wfrequest withhttp(uri: "http://myurl:8080") { wfrequest = get(path : '/application/controller/' + params.id, requestcontenttype: xml) { resp, xml -> render xml } } } ok far, return data xml, tags gone: joanne w.joanne w.2009-12-23 00:00:00.0 eststephen2010-01-14 00:00:00.0 est can point me i...

coding style - New line at the end of source code -

anytime open code editor in visual studio, there empty new line @ end of generated codes. delete them since seem irrelevant me. however, read code @ github said: \ no newline @ end of file this last line. i'm thinking empty new lines @ end of source codes have relevance. mean? provide performance boost? no, makes no difference whatsoever. some coding conventions it's have final newline, it's not to.

Pointers to arrays problem in C -

i have function takes pointer of array (in order modify within function) int func_test(char *arr[]){ return 0; } int main(){ char var[3]; func_test(&var); return 0; } when try compile : passing argument 1 of ‘func_test’ incompatible pointer type why problem, , how pass pointer array in case? char * arr[] not pointer array; array of pointers. declarations in c read first identifier towards right, identifier towards left. so: char * arr[]; // ^ arr is... // ^ array of... // ^ pointers to... // ^ char

php - Stop HTML converting an & code -

i have html table displays information database, , 1 of database fields contains parameter list such as: id=eff34-435-567rt-65u&notification=5 but when display in table &not becomes ¬ i know can manually force print right way using &amp;not but rather able use force html ignore code can pull text straight database , print table without having regex find out if there & , replace them &amp; tried using <pre> tag did not work. is there way force html print typed specific td field? nothing practical (cdata doesn't have browser support in text/html mode). write proper html instead. you should running comes out of database through conversion function make html safe anyway (to protect against xss if nothing else). php has htmlspecialchars() , tt has | html . whatever using should have other regex.

using slider to rotate image in Matlab -

Image
i have gui (using guide) in matlab, how looks: i want rotate image using slider , show change in real time. i use axes display image. how can this? edit: i'm building ocr application. how plate looks when i'm rotate it, numbers totally deformed. thanks. here example gui: function rotationgui() %# read image = imread('cameraman.tif'); %# setup gui hfig = figure('menu','none'); hax = axes('parent',hfig); uicontrol('parent',hfig, 'style','slider', 'value',0, 'min',0,... 'max',360, 'sliderstep',[1 10]./360, ... 'position',[150 5 300 20], 'callback',@slider_callback) htxt = uicontrol('style','text', 'position',[290 28 20 15], 'string','0'); %# show image imshow(i, 'parent',hax) %# callback function function slider_callback(hobj, eventdata) ...

flash - actionscript 3 wall hit-detection -

am making simple flash game , trying keep avatar hitting walls in given level, here code wrote, simple enough var hitwall:boolean = checkwallhitlvl1(); if ( downkeyisbeingpressed ) { avatar.moveabit( 0, 1 ); if(hitwall) { avatar.moveabit( 0, -5); } } else if ( upkeyisbeingpressed ) { avatar.moveabit( 0, -1 ); if(hitwall) { avatar.moveabit( 0, 5 ); } } else if ( leftkeyisbeingpressed ) { avatar.moveabit( -1, 0 ); if(hitwall) { avatar.moveabit( 5, 0 ); } } else if ( rightkeyisbeingpressed ) { avatar.moveabit( 1, 0 ); if(hitwall) { ...

javascript - Get the children table data of $(this), which is the table row -

so have function $("#names tbody tr").click(#something here); and wondering. since i'm "inside" tr of table, here how go through each individual td using object? you do: $("#names tbody tr").click(function(){ $(this).children('td').each(function(index, element){ //here td }) });

Mercurial and SVN side by side in same working directory? -

our environment uses svn. commit alot more often, don't want break of main branches. love mercurial much more svn. if hg init repository in svn working copy issues arise if commit mercurial repository on regular basis , committed working revisions svn branch? our environment not setup such each developer has own svn branch, , not viable solution currently. there not problem having mercurial , subversion share working folder. subversion keeps files in .svn folders while mercurial keeps files in .hg folder @ top level. for convenience, may consider adding .svn/ entry .hgignore file don't accidentally commit .svn folders in mercurial repository. that being said. not need use subversion @ all. mercurial can interface subversion without subversion client. see working subversion .

android - Using Custom Adapter uses more RAM? -

my application on first lunch uses 6.5mb, , when enter activity 3 tabs, tab displays listview, uses 14 mb!! this happened when went "bad code" simpleadapter custom adapter. what want 2 strings on each side in listview. strings in array, here way using people told me incorrect way do: string[] array= getresources().getstringarray(r.array.names_list); int lengthtmp= array.length; for(int i=0;i<lengthtmp;i++) { counter++; addtolist(array[i]); } adapter = new simpleadapter(this,list,r.layout.start_row,new string[] {"number","suraname"},new int[] {r.id.start_numbering,r.id.start_name}); private void addtolist(string name) { hashmap<string,string> temp = new hashmap<string,string>(); temp.put("number", integer.tostring(sortingpictures[counter-1])); temp.put("suraname", name); list.add(temp); } with code, activity takes 10mb of ram. after changing code use custom adapter, uses 14 mb: ...

wolfram mathematica - Re-layout graph after small modification while preserving features of original layout -

Image
is there simple way following in mathematica 8? construct graph, , display using graph layout. modify graph (e.g. add or remove edge or vertex). re-compute layout starting original layout, in such way the "shape" of object more or less preserved. e.g. re-run spring-electric layout algorithm starting coordinates of previous layout. if graph hasn't changed between 2 displays, layout shouldn't change either (or minimally). using display of new graph or graphplot both acceptable. edit: in essence need similar layouts similar graphs. obtain similar graphs modifying existing one, may have been laid out, generic solution acceptable. edit 2: here's example of kind of thing useful. go http://ccl.northwestern.edu/netlogo/models/giantcomponent , click "run in browser" (requires java). click setup click go. can see graph evolve. if in mathematica, each of successive graphs different, , difficult see same graph evolving. in several applic...

Visual Studio 2010 SP1 does not search for text in *.* -

i used able search text in every file in solution, that: http://vvcap.net/db/lwmpashxormurfyllo0q.htp . after upgrading vs2010 sp1, doesn't work anymore: find "description", match case, whole word, subfolders, keep modified files open, find results 1, "entire solution", "*.*" no files found in. find stopped in progress. what's interesting, can still search if know file extension, this: http://vvcap.net/db/ifr8jcua7j79saubsnfc.htp : find "description", match case, whole word, subfolders, keep modified files open, find results 1, "entire solution", "*.cs" ... ... matching lines: 485 matching files: 109 total files searched: 970 anyone knows wtf going on here, , how around this? i don't know happened, vs searching "*" again. maybe after last windows update... have no reasonable explanation wtf happened

php - Why won't this script properly sanitize output? -

i trying sanitize output of should simple email script, outputs blank page. here script: <?php define("email", "info@silentpost.net"); if(isset($_post['submit'])) { //include validation class include('./support/validate.class.php'); //assign post data variables $_post['name'] = filter_var($_post['name'], filter_sanitize_string); $_post['email'] = filter_var($_post['email'], filter_sanitize_email); $_post['message'] = filter_var($_post['message'], filter_sanitize_string); $name = trim($_post['name']); $email = trim($_post['email']); $message = trim($_post['message']); //start validating our form $v = new validate(); $v->validatestr($name, "name", 3, 75); $v->validateemail($email, "email"); $v->validatestr($message, "message", 5, 1000); if(!$v->haserrors()) { $header = "from: $em...

javascript - Can I run HTML files directly from GitHub, instead of just viewing their source? -

if have .html file in github repository, e.g. running a set of javascript tests, there way can view page directly—thus running tests? for example, somehow see test results produced the jquery test suite , without downloading or cloning repo local drive , running them there? i know put github in static content hosting business, again, have change mime-type text/plain text/html . an alternative http://htmlpreview.github.com http://rawgithub.com . provides more convenient way preview files. update the site has been renamed http://rawgit.com : before https://raw.githubusercontent.com/[user]/[repository]/[branch]/[filename.ext] in case .html extension after https://rawgit.com/[user]/[repository]/[branch]/[filename.ext] in case .html extension now seems able use cdn in production well, pretty cool: https://cdn.rawgit.com/[user]/[repository]/[branch]/[filename.ext] you can serve gists before https://gist.github.com/[user]/[gist] after http...