Posts

Showing posts from September, 2012

ASP.NET MVC 3, user defined id for field -

can 1 help? @html.editorfor(model => model.property, new { id = "some value" }) not working. when view source displays element id "id=model.property" how resolve this. thanks. if need prefix generated id, use viewdata.templateinfo.htmlfieldprefix property. otherwise, use html.textbox, html.checkbox, etc... or write entire input element tag yourself.

xml-tree parser (Haskell) for graph-library -

i'm writing library working graphs. primary task - parsing xml-tree. tree looks <graph nodes=4 arcs=5> <node id=1 /> <node id=2 /> <node id=3 /> <node id=4 /> <arc from=1 to=2 /> <arc from=1 to=3 /> <arc from=1 to=4 /> <arc from=2 to=4 /> <arc from=3 to=4 /> </graph> structure storing: type id = int data node = node id deriving (show) data arc = arc id id deriving (show) data graph = graph { nodes :: [node], arcs :: [arc]} how write data xml file structure? can not write parser xml tree of kind (hxt library) assuming convert proper xml (surround attribute values quotes), following code work (using xml-enumerator): {-# language overloadedstrings #-} import text.xml.enumerator.parse import control.monad import data.text (unpack) import control.applicative type id = int data node = node id deriving (show) data arc = arc id id deriving (show) ...

windows - How get admin privileges? -

i have question , long time im looking answer, wrote program , need know installer can configure windows 7 run program administrator? program come windows starting , want run administrator. included manifest program , compiled windows ask every time program want executed better if there possibility ask once admin privileges. told me installer dont need include manifest program , there options ask once admin privilege. can me this? thank you. you need somehow configure application run under local system account. done through scheduled task or windows service.

c# - Why doesn't resharper suggest removing redundant access modifiers? -

resharper superb, fule kno. however, if declare method such: private void methodname() { //code in here } or enum: public enum someenum { value1, value2 } resharper doesn't suggest removing redundant access modifiers... why not? it doesn't suggest removing redundant comments either. recognises of content of code file, while technically redundant compiler, enhances code readability, , hence maintainability.

analytics - User Agent in an iPhone App -

what default user agent if want add third party code (analytics or ads) in iphone app , how can change it? change user-agent in header of request this: nsstring* useragent = @"mozilla/5.0 (x11; u; linux i686; en-us; rv:1.8) gecko/20051111 firefox/1.5 bavm/1.0.0"; nsurl* url = [nsurl urlwithstring:@"http://www.stackoverflow.com/"]; nsmutableurlrequest* request = [[[nsmutableurlrequest alloc] initwithurl:url] autorelease]; [request setvalue:useragent forhttpheaderfield:@"user-agent"]; nsurlresponse* response = nil; nserror* error = nil; nsdata* data = [nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error]; nsstring *result = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding]; nslog(@"%@",result); get current user-agent / lookup user-agents specific browsers: http://www.useragentstring.com/ the user-agent makes no difference. use default one, or better, don't worry ...

Perl SSH connection to execute telnet -

i tried following access router via central admin server "ssh hop" server #!/usr/bin/perl -x use strict; use net::openssh; use net::telnet; $lhost = "linuxserver"; $luser = "linuxuser"; $lpass = "linuxpassword"; $chost = "routername"; $cpass = "routerpassword"; $prompt = '/(?:password: |[>])/m'; @commands = ("show users\r"); $ssh = net::openssh->new($lhost, 'user' => $luser, 'password' => $lpass, 'master_opts' => [ '-t' ], #'async' => 1 # if enabled password cannot set here ); ($pty, $err, $pid) = $ssh->open2pty("telnet $chost"); $t = new net::telnet( -telnetmode => 0, -fhopen => $pty, -prompt => $prompt, -cmd_remove_mode => 1, -output_record_separator => "\r", #-dump_log => "debug.log", ); $end = 0; while (!$end) { ($pre, $post) = $t->waitfor($prompt); if ($post =~ /password: /m)...

How to execute jQuery? -

here code: jquery.getjson('http://twitter.com/status/user_timeline/brianj_smith.json?count=1&callback=?', function(data){ if (data.length > 0) { var link = jquery('<a>').attr('http://twitter.com/brianj_smith/status/' + data[0].id) .text('read'); }); i not sure how execute on website -- using javascript if possible. can give me helping hand? edit: i'm not having luck getting text 'read' show up...at all. not skilled @ jquery on whole. i've begun use it. have jquery in head of page. place code snippet somewhere on page(i assume jquery.js included on page): <script type="text/javascript"> jquery(function(){ jquery.getjson('http://twitter.com/status/user_timeline/brianj_smith.json?count=1&callback=?', function(data){ if (data.length > 0) { var link = jquery('<a>').attr('href', ...

Populate database table with enum values in hibernate -

is there possibility let hibernate (3.6) populate database table values given enum ? have following class: @entity public enum role { role_user_free("role_user_free"), role_user_standard("role_user_standard"), role_user_premium("role_user_premium"), role_admin("role_admin"); ... constructor / setter / getter etc. } i can use enum without problems entity class using @enumerated(enumtype.string) public role getrole() my question is, how can populate corresponding table role automatically ? underlying logic , definiations resides in xml specification. of course, can generate sql file spec xsl , let hibernate import import.sql sematic @ startup... there more elegant way ? the table should this: |roleid|rolename | | 0 |role_user_free| .... you have pick side - either you're going use role enum or entity. you're trying both , that's going lead trouble along road. if want use enum r...

PHP Make a simple if-isset-empty function -

i'm coding worksheet app printer company. i'm getting flood of forms. every single input field have check if $_post variables set, , if, echo value. (in case of error, example after validation error, user shouldn't retype whole form) sample code: if(isset($_post['time'])&&!empty($_post['time'])){echo $_post['time'];} i had implement hundred times. tried figure out kind of function make simple , readable. something this: function if_post_echo($key, $default = "") { if(isset($_post[$key])&&!empty($_post[$key])){ echo $_post[$key]; }else{ echo $default; } } but wont work. have tried pass in $_post $key variable this: if_post_echo($_post['time']) function if_request_echo($key, $default = "") { if(isset($key)&&!empty($key)){ echo $key; }else{ echo $default; } } and tried this: function if_request_echo...

c++ - Destructor and python -

i have base class in c++. export python using boost::python. virtual destructor? base class should have virtual destructor avoid wrong memory freeing, right? forget , wrote base without destructor. works, lot of memory leaks. now i've added: class base { public: virtual ~base(); // other members... }; and after importing of module in python error: importerror: base.so: undefined symbol: _zti6base what i'm doing wrong? and, understand, error causes due missing destructor exporter py-module. the missing symbol error caused failing define destructor (you're declaring destructor, it's unclear question whether you're defining it): class base { public: virtual ~base() {} // other members... }; (note added curly braces) as question whether every "base class should have virtual destructor avoid wrong memory freeing", please take @ faq: http://www.parashift.com/c++-faq-lite/virtual-functions.html...

html5 - SVG rendering badly in Firefox -

i working on infographic sliding carousel <li> s, svg showing pixelated in firefox, though bug svgs in ff has been resolved, thought. can see fix this? url: http://weaver-wp.weavertest.com/radiation-infographic/ you zooming svg file large size: background-size: 9730px 30000px; background-position: -7310px -29250px; most browsers not antialias large svg shapes, requires graphics memory. (this see in safari , chrome.) looks firefox rendering svg size of canvas , blowing image interpolation cropped region. the fix both same: crop svg first , use cropped portion background.

c# - How do I Access separate pages of DataTable rows -

i have datatable large resultset. datatable used generate multiple pages in pdf (one each row in datatable). after number of rows, pdf generation takes long, want provide list of hyperlinks end user generate separate pdfs each set of rows, i.e. set 1 (rows 0-90), set 2 (rows 91-181), etc. i want able filter original datatable whenever generate pdf set of rows. know gridviews offer paging capability, don't want plop data gridview unnecessarily. what hoping kind of rowfilter can say: _dt.rowfilter = "rows(0-90)" does know of such feature of datatables (using .net 3.5)? or can offer solution? try - use asenumerable extension method , use linq query rows need. datatable.asenumerable().take(90); page 2: datatable.asenumerable().skip(90).take(90);

Cases where HTML is not frowned upon inside of php? -

i know control stuff should separated view stuff, there's many cases know it's slower , over-complicating things html templates. my question is... acceptable? examples of i'm talking about... functions output dynamic tables, functions create input elements, , functions format text. the con can think of, other being "ugly," don't tab out , newline inside of these functions, makes output html bit ugly. of time when face this, forget convention - functionality wins in cases. anyone have insight or opinions on topic share? i know it's more work, mvc pattern more maintainable in long run. dynamic tables, better create class can create size table/list/divs , pass data have view data in model/controller. i cheat bit on small projects , mix in business logic presentation, if project ever grows more work correcting down road. unless i'm being lazy, it's not hard strict implementing code in mvc manner.

objective c - What Doxygen alternative would Dave DeLong use? -

here's sure way downvoted, kickbanned , laughed at, i'm gonna try anyway. yesterday dave delong answered a question of mine . wasn't answer looking for, in question mentioned alternative way of generating doxygen-style documentation objective-c. before it, (maybe dave himself) noticed answer didn't match question , removed it. *poof* gone link documentation tool. i can't remember name, i'm it's neither headerdoc nor doxygen itself. dave, out there? link again? may gods of downvoting gentle me. cheers y'all, ep p.s. where's "send message user" button on stackoverflow again? :s i'm not dave delong, i'd use appledoc , it's pretty darn awesome! developer page quote: appledoc command line tool helps objective-c developers generate apple-like source code documentation specially formatted source code comments. it's designed take readable source code comments possible input , use comme...

javascript - php page redirect after operation -

i have page (index.php) has php grid subpages(<<1,2,3,4>>). operation on page takes index.php. using $_get['prd_p'] or $_request['prd_p'] gives page number. want users stay on page after operation, means have use redirects. <form name="frmsearchme" action="<?php echo $page_name; ?>" method="post"> <tr> <input class='form_button' type='submit' name='btnsubmit' value=' save ' onclick='return checkerrors();' /></td> </tr> //php codes here </form> yes, have redirect same page after performing operation. header("location:url&".$_get['prd_p']); die(); you should use die() or exit() after redirect statment.

php - How to begin "block of string" formatting in C#? -

i have write queries in c# code , had question formatting. see below: string sql = "select * "; sql += "from hyt_user_vehicle_group_assoc "; sql += "inner join hyt_vehicle_group on hyt_vehicle_group.vehicle_group_no = hyt_user_vehicle_group_assoc.vehicle_group_no "; coming php background, how have written in php: $sql = "select * hyt_user_vehicle_group_assoc inner join hyt_vehicle_group on hyt_vehicle_group.vehicle_group_no = hyt_user_vehicle_group_assoc.vehicle_group_no"; notice how don't have write sql += each new line in string? there wayto tell c# i'm going begin "block of string", such don't have type sql += ? yup - use verbatim string literal putting @ before leading ": string sql = @"select * hyt_user_vehicle_group_assoc inner join hyt_vehicle_group on hyt_vehicle_group.vehicle_group_no = hyt_user_vehicle_group_assoc.vehicle_group_no"; note ...

Rails routing by anchor identifier -

hey i'm looking how define route under anchor identifier ie: match '/#/pages/home' => 'pages#home' or match '/#/posts/:id' => 'posts#get' # special character , cannot that. if could, why want ?

javascript - jQuery .load() not firing on images (probably caching?) -

i have pretty basic jquery code: ... $(this).find('img').load(function(){ loadedimages++; if(loadedimages == $this.find('img').length){ ... however, thats not firing consistently. fires if hard refresh or close browser, normal refresh, or hitting same url twice @ time without erasing cache makes .load() never fire. any ideas on how fix this? a way add "dummy variable" @ end of url use grab image... such time in milliseconds appended query string param.

javascript - Best practice for triggering events on calling page from an ajax page -

i have page lists bunch of files. page can accessed directly via url or can loaded in modal dialog via ajax different page. if files page loaded via ajax, allow user click name of file , trigger action in page loaded files page. example, there article edit page. page contains "attach file" button. when user clicks button, files page loaded in modal dialog , when filename clicked, id of file inserted article form , dialog closed. there event edit page similar button, handle filename-click event differently on page. i'd handle these click events differently depending on calling page. @ moment i'm defining handler function global scope in page containing form files being attached, testing function in the files-page when filename clicked , calling if exists. works feels little hacky. there kind of best practice sort of thing i'm not aware of? i'm using jquery if makes things easier in way.. you should @ jquery live attach handler event elem...

sql - Optimal solution for interview question -

recently in job interview, given following problem. say have following table widget_name | widget_costs | in_stock --------------------------------------------------------- | 15.00 | 1 b | 30.00 | 1 c | 20.00 | 1 d | 25.00 | 1 where widget_name holds name of widget, widget_costs price of widget, , in stock constant of 1. now business insurance have deductible. looking find sql statement tell me every widget , it's price exceeds deductible. if dedudctible $50.00 above return widget_name | widget_costs | in_stock --------------------------------------------------------- | 15.00 | 1 d | 25.00 | 1 since widgets b , c used meet deductible the closest following select * ( select widget_name, ...

jquery - JQueryUI Dialog Size -

i'm new jqueryui, , though have dialog working, doesn't open @ size think i'm specifying. why setting width , height when dialog defined not affect initial size of dialog? how make 600px 500 px? here div defines dialog: <div id="dialog-form" title="create appointment"> <form> . . . </form> </div> here javascript makes dialog of it: $(function() { $("#dialog-form").dialog({ autoopen: false, maxwidth:600, maxheight: 500, width: 600, height: 500, modal: true, buttons: { "create": function() { $(this).dialog("close"); }, cancel: function() { $(this).dialog("close"); } }, close: function() { } }); and javascript defines button open it: $("#create-appt") .button() .click(function() { ...

queue - mq_receive: message too long -

i implementing communication between 2 processes using queue. problem when call function mq_receive, error: message long. i have done following: struct mq_attr attr; long size = attr.mq_msgsize; .... // initializing queue "/gateway" int rc = mq_receive(gateway, buffer, size, &prio); if print size value, size=1, while when print same size program (got same mechanism), not long integer ( -1217186280 )... how can solve error?....so while size = 1, believe it's right "message long" why 1? p.s. have tried put : int rc = mq_receive(gateway, buffer, sizeof(buffer), &prio); but no result. it seems need read docs more carefully. when call mq_receive should pass size of destination buffer. this size must greater mq_msgsize attribute of queue . in addition, seems have error in queue attributes initialisation makes proper mq_receive call impossible. here standard message queue session: fill mq_attr struct ( doc ): struct mq_a...

r - Efficient apply or mapply for multiple matrix arguments by row -

i have 2 matrices want apply function to, rows: matrixa gsm83009 gsm83037 gsm83002 gsm83029 gsm83041 100001_at 5.873321 5.416164 3.512227 6.064150 3.713696 100005_at 5.807870 6.810829 6.105804 6.644000 6.142413 100006_at 2.757023 4.144046 1.622930 1.831877 3.694880 matrixb gsm82939 gsm82940 gsm82974 gsm82975 100001_at 3.673556 2.372952 3.228049 3.555816 100005_at 6.916954 6.909533 6.928252 7.003377 100006_at 4.277985 4.856986 3.670161 4.075533 i've found several similar questions, not whole lot of answers: mapply matrices , multi matrix row-wise mapply? . code have splits matrices row lists, having split makes rather slow , not faster loop, considering have 9000 rows in each matrix: scores <- mapply(t.test.stat, split(matrixa, row(matrixa)), split(matrixb, row(matrixb))) the function simple, finding t-value: t.test.stat <- function(x, y) { return( (mean(x) - mean(y)) / sqrt(var(x)/length(x) + var(y)/length(y)) ) } ...

actionscript 3 - AS3: Embedding characters -

Image
i having trouble textfields , caracter embedding. have understood, way embed character in flash, have textfield in movieclip exported actionscript via classname. have textfield embed characters. but when try use textfield in project, cannot auto resize field longer!? there better way embed charactes? or missing unknow attribute? (and yes have tried textfield.autosize = "left" (or "center" or "right") ). the textfield configured in flash cs4: properties: http://screencast.com/t/0vb6knno6g library implementation: http://screencast.com/t/w3yqlqit0vei and embed movieclip containing textfield this: protected var tabname:movieclip = new text(); // property on object adding text , setting settings: var txt:textfield = tabname.txt; if( !contains(tabname) ) { addchild(tabname); var format:textformat = new textformat(); format.bold = true; format.font = "arial"; ...

mysql - Using @variables:= in delphi query does not work -

i have following problem. zquery1.sql.text:= ' select '+ ' if(q.rank2 = 1, @rank:= 1, @rank:= @rank + 1) rank '+ ' ,q.* ( '+ ' select groep.id - mingroepid(groep.id) rank2 '+ ' ,groep.otherfields '+ ' groep '+ ' order rank2 ) q; '; zquery.open; when run code exception incorrect token followed ":" in zquery1. how fix this? need use delphi, because cannot put select in mysql procedure. zeos 6 not support mysql procedures return resultset. p.s. i'm using delphi 2007 , mysql 5.1 zeos 6.6.6. although i'm pretty sure versions don't matter. i'm not willing switch versions i'm far project. this can't done, can parameterize value. best can sql.text ...

.net - Why is creating a new thread expensive? -

i read lots of .net resources telling me should using thread pool thread rather instantiating new thread myself. should because instantiating new thread expensive operation. happens during thread creation makes expensive operation? everything relative. creating new thread expensive... relative not creating one. if you're not doing lot of work per thread, work involved in building , tearing down threads can potentially make measurable portion of cpu time. it's cheap relative creating new process, on windows. it's better use threadpool because tuned avoid having many threads active @ once. want more handful of threads active @ 1 time, or you'll spend lot of cpu time performing context-switches between them all. using threadpool manages you, additional requests queued until worker thread ready.

ios - Indexed TableViews not displaying after upgrade to MT 4.0 -

after upgrading mt 4.0, tableviews displaying indexes on right hand border no longer working. tableview still displays in sections , works properly, index not displaying. i have these 3 methods defined in uitableviewsource, , 3 appear working: public override string[] sectionindextitles(uitableview tableview) public override int sectionfor(uitableview tableview, string title, int atindex) public override string titleforheader(uitableview tableview, int section) is else having problem? bug mt 4.0? this known bug . it appears uitableview not retaining returned array, can use following work around issue while investigate further: nsarray array; [export ("sectionindextitlesfortableview:")] public nsarray sectiontitles (uitableview tableview) { if (array == null) { string[] titles = new string[rowsinsection(tableview, 0)]; (int index = 0; index < titles.length; index++) titles[index] = index.tostring(); arr...

Jquery ajax call not working within a already rendered partial in Rails -

i´m using great nicolas alpi instructions jquery + rails, application.js is: jquery.ajaxsetup({ 'beforesend': function(xhr) {xhr.setrequestheader("accept", "text/javascript")} }) function _ajax_request(url, data, callback, type, method) { if (jquery.isfunction(data)) { callback = data; data = {}; } return jquery.ajax({ type: method, url: url, data: data, success: callback, datatype: type }); } jquery.extend({ put: function(url, data, callback, type) { return _ajax_request(url, data, callback, type, 'put'); }, delete_: function(url, data, callback, type) { return _ajax_request(url, data, callback, type, 'delete'); } }); /* submit form ajax use class ajaxform in form declaration <% form_for @comment,:html => {:class => "ajaxform"} |f| -%> */ jquery.fn.submitwithajax = function() { this.unbind('submi...

seo - In Django, disable @login_required for search engine spiders -

i'm looking clean way let search engine spiders bypass @login_required, viewing pages typically require logged-in user. write middleware automatically log search engines dummy account, that's not i'd call clean. suggestions better solution? thanks. don't this. 'cloaking', , can banned google's index. cloaking refers practice of presenting different content or urls users , search engines. serving different results based on user agent may cause site perceived deceptive , removed google index. cloaking: http://www.google.com/support/webmasters/bin/answer.py?answer=66355 instead, need implement google's first click free solution. in setup, first click google search result able see full content, subsequent clicks trapped. can done on referrer basis, or cookie basis. can read more first click free here: first click free: http://www.google.com/support/webmasters/bin/answer.py?answer=74536

python - Pattern for associating pyparsing results with a linked-list of nodes -

i have defined pyparsing rule parse text syntax-tree... text commands: add iteration name = "cisco 10m/half" append observation name = "packet loss 1" assign observation results_text = 0.0 assign observation results_bool = true append datapoint assign datapoint metric = txpackets assign datapoint units = packets append datapoint assign datapoint metric = txpackets assign datapoint units = packets append observation name = "packet loss 2" append datapoint assign datapoint metric = txpackets assign datapoint units = packets append datapoint assign datapoint metric = txpackets assign datapoint units = packets syntax tree: ['add', 'iteration', ['name', 'cisco 10m/half']] ['append', 'observation', ['name', 'packet loss 1']] ['assign...

HTML5 video element width and height attributes question -

can html5 video elements width , height attributes have pixel , percentage value? if these values allowed? do have add percentage , pixel prefixes @ end of value? based on w3c specification width , height define video size in css pixels, not percentages. setting % value won't work. <!-- no `px` @ end of value css --> <video width="980" height="560" ... > ... </video> it’s best specify height , width attributes page doesn’t need reflow. if pixel values doesn't work you, don't specify video dimension attributes , instead use style attributes specify height , width in percentage values. <!-- let's supposed want video adjust size of parent element --> <video style="outline:none; width:100%; height:100%;" ... > ... </video> if don't specify dimensions @ all, video display @ original size.

iphone - Drag and drop objects and return them to their original position -

i'm trying drag image , let return it's original position after releasing it. far, can drag image creating button using following code: (as seen in answer question: basic drag , drop in ios ) uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; [button addtarget:self action:@selector(imagetouch:withevent:) forcontrolevents:uicontroleventtouchdown]; [button addtarget:self action:@selector(imagemoved:withevent:) forcontrolevents:uicontroleventtouchdraginside]; [button setimage:[uiimage imagenamed:@"vehicle.png"] forstate:uicontrolstatenormal]; [self.view addsubview:button]; and later define: - (ibaction) imagemoved:(id) sender withevent:(uievent *) event { cgpoint point = [[[event alltouches] anyobject] locationinview:self.view]; uicontrol *control = sender; control.center = point; } how can make return it's original position after releasing ?, starters save position @ each image supposed return, then, there anyway indicate uiima...

regex - Perl file treatment is limited in size? -

i've made translator in perl messageboard migration, applying regexes , print result. write stdout file , here go ! problem program won't work after 18 mb written ! i've made translate.pl ( https://gist.github.com/914450 ) , launch line : $ perl translate.pl mydump.sql > mydump-bbcode.sql really sorry quality of code never use perl... tried sed same work didn't manage apply regex found in original script. [edit] reworked code , sanitized regexes (see gist.github.com/914450) i'm still stuck. when splited big dump in 15m files, launched translate.pl 7(processes) 7 use cores script stops @ variable size. "tail" command doesn't show complex message on url when stops... thanks guys ! let know if manage finally yikes - start basics: use strict; use warnings; ..at top of script. complain not declaring lexicals, go ahead , that. don't see obvious truncating file, perhaps 1 or more of regexes pathological. also, undefs @ end not...

uml - What does I1, I2, U1, means in Visio database relationship diagram? -

i reverse engineering database create database er diagram in visio. when display table in visio, on left hand side of entity diagram, see symbols next column names not know mean. symbols such as, u1, u2, l1, l2, l5...etc. others symbols such pk (primary key) , fk (foreign key) shown in same area, make sense me. these other types of indexes. u1 = unique index 1..... i1 = index 1...... here examples in sql server http://msdn.microsoft.com/en-us/library/ms188783.aspx

javascript - Form input history select event -

i've been struggling deal few forms have users entering in lot of repeat data. in these cases helps users have access form history (ie. select name of person they've sent multiple notices to, etc. issue here in browsers there no event fired user selects chunk of text form history . of few other posts on stackoverflow decided use setinterval instead. what i'm looking feedback spot might bad idea , make better. i have demo of here http://lab.atworkinthecloud.com/form-history-select/ i believe shouldn't base implementation on behavior of browser (remembering history), might or might not available user. if want design useful interface, should provide access history yourself, or use features autocomlete

vbscript - .vbs to sort a list of users favourites -

This summary is not available. Please click here to view the post.

android - Want to create a file, a directory created instead ! -

i'm using code create file in root of sdcard, however, have directory created instead of "filedir+filename" ! file file = new file(sdcard.getabsolutepath(), filedir+filename); if (!file.mkdirs()) { log.d("error", "create dir in sdcard failed"); return; } outputstream out = new fileoutputstream(file); .............................. thank help. file.mkdirs() creates directory , not file [ref: http://download.oracle.com/javase/1.4.2/docs/api/java/io/file.html#mkdir() . code creates directory. should use code this. string destination = currentdir + "test.txt"; file filecon = new file(destination); if( ! filecon.exists() ){ filecon.createnewfile(); } alternatively try this, string destination = currentdir + "test.txt"; // open output stream fileoutputstream fout = new fileoutputstream(destination); f...

php - How to use compiled gettext .mo files without the gettext module? -

i'm trying find way use gettext , friends without depending on official gettext module , i've found not installed everywhere , yields different results depending on os , server configuration. i make library can auto load po file, change languages , translate text between {t} , {/t} in view, posted here in case 1 want use instead calling gettext function in view: http://www.chuongduong.net/page/15/codeigniter-gettext-with-smarty-or-parser-template-without-php-code-in-view.html the view code might be: <html> <head> <title>{blog_title}</title> </head> <body> <h3>{blog_heading}</h3> {blog_entries} <h5>{t}title is{/t} {title}</h5> <p>{t 1="<b>" 2="</b>"}click here %1to see%2 me{/t}{body}</p> <p>{t 1="{id}" 2="author"}the id is: %1 wrote %2{/t}</p> <p>{t 1="<a href=\"link here\">" 2="<...

php - Google Ads not showing in div? -

hey, don't understand why, have ad box below lightbulb on page (view source) , don't see anything. understand google take 10 minutes process ads , show things, have tried day using multiple test ad boxes nothing seems work. tl;dr- dont know how use javascript , can't figure out whats wrong on ads it should in information box below lightbulb. http://atomicpool.com/play.php?id=1 anyone have ideas? about javascript...here have copy-paste ads code given google..... , run properly... , have configure size of div google ads require...

iphone - My iOS App Works Well In The Simulator, But Not In A Real Device? -

so first app making jailbroken devices. i must it's not finished yet, believe it's habit test incomplete apps in real device every , while developing app. since app jailbroken devices, have fake sign app , that. the thing is, app has plist 2 entries: bool "hasbeenlaunchedbefore" , string "password". app changes true hasbeenlaunchedbefore when app finished configuring, when app loads gets different view. password straightforward: stores password user. i think plist file not getting modified when launch app in device, because well, when app has never launched before, configuration wizard. everytime close app keep getting config wizard, means hasbeenlaunchedbefore not changed true supposed be. also, passwords never match, means password doesn't modified either. everything works fine in ios simulator, not in idevice. me bit this? permissions issue? has really, left me no words or ideas fix it. guessing put plist in /documents, have no idea of how...

php - How To Read OPDS Catalog (ex : http://feedbooks.com/catalog.atom) -

i'm new in php. want read opds catalog (ex : http://feedbooks.com/catalog.atom ) , store catalogs json file. could suggest me how it, or point me usefull article/source code it? open url (allow_url_fopen must switched on that, otherwise take @ curl ) $content = file_get_contents('http://feedbooks.com/catalog.atom'); $xml = new simplexmlelement($xmlstr); print_r($xml); the print_r show object received, alter object , create json via json_encode($xml), , write file. alternatively can use yahoo pipe read feed , output json. $json = file_get_contents('http://pipes.yahoo.com/pipes/pipe.run?_id=29ec5982a8bede87d83a402f7f8ac0ec&_render=json'); that's actual pipe: http://pipes.yahoo.com/pipes/pipe.run?_id=29ec5982a8bede87d83a402f7f8ac0ec&_render=json

for and foreach statements in D -

besides syntactic differences, 2 inherently same? both of them implemented in core language? or foreach part of standard library? , far performance, make difference if choose 1 on other? you should use foreach if possible. foreach iterate on practically anything (even metadata, compile-time data types); for can't. foreach (type; typetuple!(int, long, short)) { pragma(msg, type); } but can't for loop. foreach can used perform actions @ compile-time (extension of above); example, if have piece of code repeats 10 times, can say: template iota(size_t a, size_t b) //all integers in range [a, b) { static if (a < b) { alias typetuple!(a, iota!(a + 1, b)) iota; } else { alias typetuple!() iota; } } foreach (i; iota!(0, 10)) { int[i] arr; } //not possible 'for' and occur @ compile-time , i treated constant . (this doesn't work for .) foreach can overloaded opapply , range constructs, for can't. very handy when iterating...

content management system - Only Show Comment in Wordpress -

i looking way show comments posted in wordpress. my main goal turn wordpress cms site fmylife.com. basic principle allowing post anonymously (without having post comment on), , comments need moderated admin. if there easier solution doing this, i'm open hearing well. thing don't want fmyscript clone. i've tried , don't it. any advice appreciated. thanks. adam. why don't try buddypress plugin wherein users can register , post. disable other components except activity feed , make homepage static activity feed page (configurable in settings).

javascript - Magnify search box similar to that on Apple.com -

if go http://apple.com , click in search box, you'll notice grows/magnifies onfocus , , onblur collapses it's original state. i'm wondering if there's jquery plugin or similar job easily. i don't want use js that's on apple website since it's not cross browser. don't have time roll own. if there's nothing prebuilt, that's ok, if knows of pre-made, i'd grateful. search box @ apple.com without js: http://www.kvadracom.com/en-projects-blog.html#1

Jquery append/html div not functioning, wrong css? -

i have html code snippet below, not display in div "itemcontent" unless type in. can debug , can tell appropriate data getting passed "sucessfil", nothing shows on div appends! there wrong css? <script type="text/javascript"> function sucessfil(data) { $('#itemcontent').append(data); } function displayitem(param) { $.ajax({ url: 'itemviewer.php?id='+param, success:sucessfil }); } function showiteminviewer(param) { el = document.getelementbyid("itemviewer"); el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; if(param!='') { displayitem(param); } } </script> <style> #itemviewer { visibility: hidden; position: absolute; left: 20%; top: 5px; width: 500px; height: 500px; text-align: center; z-index: 1000; background-color:#666 } ...

javascript - chrome.extension.sendRequest() asynchronous problem -

i building chrome extension involves changing default css of site, code skeleton follow chrome.extension.sendrequest({ options: "foo" }, function(response) { if(response=='on'){ var d = document.documentelement; var css_chunk = document.createelement("style"); css_chunk.type = "text/css"; css_chunk.innertext = "img{ visibility:hidden !important; display:none !important; } "; d.insertbefore(css_chunk, null); } }); i found it's more ajax call , therefore css not alway change before original website loaded. problem sometime "winks" short time before images disappear. there option make call synchronous? i tied add sleep(n) outside after call , works. function optional user, i.e. if function off, page sleep(n) not reasonable. why not use stylebot ? either that, or write greasemonkey script, , save trouble of writing full extension.

c++ - return NULL value -

snippets of framebufferd3d11.h namespace dx11 { ... class framebuffermanager : public framebuffermanagerbase { public: ... private: ... static struct efb { ... std::unique_ptr<d3dtexture2d> resolved_color_tex; std::unique_ptr<d3dtexture2d> resolved_depth_tex; } m_efb; }; } //namespace snippets of framebufferd3d11.cpp namespace dx11 { ... framebuffermanager::efb framebuffermanager::m_efb; ... framebuffermanager::framebuffermanager() { ... m_efb.resolved_color_tex = null; m_efb.resolved_depth_tex = null; } } //namespace if compile icc, problem null assign value, null defined 0. how solve problem this? your code correct. of following should work: m_efb.resolved_color_tex = 0; m_efb.resolved_color_tex = null; m_efb.resolved_color_tex = nullptr; a null pointer constant (like 0 or null ) implicitly convertible nullptr_t , unique_ptr has assignment operator takes nullptr_t . if version of icc using not yet s...

python - SQLAlchemy: print the actual query -

i'd able print out valid sql application, including values, rather bind parameters, it's not obvious how in sqlalchemy (by design, i'm sure). has solved problem in general way? in vast majority of cases, "stringification" of sqlalchemy statement or query simple as: print str(statement) this applies both orm query select() or other statement. note : following detailed answer being maintained on sqlalchemy documentation . to statement compiled specific dialect or engine, if statement not bound 1 can pass in compile() : print statement.compile(someengine) or without engine: from sqlalchemy.dialects import postgresql print statement.compile(dialect=postgresql.dialect()) when given orm query object, in order @ compile() method need access .statement accessor first: statement = query.statement print statement.compile(someengine) with regards original stipulation bound parameters "inlined" final string, challenge here sql...

alfresco - curl query to check out a document using the CMIS protocol -

i trying checkout document using rest-based cmis protocol , error server ( alfresco ). am misusing curl? or missing in request? curl --user admin:admin -f "atomentry=@atomentry.xml" http://localhost:8080/alfresco/service/cmis/checkedout with atomentry.xml being: <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"> <cmisra:object> <cmis:properties> <cmis:propertyid propertydefinitionid="cmis:objectid"> <cmis:value>workspace://spacesstore/3e13d089-39cf-48a4-b0b6-773b602bbcc0</cmis:value> </cmis:propertyid> </cmis:properties> </cmisra:object> </entry> i wrong both curl , xml... here worked: curl -x post -uadmin:admin "http://localhost:8080/alfresco/s/cmis/checkedout"...

Android On Touch -

i have been trying make program draw circles touch screen no luck, can please tell me how can this? or tutorial shows me how... keep getting errors in code import android.content.context; import android.content.intent; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.path; import android.text.format.time; import android.util.attributeset; import android.view.motionevent; import android.view.view; import java.lang.math; public class gameview extends view{ private final float x; private final float y; private final int r; private final paint mpaint = new paint(paint.anti_alias_flag); public gameview(context context, float x, float y, int r) { super(context); setfocusable(true); mpaint.setcolor(0xffff0000); this.x = x; this.y = y; this.r = r; } @override protected void ondraw(c...

javascript - how to keep adding files to files array with multiple button clicks -

basically, have input element of type file: <form method="post" action="upload-page.php" enctype="multipart/form-data"> <input name="filestoupload[]" id="filestoupload" type="file" multiple="" /> </form> now each click on file button, files array keeps track of files selected current click, how make keeps track of files every click? you must add more input elements page.

java me - SMS sent to shortcode from J2ME doesn't get reply from service. Why? -

i'm building j2me app nokia series 40 devices has feature of sending smss predefined shrotcodes. on networks: 1) user uses app, activates send sms shortcode feature, sms sent , service replies "welcome" service messages. on other networks (same phone different sim): 1) user uses app, activates send sms shortcode feature, sms sent , service not reply "welcome" service messages. 2) when sending same sms by-hand messaging application, service reply "welcome" service messages why happen? thanks. try, using different textboxes each, mine did using unique interfaces each , storing shortcode adresses in arrays traversing them worked. regards, sam