Posts

Showing posts from July, 2010

javascript - sending full address of google to external page -

i use code getting referral address . <script>ducument.wrtie(document.referrer);</script> and work correct google , full url : http://www.google.com/url?sa=t&rct=j&q=%d8%b7%d8%b1%d8%a7%d8%ad%db%8c%20%d9%85%d8%ac%d9%84%d9%87%20%d8%a7%db%8c%d9%86%d8%aa%d8%b1%d9%86%d8%aa%db%8c%20%d8%b1%d8%af%d8%b2&source=web&cd=4&cad=rja&ved=0ceyqfjad&url=www.mysite.com/1392/02/%d8%b3%d8%a7%d8%ae%d8%aa-%da%a9%d9%88%da%86%da%a9%d8%aa%d8%b1%db%8c%d9%86-%d8%b1%d8%a7%db%8c%d8%a7%d9%86%d9%87-%d9%87%d9%88%d8%b4%d9%85%d9%86%d8%af-%d8%af%d9%86%db%8c%d8%a7-%d8%a8%d8%a7-%d9%86%d8%a7/&ei=nt2kuzlhhsb40ghinocydq&usg=afqjcng9pknl1ubdalnudipnmdqcwhqx_a but when send external php page below code <script src="mysite.com/ntg.php?token=12948&referrer="+document.referrer></script> only send address keyword search http://www.google.com/url?sa=t & has special meaning in urls. if want include data, have encode it. use

Java impose final programmatically -

what's proper way ensure value gets set once, although time set unknown (ie: not in constructor). null check or keep track of flag , throw exception - exception should throw? it's small, localized library , prefer not create own valuealreadyassigned exception such seemingly generic case. the method throw illegalstateexception , since it's javadocs say: signals method has been invoked @ illegal inappropriate time.

casting - Type cast vs type assertion on concrete struct? -

i new golang, appologize if question naive. looked around, not find answer basic question. lets have concrete struct , methods shown below. type mydata struct{ field1 string field2 int } func(a mydata) operatoronstring() string{ return a.field1.(string) } func(a mydata) operatoronint() int{ return a.field2.(int) } my question is, can type cast , return rather performing assertion? have learned far that, assertion used on data of type interface. in case have concrete type. should still use assertion or can return int(a.field2) . know example trivial, point confused when use between 2 conversion types. or there golang idiomaticity involved here? thanks first of all, type assertion can used on interfaces: for expression x of interface type , type t , primary expression x.(t) asserts x not nil , value stored in x of type t . notation x.(t) called type assertion. but you're applying non interface typed fields ( int , stri

Sending Image via socket php -

i developing video chat app in php via sockets using linux server client connecting through telnet telnet 127.0.0.1 4444 and code send text message other clients below $msg['pid'] = posix_getpid(); $message = serialize( $msg ); $f = fopen(self::pipename, 'w+'); if( !$f ) { echo "error: can't open pipe writting\n"; return; } fwrite($f, $this->strleninbytes($message) . $message ); fclose($f) please tell me how can send images ? from wikipedia: telnet network protocol used on internet or local area networks provide bidirectional interactive text-oriented communication facility... i don't think there way send images until encode them in way (e.g. base64) , decode them on client side.

java - Finding substring within occurrence of a special character -

i have string example • how you. • fine. • thirdline. now want detect • occurrences , store in array. array contain 3 entries •how •i fine •thirdline how can done in java str = "• how you. • fine. • thirdline."; string[] list = str.split("\\•");

c# - Drop Down List resets -

my drop down list resets default when try select item, , doesn't trigger's code behind method when put line break , try debug it: here's markup, <script type="text/javascript"> function bringpopup() { $.blockui({message: $('#anotherup'), css: { width: '600px' } }); } </script> <div id="anotherup" style="display: none; cursor: default"> <asp:updatepanel id="updatepanel2" runat="server" updatemode="conditional" childrenastriggers="false"> <contenttemplate> <asp:dropdownlist id="drop1" runat="server" enableviewstate="true" autopostback="true" onselectedindexchanged="drop1_selectedindexchanged"/> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="drop1" eventname="selectedindexch

What is a good structure for module Integration through Cmake -

i trying integrate few different projects we've been making through cmake. in general, projects not uniformly laid out, have similarities. each library, library typically has test code/executable want maintain...and can have own inter-dependencies. in addition these libraries have been being maintained in separate repositories (mercurial if makes difference). interdependence of files this: library independent library b independent library c independent library e depends on a,b,c executable 1 depends on c executable 2 depends on e executable 3 depends on e so each library laid out this + librarya\ | + cmakelists.txt | + librarya | | + cmakelists.txt | | + include\ | | | header.h | | + source\ | | | lib.cpp | + test\ | | + cmakelists.txt | | main.cpp and overarching structure is + root\ | + cmakelists.txt | + librarya\ | + libraryb\ | + libraryc\ | + librarye\ | + executable1\ | + executable2\ | + executable3\ with each folder being own subdirs project. struct

javascript - Return value of hidden field with jQuery -

i'm building kind of e-commerce site jcart school project. following: i value of hidden field , return @ location on same page. while browsing stack overflow found code value of hidden: <script> var subt = $('#jcart-subtotal').val();</script> this works expected. checked using alert(subt) . i tried return(subt); instead of alert, because want value printed on page itself, not shown in alert message. how should print value instead of have shown in alert popup? put wherever want show value on page: <span id='showme'></span> javascript $('#showme').html($('#jcart-subtotal').val());

c# - Best way to sync remote SQL Server database with local SQL Server Compact database? -

i realise discussed topic suggestions see seem involve direct access sql server in our instance not ideal. our scenario remote sql server database (say) 100 tables. developing lightweight desktop application use sql server compact database , sync subset of (say) 20 tables remote server periodically. i have control on how replication occurs because speed major issue since remote server 1000's of miles away. also don't need sync records in each table - relevant each user. i quite sql merge facility requires client connected remote sql server. not possible , thinking of interfacing remote server through web service accessed through our application or other method. any suggestions welcome. update just clarify, internet connection intermittent, that's main reason why need sync 2 databases. the fact using compact db client puts pretty heavy limitations on available options in scenario. given limitations , performance requirements desire, consider imp

vbscript - Script Works on Win 7, Not on Server 2003 -

i have script rather simple, boots winscp , checks directory file starts "tsa". if file exists, exits, if not exist, transfers on new file. its , running on windows 7 machine, created - when transfer on server [windows server 2003] never finds file. my script: var filepath = "../zfinance/tsa"; // session connect var session = "someplace@somewhere.com"; // path winscp.com var winscp = "c:\\program files\\winscp\\winscp.com"; var filesys = wscript.createobject("scripting.filesystemobject"); var shell = wscript.createobject("wscript.shell"); var logfilepath = filesys.getspecialfolder(2) + "\\" + filesys.gettempname() + ".xml"; var p = filepath.lastindexof('/'); var path = filepath.substring(0, p); var filename = filepath.substring(p + 1); var exec; // run winscp check file existence exec = shell.exec("\"" + winscp + "\" /log=\"" + logfilepath + "\&

android - Overcome out of memory Error when loading images into textview -

sorry if sound newb but.. =[ im working application need load large amount of images onto textview, didnt use webview becuz doesnt lead mobile view decide parse content , use html.fromhtml show textview. problem is: if load page luckily there not images, run pretty smooth. otherwise error below... anyone know if theres way can dispose source system memory after finished reading image?...or...any other way fix problem? i used source here android imagegetter images overlapping text 05-08 21:30:31.404: error/dalvikvm-heap(25083): out of memory on 1920016-byte allocation. 05-08 21:30:31.404: error/androidruntime(25083): fatal exception: asynctask #10 java.lang.runtimeexception: error occured while executing doinbackground() @ android.os.asynctask$3.done(asynctask.java:299) @ java.util.concurrent.futuretask$sync.innersetexception(futuretask.java:273) @ java.util.concurrent.futuretask.setexception(futuretask.java:124) @ java.util.concurrent.futuretas

java - GridBagLayout is not displaying as expected -

Image
this first foray gridbaglayout, have reviewed java documentation online (as lot of q&as) , i've creating panel i'm expecting display such: +--------------------------+ | choose timer | +--------+--------+--------+ | 5min | 25min | 30min | +--------+--------+--------+ | 00:00:00 | +--------+--------+--------+ | start | pause | quit | +--------+--------+--------+ and here's gridbaglayout i'm using. public class buttonsel extends jframe implements actionlistener { jlabel buttonsellabel = new jlabel("choose timer run"); jbutton pomobutton = new jbutton("00:25:00"); jbutton shrtbutton = new jbutton("00:05:00"); jbutton longbutton = new jbutton("00:30:00"); jbutton startbutton = new jbutton("go"); jbutton pausebutton = new jbutton("pause"); jbutton quitbutton = new jbutton("quit"); jlabel textdisplay = new jla

google app engine - How to delete an entity by property in gae datastore -

key newwordkey = keyfactory.createkey(newword_key_kind, newword_key); entity newword = new entity(newword_entity_kind, newwordkey); newword.setproperty(user_col_username, username); newword.setproperty(newword_col, word); datastore.put(newword); i mean want delete "newword" entity property "username" ex, delete words upload user "alexis" idea ? thx use delete entities query function: query q = pm.newquery(newword_kind.class); q.setfilter("user_col_username == usr"); q.declareparameters("string usr"); q.deletepersistentall("alexis"); more info here hope helps.

regex - JavaScript - Regular expression to convert image source -

my question related javascript regular expressions. i'm building simple lightbox wordpress mootools javascript framework. wordpress stores pictures in variety of sizes file names like: 'image-50-50x100.jpg' 'image-50-150x100.jpg' 'image-50-1024x698.jpg' 'image-50.jpg' when user clicks thumbnail image, have convert source of image source of full size image, , preload full-size image. the question how change string this: 'http://some-path/image-50-50x100.jpg' 'http://some-path/image-50-150x100.jpg' 'http://some-path/image-50-1024x698.jpg' 'http://some-path/image-50.jpg' , into: 'http://some-path/image-50.jpg' missing piece accurate regular-expression in code below: source.replace( /regular-expression/, '' ); thanks in advance. this should it: str = str.replace(/-\d+x\d+/, ''); e.g.: var str = 'http://some-path/image-50-1024x698.jpg'; str = str.re

php - check if mysql row exists not working -

i have script needs check if mysql row exists. if does, must act on it. if doesnt, must different.. works fine if exist, when doesnt returns error ajax: unknown column '100005075040249' in 'field list' the '100005075040249' value of $friend below heres php code: $connection = mysql_connect("$host", "$username", "$password") or die(mysql_error()); $sql_result = mysql_query("select `fb_id` `lavender`.`players` fb_id = `$friend`"); if(is_resource($sql_result) && mysql_num_rows($sql_result) > 0 ){ $rec = mysql_query("select recieved `lavender`.`players` fb_id = `$friend`"); $rec = $rec['recieved']; if($rec == 0){ mysql_query("update `lavender`.`players` set `count` = `count`+1, `total` = `total`+1, `recieved` = 1 fb_id= `$friend`"); }; echo "inserted old row"; }else{ mysql_query("insert `lavender`.`players` (`fb_id`, `count`

php - Inserting cart and user data into mysql for a order system -

hi there, had question similar one, seems i'm stuck again. thought got work until tried add more 1 product cart , sending database . the user data (name, address, etc..) , cart data 1 item (product name, price, etc..) gets inserted without problem. however, if have lets say, 2 items in cart when try send data database , 2 rows there isn't problem, both rows same item , seem count same id twice, there 2 different id's in session . any clues i've gone wrong? i'm sending data through form! here's code block: $editformaction = $_server['php_self']; if (isset($_server['query_string'])) { $editformaction .= "?" . htmlentities($_server['query_string']); } if ((isset($_post["mm_insert"])) && ($_post["mm_insert"] == "form1")) { $insertsql = sprintf("insert ordermodul (orgnummer, namn, levadress, faktadress, telefon, email, datum, summa, nmr) values (%s, %s, %s, %s, %s

jQuery syntax for working with XML in C# -

i wondering whether know of libraries provide jquery interface working xml in c#. google search didn't turn useful, i'm turning you. as others have mentioned in comments, linq xml way go. start here in msdn documentation.

javascript - Get numerical value from parent with id like 'post-1' and use it in jQuery function -

i'm trying figure out following. i have following jquery code: var = ""; var bplay = 0; audiojs.events.ready(function() { = audiojs.createall(); $(".audiojs .play-pause").click(function() { var e = $(this).parents(".audiojs").index(".audiojs"); $.each(as, function(t, n) { if (t != e && as[t].playing) { as[t].pause() } }) bplay = !bplay; if (bplay == 1) { $(".bar").each(function(i) { fluctuate($(this)); }); } else { $(".bar").stop(); } }) }); in nutshell preforms list of things when clicks particular .audiojs instance on page. 1) checks if there other instance playing, if there pauses it. , if playing applies fluctuate function elements on page have class="bar" . issue! don't want apply .bar's on page, specific group associated par

Python Numpy - Complex Numbers - Is there a function for Polar to Rectangular conversion? -

is there built-in numpy function convert complex number in polar form, magnitude , angle (degrees) 1 in real , imaginary components? clearly write own seems type of thing there optimised version included in module? more specifically, have array of magnitudes , array of angles: >>> array([1, 1, 1, 1, 1]) >>> b array([120, 121, 120, 120, 121]) and is: >>> c [(-0.5+0.8660254038j),(-0.515038074+0.8571673007j),(-0.5+0.8660254038j),(-0.5+0.8660254038j),(-0.515038074+0.8571673007j)] there isn't function want, there angle , hardest part. so, example, 1 define 2 functions: def p2r(radii, angles): return radii * exp(1j*angles) def r2p(x): return abs(x), angle(x) these functions using radians input , output, , degrees, 1 need conversion radians in both functions. in numpy reference there's section on handling complex numbers, , function you're looking listed (so since they're not there, don't think exist within

Is it possible to disable/increase HTML node text-limit (10,000) in Chrome Developer Tools -

Image
i've got html page node contains bunch of text. (more 10,000 characters) <html>lorem ipsum ...</html> inside dom tree of chrome developer tools, node's text truncated after 10,000 characters, showing "…" @ end. if double click text in dev tools , click document, gets truncated well. is there switch/config disabling behaviour? or @ least possibility increase limit? chrome version: 26.0.1410.65 tested operating systems: osx 10.8.3, windows 7 sp1 x64 installed extensions: google docs (on mac), none (on windows) the node-text in screenshot consists of 10,000 lorem ipsum character followed sequences of "a"s.

html - DOM php delete all tags by tag name -

i'm having problem script i've been using time , worked me until hit problem. i have script i'd delete p html tags html source code. script work partly because removes of p tags, leaves out. i don't understand why that. $doc = new domdocument(); $a = <<<fail <html><body> <div style="clear:both"></div> <p class="articletitle">hoo</p> <p class="articletext">hmmm</p> <p class="articletext">hmmmm</p> <p align="center"></p> </body></html> fail; $doc->loadhtml($a); $list = $doc->getelementsbytagname("p"); foreach ($list $l) { $l->parentnode->removechild($l); $c++; } echo $doc->savehtml() . $c; the script returns <!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/tr/rec-html40/loose.dtd"> <html><body> <div style="clear:b

wpf - Can't properly load a ResourceDictionary at runtime -

Image
note : have resourcedictionary , wpf window (my view) , viewmodel, declared within winforms application. therefore have no app.xaml. i have following converter declared: public class debugconverter implements ivalueconverter public function convert(byval value object, byval targettype system.type, byval parameter object, byval culture system.globalization.cultureinfo) object implements system.windows.data.ivalueconverter.convert return value end function public function convertback(byval value object, byval targettype system.type, byval parameter object, byval culture system.globalization.cultureinfo) object implements system.windows.data.ivalueconverter.convertback return value end function end class and try loading resourcedictionary @ runtime (which specified build action resource , not page): m_rdgriddictionary = new resourcedictionary() m_rdgriddictionary.source = new uri("pack://application:,,,/wpf/helpers/gridresourcedict

Mixing javascript, jQuery and PHP, newline -

ok, have few things here: javascript: desc = "line 1 \n line 2" jquery: $("#msg").text(desc); php: const num = 555; what want, change text of <p> id of msg , contain piece of text number of lines, , in 1 of them number php constant. like so: line 1 line 2 555, line 2 continued line 3 my problem how mix them all? tried following: var desc = "line 1 \n line2" + <?php echo num ?> +"\n line 3"; , doesn't work. there several issues code: php constants should defined using define("constant_name", "value"); syntax; \n has no effect inside html tag (if dont apply white-space: pre; or pre-wrap ); <?php echo num; ?> should wrapped " or should inside javascript string; $("#msg").text(desc) remove tags desc , need use .html(desc) instead. what need this: php define("num", 555); javascript var desc = "line 1<br/>line2 &l

yii extensions - How to implement a dynamic js script in Yii List View? -

hello , reading question. have typical list view: <?php $this->widget('bootstrap.widgets.tblistview',array( 'dataprovider'=>$dataprovider, 'itemview'=>'_view', 'emptytext'=>'no jobs', )); ?> in _view file have div , button slidetoggles div. if put javascript @ top of page, not work because results dynamic , name of div changes id returned, eg: id="detailsdiv-<?php echo $data->id_employer_contract;?>" the problem in javascript, follows: <?php yii::app()->clientscript->registerscript('details', "$('#details-$data-id_employer_contract').click(function(){ $('#detailsdiv-$data->id_employer_contract').slidetoggle(); return false;});");?> how can make javascript code dynamic? meaning, how can loop through id? tried adding code listview property ajaxupdate it's still not working. can tell me how can loop javascr

html - Open link in window that contains iframe where link is initiated -

i have iframe contains webpage built. have link in frame, , when click on link opens link within iframe. how make link opens in main window? if want links in iframe open parent frame, add following tag head of html document: <base target="_parent"> ( see documentation base tag .) otherwise, add target="_parent" attribute link want opened in parent frame. ( see documentation target attribute of a tag .) in either case, if there no parent frame/context, _parent behaves _self .

SELECT INTO Multiple Variable in MySQL declaration -

is possible set 2 parameters value in single query in stored procedure mysql? want , 2 different parameters output , don't want con-cat it. declare v_first_name varchar(100); declare v_last_name varchar(100); set p_email_id = 'some_email_id'; /* instead of want laod result in single query set v_first_name=(select first_name user_master email_id=p_email_id); set v_last_name=(select last_name user_master email_id=p_email_id); */ if flag1=1 select 1 'result',v_first_name 'first_name',v_last_name 'last_name'; else select 0 'result',v_first_name 'first_name',v_last_name 'last_name'; end if; any ? select first_name @v_first_name , last_name @v_last_name user_master email_id=p_email_id; ==== **not working** just list them out commas after into : select a, b, c v_a, v_b, v_c ...

android - Galaxy S4 test app on real device -

following documentation here , trying setup testing environment on s4. when plug computer drivers not install properly, follow instructions update whatever in usb_driver folder of sdk. i message says windows not locate driver , unable install, if correct driver isn't in folder. clicking on samsung_android under other devices in computer management window. when go computer, see device listed under portable devices though. missing step? appreciated download usb driver windows here: http://developer.samsung.com/android/tools-sdks/samsung-andorid-usb-driver-for-windows

symfony - Detect routes and entities from Symfony2 vendor -

i'm creating bundle adds entity , few routes use in symfony2 application. i want bundle used vendor, i've created files, published on github , packagist , works fine. my problem when require bundle in project, entities , routes not detected: 1) php app/console doctrine:schema:update doesn't detect modification 2) when try hit route vendor, here error get: no route found "get ..." any idea welcome, what's process these things in bundle? cheers. cyril take @ installation steps of fosuserbundle example. uses published bundle, have activate in appkernel , import routes. entity think bundle user have subclass entity.

ms access - VBA global variable value disappear in other sub -

i have global variable called flag set up. can access flag every module in code, when assign value 1 in sub command97_click(), reason flag not keep value sub form_beforeupdate(cancel integer). when print flag in sub form_beforeupdate not equal 1 anymore. know silly, new vba... bear in mind code more this, keeping basic question. thanks in advance! public flag integer private sub command97_click() flag = 1 end sub private sub form_beforeupdate(cancel integer) if flag = 1 docmd.runcommand accmdundo msgbox "flag = " & flag, vbinformation exit sub end if end sub i suspect have variable scope issue. depends on flag variable defined, , there others same name elsewhere. if public flag integer @ top of form module, it's not global. take here explanation of scopes.

android - Set Intents category programmatically -

i have application following lines in androidmanifest: <category android:name="android.intent.category.home" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.monkey"/> my question is: possible set these options programmatically? mean, users able enable or disable options above. what keep app launcher. so, possible put condition on this, can make depending on user? edition: edited question add suggestion of rawr. here doing before calling main activity: intent myintent = new intent(v.getcontext(), mainactivity.class); myintent.addcategory(intent.category_home); myintent.addcategory(intent.category_default); myintent.addcategory(intent.category_monkey); startactivity(myintent); if use these commands inside manifest, work. 1 cannot leave app pressing home button. adding categori

php - For the life of me, I can't figure out how to setup the Zend Framework -

i'm sorry, know there tons of tutorial on , tried , didn't work. i have wamp installed in c:. it's document root d:/sites/wamp. have been able load regular html, php, wordpress , code igniter there. with code igniter, quite easy had copy paste library d:/sites/wamp folder , configure database. with zend framework, i'd similar i'd have copy files wamp folder. possible? i'd avoid using zend tool now. point me in right direction please tutorial or files copy over. if reason don't want use zend_tool here default basic application structure: project |-- application | |-- bootstrap.php | |-- configs | | `-- application.ini | |-- controllers | | |-- errorcontroller.php | | `-- indexcontroller.php | |-- models | `-- views | |-- helpers | `-- scripts | |-- error | | `-- error.phtml | `-- index | `-- index.phtml |-- library | `--zend //zend framework goes here *** |

ios - CABasicAnimation - transform scale keep in center -

trying animatie ellipse masked on uiview scale transformed remaining in center position. i have found calayer - cabasicanimation not scaling around center/anchorpoint , , followed adding bounds property masklayer cashapelayer however, ends mask being positioned in left corner 1/4 of showing. mask remain within center of screen. @synthesize maskedview; - (void)viewdidload { [super viewdidload]; uiviewcontroller *vc = [self.storyboard instantiateviewcontrollerwithidentifier:@"next"]; vc.view.frame = cgrectmake(0,0, self.view.frame.size.width, self.view.frame.size.height); vc.view.layer.bounds = self.view.layer.bounds; cashapelayer *masklayer = [[cashapelayer alloc] init]; cgrect maskrect = cgrectmake((self.view.frame.size.width/2)-50, (self.view.frame.size.height/2)-50, 100, 100); cgmutablepathref path = cgpathcreatemutable(); cgpathaddellipseinrect(path, nil, maskrect); [masklayer setpath:path]; cgpathrelease(path); vc.vi

asp.net mvc 4 - MVC 4 Add/Update list in a partial view -

this first program , quite not sure on how complete codes. trying create new transaction, supplier there multiple inventory types. lost on how add inventory types list using partial view. guidance on how structure code appreciated. here codes: viewmodels: public class inventorytransactionparent { [key] public int inventorytransactionid { get; set; } [foreignkey("inventorytransactiontype")] [display(name = "transaction type")] public int inventorytransactiontypeid { get; set; } public virtual inventorytransactiontype inventorytransactiontype { get; set; } [display(name = "supplier")] [foreignkey("supplier")] public int? supplierid { get; set; } public virtual supplier supplier { get; set; } [display(name = "transaction date (from previous month only)")] [displayformat(applyformatineditmode = true, dataformatstring = "{0:dd/

c# - BulkCopy and Collation from two Databases -

i have two different databases , 1 has sql_latin1_general_cp1_ci_as collation , other modern_spanish_ci_as , i obtain data de source select [data1] collate database_default cal_key, [data2] collate database_default telephone [tablename] after create new table in database destination, this create table tempo_xxx (cal_key varchar(20) collate database_default not null, telephone varchar(40) collate database_default not null) i use columnmapping , sbc.columnmappings.add("cal_key", "cal_key"); sbc.columnmappings.add("telephone", " telephone "); but obtain same message: the given columnmapping not match column in source or destination the destination columnmapping case sensitive change mapping sbc.columnmappings.add("cal_key", "cal_key"); also remove spaces " telephone "

CakePHP Controller Testing: Mocking the Auth Component -

the situation controller code <?php app::uses('appcontroller', 'controller'); class postscontroller extends appcontroller { public function isauthorized() { return true; } public function edit($id = null) { $this->autorender = false; if (!$this->post->exists($id)) { throw new notfoundexception(__('invalid post')); } if ($this->post->find('first', array( 'conditions' => array( 'post.id' => $id, 'post.user_id' => $this->auth->user('id') ) ))) { echo 'username: ' . $this->auth->user('username') . '<br>'; echo 'created: ' . $this->auth->user('created') . '<br>'; echo 'modified: ' . $this->auth->user('modified') . '<br>

string - Finding escape characters in AT&T x86 assembly -

question 1: have following assembler code, purpose loop through input string, , count number of escape characters '%' encounters: .globl sprinter .data .escape_string: .string "%" .num_escape: .long 0 .num_characters: .long 0 .text sprinter: pushl %ebp movl %esp,%ebp movl 8(%ebp),%ecx # %ecx = parameter 1 loop: cmpb $0, (%ecx) # if end of string reached jz exit cmpl $.escape_string,(%ecx) # if escape character found je increment back: incl .num_characters incl %ecx jmp loop increment: incl .num_escape jmp # jump 'back' exit: movl .num_escape, %eax # return num_escape popl %ebp ret this assembly code compiled following c code: #include <stdio.h> extern int sprinter (char* string); int main (void) { int n = sprinter("a %d string of %s fashion!"); printf("value: %d",n); return 0; } the expected output running code value: 2 (be

erlang - Receive after result not returned -

given function: %% @doc retrieves client's state. -spec(state(pid()) -> atom()). state(pid) when is_pid(pid) -> case process_info(pid) of undefined -> undefined; _else -> pid ! {state, self()}, receive {state, state} -> state after 1000 -> undefined end end. it works expected dead pids , alive clients: > client:state(a). undefined > client:state(pid). online but reason returns pid if process pid not reply status during 1 second: > client:state(self()). <0.172.0> i'm expecting 'undefined' atom there. how can fix code? this happens because receiving message sent. function running on shell process , sends {state, self()} message. right after sending message, receives message , function ends state , self() pid sent. i hope i've not been confusing.

Generic way to compare class instance in Java -

i looking generic way implement code snippet: if (!(obj instanceof myclass)) { return false; } ideally (so don't have hard-code myclass everytime): if (!(obj instanceof this.getclass())) { return false; } however, example not work. you do this.getclass().isinstance(obj);

multithreading - Running Two Functions at the Same Time in C# -

i have created class library in project scans series of files. in main project uses dll reference, i'd create progress bar shows how many file have been scanned far. the dll class makes use of foreach loop since it's purpose turn each file hash code. foreach loop has been used join each converted segment of file can have 512 bit long code, , proceeds next file. i have defined variable in dll class --> public static int value_ = 0; this variable updated @ the end of foreach loop. now in main project, i'd use variable update progress bar @ same time function in class library project running. for example : dll.function(); pb.value = value_; i'd appreciate hint on how can implement this. you can use background worker work , report progress. worker.workerreportsprogress = true; and can have progress report triggered event subscribe to. worker.progresschanged += new progresschangedeventhandler(worker_progresschanged); in doing so, can

sql server - Getting wrong result when using bigint in sql query -

i have passed below amountdue in query getting wrong result. amountdue data type float. amountdue: 2412880.28 amountdue: 561.06 my query: select convert(varchar,(select convert(bigint,amountdue*100))) dbo.tblbidresults i getting below results wrong: 241288027 56105 correct result: 241288028 56106 try converting numeric instead of bigint: declare @temp float set @temp = 2412880.28 select convert(varchar,(convert(numeric(27,0),@temp*100))) there good post goes on reason here.

Preferred way of writing vertical media queries with Sass' Breakpoint Extension -

with sass extension breakpoint, there preferred way write vertical media queries have single argument query value? here's example of i'd accomplish: @media (max-height: 50em) { .item { font-size: 2em; } } or, should plain, "on-the-fly" media query these styles such: .item { @media (max-height: 50em) { font-size: 2em; } } is possibly handled variable? my styles "mobile first", of other media queries on site use breakpoint's default "min-width" setting. thanks! you can following: $vertical: 'max-height' 50em; .item { @include breakpoint($vertical) { font-size: 2em; } } you can include height queries other queries follows: $mixed: 15em ('max-height' 50em); .item { @include breakpoint($mixed) { font-size: 2em; } }

perl - How to add a character before a specific symbol in a variable? -

i have user defined variables user@domain.com using perl need add "sc" @ end of user , before @ symbol. so if: $user = "user@domain.com" $string = "sc" i need come out result of $user-id = "usersc@domain.com" any appreciated. $user =~ s/(?=@)/sc/; or $user =~ s/@/sc@/; or $user =~ s/^[^@]*\k/sc/; # assumes "@" present. of course, none of work if $user doesn't contain correct string begin with. $user = "user@domain.com"; is same as $user = "user" . join($", @domain) . ".com"; given @domain doesn't exist, that's same as $user = "user.com"; always use use strict; use warnings; ! want my $user = "user\@domain.com"; or my $user = 'user@domain.com'; to create var $user string user@domain.com .

php - Custom delete method doesn't call in custom datasource -

i'm using custom datasource consume webservice. create, read , update work delete doesn't works. here code calling delete method in controller. public function delete($id){ $this->autorender = false; debug($this->article->delete($id)); } and here code in datasource public function delete(model $model, $id = null) { echo "display message if method called"; $json = $this->http->post(cakesession::read('site.url') . '/webservice/delete/', array( 'id' => $id, 'apikey' => $this->config['apikey'], 'model' => $model->name )); $res = json_decode($json, true); if (is_null($res)) { $error = json_last_error(); throw new cakeexception($error); } return true; } but when want delete item, debug(); display false . have no other displays. don't understand why delete method isn't called correctly. there wrong in code

c# - Matrix.CreateScale only scaling with full numbers -

i've been trying zoom in , out on objects using matrix.createscale() function, using this: matrix.createscale(new vector3(zoom, zoom, 0)) but, i've noticed when tried make zoom 1,5 doesn't anything, @ numbers 1 or 2, when reaches it's big/small, how zoom in , out without taking such big steps, how make take less steps? public float zoom { { return zoom; } set { zoom = value; } } public matrix get_transformation(graphicsdevicemanager graphicsdevice) { transform = matrix.createtranslation(new vector3(-pos.x, -pos.y, 0)) * matrix.createrotationz(rotation) * matrix.createscale(new vector3(zoom, zoom, 0)) * matrix.createtranslation(new vector3(graphicsdevice.graphicsdevice.viewport.width * 0.0f, graphicsdevice.graphicsdevice.viewport.height * 0.0f, 0)); return transform; } //zoomin

java - multiple singleton beans referencing the same class -

i have java class lets 'class1' holds concurrenthashmap (to used cache) , functions update , remove entries in map.this class not designed singleton class. having discussion colleague, couldnt decide due couple of posts read on internet.i asking if okay this- <bean id="reqrespcachemgr1" class="gravity.applications.rfqservice.reqrespgtwy.utility.reqrespcachemanager" scope="singleton"> </bean> <bean id="reqrespcachemgr2" class="gravity.applications.rfqservice.reqrespgtwy.utility.reqrespcachemanager" scope="singleton"> </bean> <bean id="reqrespcachemgr3" class="gravity.applications.rfqservice.reqrespgtwy.utility.reqrespcachemanager" scope="singleton"> </bean> i trying create 3 singleton instances of same class..i think doesnt spoil meaning of singleton-ness because talking singleton scope in spring bean factory context , not class loader

Windows batch - move x amount of folders+content to another folder -

i in process of cleaning , organizing nas folders. however, have folder on 1800+ folder in it, need have split 18 folders each containing maximum 100 folders. name of folder moved irrelevant, @ top-level should sequential. folder content should moved along. additionally, need batch file reverses this. the reason needed due program uses index , organize folders , folder content cannot handle folders more 100 folders. i tried myself already, ended foobar'ing completely. something this? @echo off set destination=c:\temp\ set source=c:\windows\system32\ set dcount=0 set fcount=0 setlocal enabledelayedexpansion mkdir %destination%dir%dcount% /f "tokens=*" %%f in ('dir /b /s /a:d "%source%*"') ( set str=%%f set str=!str:%source%=! mkdir %destination%dir!dcount!\!str! copy %%f %destination%dir!dcount!\!str! 1> nul set /a fcount=!fcount!+1 if !fcount! equ 100 ( set fcount=0 set /a dcount=!dcount!+1 mkdir %des