Posts

Showing posts from July, 2010

c - how to count cycles? -

i'm trying find find relative merits of 2 small functions in c. 1 adds loop, 1 adds explicit variables. functions irrelevant themselves, i'd teach me how count cycles compare algorithms. f1 take 10 cycles, while f2 take 8. that's kind of reasoning do. no performance measurements (e.g. gprof experiments) @ point, old instruction counting. is there way this? there tools? documentation? i'm writing c, compiling gcc on x86 architecture. http://icl.cs.utk.edu/papi/ papi_get_real_cyc(3) - return total number of cycles since arbitrary starting point

javascript - Is there a screencast/tutorial site for CoffeeScript? -

i'm new coffeescript, looking forward writing javascript code in more akin ruby. what 2-3 resources can recommended tutorials or screencasts , running coffeescript? [ update : have book coming out pragprog, coffeescript: accelerated javascript development . also, latest version of coffeescript 1.1.0, though introduced few changes; mainly, it's bugfix release.] the official documentation @ http://coffeescript.org up-to-date place you're going find. right now, latest release of coffeescript 1.0.1. there lot of changes in 1.0. orbit linked 2 other resources nice dated. tongue-in-cheek 7 reasons gonna hate it presentation way when assignment done using : instead of = . nettuts+ tutorial written when latest release 0.9.6 and, think , doesn't touch on that's changed since (such classes). so, might want go through nettuts+ tutorial, official docs, start reading real-world source code. see http://github.com/jashkenas/coffee-script/wiki/in-the-wild ...

.net - ASP.net & SQL 2008: What is the best way to store multiple values for lists when values are of varying amounts and not repeated throughout rows? -

i’m creating web app school using asp.net , sql 2008. have page users view course descriptions. part of course description include list of topics covered. topics different every course , there different amount of topics every course. data bind topics ordered list in repeater. need provide search functionality on web app. elegant , normalized way of storing topics in sql? want avoid writing vb or using client side scripting. i’ve considered: •entering values separated commas in field named topics. don’t want have programmatically separate values repeater , i’m not sure if elegant solution db. •using xml data type field named topics. think may not necessary , more complex needs be. •creating separate table each course pk , field named topics. don’t want have create tables! not trying lazy efficient! when designing databases helps work core objects/entities , see how relate each other. try , have normalized tables, never de-normalize until need to. in above exam...

Escaping Bash wildcards when executing python script from bash script? -

i've got bash script defines array of file globs containing * wildcards. the script executes python script passing each of these globs parameter. on command line can quote entire glob, , python happy it. in bash script, if quote globs, python's os.path.realpath seems confused quotes - passed in script itself. e.g. bash script: backup_paths=("/root/backups/db-dump-*" "/root/backups/*_backup.tar.bz2") path in "${backup_paths[@]}" /usr/local/bin/python2.7 /usr/local/bin/clean.py \'$path\' $max_files done python: os.path.realpath(path) # results in like: /usr/local/bin'/root/backups/db-dump-*' how can make them play together? thanks instead of \'$path\' , use "$path" . double-quotes allow contents of variable $path substituted, prevent wildcard expansion , ensure path passed single argument.

iphone - How do I set the click method on a TTButton? -

i'm using ttcatalog , creating ttbutton using following: ttbutton *button = [ttbutton buttonwithstyle:@"toolbarbutton:" title:@"click button"]; i tried adding target , action that, doesn't work. how use it? you missing "[". ttbutton *button = [ttbutton buttonwithstyle:@"toolbarbutton:" title:@"click button"]; [button setuserinteractionenabled:yes]; [button addtarget:self action:@selector(buttonpressed:event:) forcontrolevents:uicontroleventtouchupinside]; then set button properties, use target/action set event handler. (the ttbutton uievent subclass.) good luck!

asp.net mvc - What is the difference between Html.Label and Html.Display? -

what difference between html.label , html.display ? html.label() renders html markup <label /> can used model entity's attrubute. for eg, <%= html.label("full name", model.fullname) %> would render <label for="fullname">full name </label> html.display() on other hand renders html markup entire entity based on specified templates. eg. if have person entity multiple attributes, define template markup how render person , html.display() uses template render person objects across views. phil haack has excellent post on display templates.

UTF-8 encoding in Spring MVC, problem with FORMs -

i have in web.xml <filter> <filter-name>encoding-filter</filter-name> <filter-class> org.springframework.web.filter.characterencodingfilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> <init-param> <param-name>forceencoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding-filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> and @ top of file.jsp have this: <%@ page pageencoding="utf-8" contenttype="text/html; charset=utf-8" %> in <head> this: <meta http-equiv="content-type" content="text/html; charset=utf-...

java - Is there a way to pass hidden values in Wicket? -

as described in wicket redirect: how pass on parameters , keeps urls "pretty"? , there variety of options passing parameters in wicket. however, of methods listed on page use url transmit parameter information. is there class that's similar the pageparameters class except hides information it's transmitting? don't care bookmarkability, care urls like http://www.example.com/example.html?uniqueid=309308&supersecretvalue=42 installing custom url coding strategy way. note though wicket doesn't expose internal state anyway, you'll need bookmarkable pages.

Navigating though the surface of a hypersphere in OpenGL -

maybe fits in math.stackexchange.com, since programing in opengl, shall ask here. i had idea of spaceship game world confined in surface of 4-d hypersphere (also called 3-sphere). thus, in seeing inside, 3-d world, navigating in every direction, never leave limited volume of 3-sphere. to represent 3-shpere "flat" 3-d space, use stereographic projection, simple implement glsl shader, need divide input vector 1 minus w coordinate. to represent vertices of objects using normalized 4d vectors, such x²+y²+z²+w²=1, keeping them inside 3-sphere. the first problem solve rotation. figured out ordinary 3d rotation matrices suffice rotate world around viewer in 3d projection, since not mess w coordinate (pretty rotating sphere around z-axis rotate stereographic projection). then figured out rotating along w-axis equivalent of translation inside 3d projection (just not commutative, ordinary 3d translations on "flat" spaces), translate along axis using simple aroun...

symfony1 - Outputting required field indicator for symfony forms -

i have few forms configured in symfony. 1 things need have asterisk (*) or other indicator next fields required. fields set required int form framework, , return "this field required" error when form submitted, want indicator before form submitted. if there way without overriding labels each field manually? here's automatic solution found in kris wallsmith's blog : lib/formatter/requiredlabelsformattertable.class.php, add 'required' class labels of required fields <?php class requiredlabelsformattertable extends sfwidgetformschemaformattertable { protected $requiredlabelclass = 'required'; public function generatelabel($name, $attributes = array()) { // loop find "required_fields" option $widget = $this->widgetschema; { $requiredfields = (array) $widget->getoption('required_fields'); } while ($widget = $widget->getparent()); // add class (non-destructively) if field...

c++ - boost::asio server multi-process -

i make simple multi process (not thread) server. i've seen iterative example in handles 1 request @ time. instead need handle more requests(more on less 10) @ same time. in classic c , c++ examples, i've seen server designed following: int listensd, connsd; // listening socket , conection socket pid_t pid; //process id listensd=socket(....); bind(listensd,...); listen(listensd,...); for(;;) { connsd=accept(listensd,...); if((pid=fork())==0) //child process { close(listensd); //close listen socket do_it(connsd); //serve request close(connsd); //close connection socket exit(0); } close(connsd); //the parent closes connection socket } is possible boost? don't know how obtain 2 different socket, because in boost function ( listen , bind , accept , etc.) return void. yes, it's possible use boost.asio fork process each connection. see bsd socket api boost.asio documentation mappings bind , li...

error handling - When using yacc, how do you tell yyparse() that you want to stop parsing? -

still learning yacc , flex, , ran across scenario how-to's , tutorials have not cover. trying parse file, , i'm going along, i'm doing secondary error checking in code i've placed in parser.y file. when come across lexicographically correct (that is, parse matches properly) logically incorrect (unexpected value or inappropriate value), how yyparse exit? also, can have return error code me can check in calling code? /* sample */ my_file_format: header body_lines footer ; header: obrace int cbrace | obrace string cbrace { if ( strcmp ( $1, "contrived_example" ) != 0 ) { /* want exit here */ } } ; /* etc ... */ i realize in example can "contrived_example" using rule, point in if -block -- can tell yyparse want stop parsing here? you can use macros yyerror or yyabort depending on want. yyabort causes yyparse return failure, while yyerror causes act if there's been error , try recover (which return failure if...

Getting the HTML source through the WebBrowser control in C# -

i tried html source in following way: webbrowser1.document.body.outerhtml; but not work. example, if original html source : <html> <body> <div> <ul> <li> <h3> manufacturer</h3> </li> <li><a href="/4566-6501_7-0.html? filter=1000036_3808675_100021_10194772_">sony </a>(44)</li> <li><a href="/4566-6501_7-0.html? filter=1000036_108496_100021_10194772_">nikon </a>(19)</li> <li><a href="/4566-6501_7-0.html? filter=1000036_3808726_100021_10194772_">panasonic </a>(37)</li> <li><a href="/4566-6501_7-0.html? filter=1000036_3808769_100021_10194772_">canon </a>(29)</li> <li><a href="/4566-6501_7-0.html? filter=1000036_2913388_100021_10194772_">olympus...

multithreading - Simple LOCK and ThreadPoolQuestion for WP7 (C#) -

funny, going test tombstoning , concurrency, , during simple setup, thought heck, worth trouble. now, after 45 minutes of setting stupid test classes, ran first error don't understand. seems need little bit more practice in lists, locks , threads. know why throws illegal operation exception (see attached code). for 1 likes f5 experience better, here complete solution (300kb) http://www.filesavr.com/txxxfve40gtjk43 do not open views, might crash vs2010. , need wp7 tools, sorry, though pretty sure example work (not work) on pure c# also. [edit] update link, working (with old code) , found first bug, comment. this works: private void inconewithlock() { lock (counterlistone) { inclistone(); } } private void inclistone() { if (counterlistone == null) { log("counterlistone == null"); return; } var c = 0; var oldlist = counterlistone.tolis...

visual studio - How to get ASP.NET website precompilation to exclude a certain folder -

the several different environments (e.g. live, demo etc) of web app differentiated config settings in folder called environmentconfiguration. whenever update 1 of sites, delete environmentconfiguration folder precompiled site before copying website files on (i.e. in order environmentconfiguration folder in deployment location not replaced). just save mistakes, there way can visual studio not produce environmentconfiguration folder when precompiles site me? you try couple of things. 1) right click on folder in solution , select exclude project. 2) @ each of files in folder , set buildaction property 'none' rather 'content'

mysql - Sql query that selects all inactive users -

i have query implement. i have 2 tables: user , login_logs table. the user table looks this: id || first_name || last_name ||           email                 || username || activated || suspended 1 ||       john       ||      dan       ||      john@whatever       ||      john1    ||     1      ||       0       || 2 ||       mike       ||      hutt       ||  ...

android - Problems trying to build PocketSphinxAndroidDemo using NDK -

i trying compile pocketsphinxandroiddemo, provides example implementation of cmu pocketsphinx speech recognizer on android. first received error similar discussion here . after executing ndk-build, got error: gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver gdbsetup : libs/armeabi/gdb.setup compile thumb : pocketsphinx_jni <= pocketsphinx_wrap.c /home/nick/workspace/android/pocketsphinxdemo/jni/pocketsphinx_wrap.c:761:28: error: sphinxbase/err.h: no such file or directory /home/nick/workspace/android/pocketsphinxdemo/jni/pocketsphinx_wrap.c: in function 'java_edu_cmu_pocketsphinx_pocketsphinxjni_decoder_1processraw_1_1swig_10': /home/nick/workspace/android/pocketsphinxdemo/jni/pocketsphinx_wrap.c:1441: warning: assignment discards qualifiers pointer target type make: *** [/home/nick/workspace/android/pocketsphinxdemo/obj/local/armeabi/objs-debug/pocketsphinx_jni/pocketsphinx_wrap.o] error 1 i tried recommendation of rebuilding sphinxbase ...

c# - foreach loop question -

is there other shorter/more efficient way check , see if last item in listbox? main goal here add selected items label, , add comma after every 1 last one. suggestions? int sc = 0; list<string> interestitems = new list<string>(); foreach (listitem siitem in listbox1.items) { if (siitem.selected == true) { interestitems.add(siitem.value.tostring()); } } foreach (string inteitem in interestitems) { label1.text += inteitem; sc++; if (sc < interestitems.count) { label1.text += ","; } } instead of second loop use: label1.text = string.join("," , interestitems); p.s. if you're using .net 3.5, need pass array of strings string.join() , : label1.text = string.join("," , interestitems.toarray()); edit: if want avoid looping do...

Visual Studio 2010/WinForm/Snap-To Lines/Control Visibility -

every often, lose pink , blue snap-to lines when editing winform in vs2010. have tried rebooting workstation, closing unnecessary open applications, checking , unchecking various options in environment>general>visual experience, still happens. makes editing winforms difficult when can't see control dragging around , dragging to. checked googles , didn't locate definitive answer. else have solution this? i had workstation reimaged , reinstalled vs2010 + sp1, things seem working again. have not seen problem couple days.

iphone - Trouble with UITableViewCellAccessory (Checkmark/None toggle) -

edit don't feel idiot. until now, haven't been paying attention whether or not cell gets checkmark. somehow, had uitableviewcellaccessorycheckmark , uitableviewcellaccessorynone flipped, turning off when wanted on , turning on when wanted off. reading code debugging... /edit below code having trouble with. tableview:didselectrowatindexpath: if (i.need == 0) { // item not needed - hide (#) , turn on checkmark i.need = 1; cell.textlabel.text = [nsstring stringwithformat:@"%@", i.name]; cell.accessorytype = uitableviewcellaccessorynone; } else if (i.need < 0) { // item not needed - hide (#) , turn on checkmark i.need = -i.need; cell.textlabel.text = [nsstring stringwithformat:@"%@", i.name]; cell.accessorytype = uitableviewcellaccessorynone; } else { // item not needed - show (#) , turn off checkmark i.need = -i.need; cell.textlabel.text = [nsstring stringwithformat:@"%@ (%d)", i.name, -i.need]; cell...

android - Default activity -

i reading tutorial , default activity class extends another, , has overriden method. how application work since doesn't else? confused! the parent class activity handles you.

Handling xml namespaces in jQuery -

i have parse xml stream contains range of namespaces this: <zs:searchretrieveresponse xmlns="http://www.directoryofchoice.co.uk" xmlns:zs="http://www.loc.gov/zing/srw/" xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.directoryofchoice.co.uk schema/content_node.xsd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:lom="http://ltsc.ieee.org/xsd/lom"> <zs:version>1.1</zs:version> <zs:numberofrecords>1066</zs:numberofrecords> <zs:records> <zs:record> <zs:recordschema>info:srw/schema/1/dc-v1.1</zs:recordschema> <zs:recordpacking>xml</zs:recordpacking> <zs:recorddata> <srw_dc:dc xmlns:srw_dc="info:srw/schema/1/dc-schema"> <dc:title...

filesystems - How to get a meaningful message for failed calls to Java File objects (mkdir, rename, delete) -

while using file.mkdir , , friends notice don't throw exceptions on failure! thankfully findbugs pointed out , code @ least checks return value still see no way meaningful information why call fails! how find out why calls these file methods fail? there alternative or library handles this? i've done searches here on , google , found surprising little info on topic. [update] i've given vfs try , exception don't have anymore useful information. example trying move directory had been deleted resulted in could not rename file "d:\path\to\filea" "file:///d:/path/do/fileb". no mention filea no longer existed. [update] business requirements limit me jdk 1.6 solutions only, jdk 1.7 out you call native methods, , proper error codes way. example, c function mkdir has error codes eexist , enospc. can use jna access these native functions easily. if supporting *nix , windows need create 2 versions of code. for example of jna mkdir ...

datetime - How to get the current date/time in Java -

what's best way current date/time? it depends on form of date / time want: if want date / time single numeric value, system.currenttimemillis() gives that, expressed number of milliseconds after unix epoch (as java long ). value delta utc time-point, , independent of local time-zone ... assuming system clock has been set correctly. if want date / time in form allows access components (year, month, etc) numerically, use 1 of following: new date() gives date object initialized current date / time. problem date api methods flawed ... , deprecated. calendar.getinstance() gives calendar object initialized current date / time, using default locale , timezone . other overloads allow use specific locale and/or timezone . calendar works ... apis still cumbersome. new org.joda.time.datetime() gives joda-time object initialized current date / time, using default time zone , chronology. there lots of other joda alternatives ... many describe here. in java ...

Does Adding a Column Lock a Table in SQL Server 2008? -

i want run following on table of 12 million records. alter table t1 add c1 int null; alter table t2 add c2 bit not null default(0); i've done in staging , timing seemed fine, before in production, wanted know how locking works on table during new column creation (especially when default value specified). so, know? whole table locked, or rows locked 1 one during default value insertion? or different altogether happen? yes, lock table. a table, whole, has single schema (set of columns, associated types). so, at minimum , schema lock required update definition of table. try think how things work contrariwise - if each row updated individually, how parallel queries work (especially if involved new columns)? and default values useful during insert , ddl statements - if specify new default 10,000,000 rows, default value has applied of rows.

email - php extracting text/plain from mail body -

this content of 1 mail read imap_php library. extract content-type text/plain; charset=iso-8859-1 text: {"data":"10/10/2011","regione":"pt","provincia":"pistoia","nome":"nome","tel":"12345","email":"mymailaddress","richiesta":"qualcosa"} if use imap_body($mbox, $result[0]) have returned text in box. if use imap_fetchbody($mbox,$email_number,2); have returned text/html body message don't want. --20cf301e2f27a218c204a88578aa content-type: text/plain; charset=iso-8859-1 {"data":"10/10/2011","regione":"pt","provincia":"pistoia","nome":"nome","tel":"12345","email":"mymailaddress","richiesta":"qualcosa"} --20cf301e2f27a218c204a88578aa content-type: text/html; charset=iso-8859-1 content...

Simple array question in PHP -

not sure if there built in function this, thought ask before waste time of writing one. lets have array: array ( ['first_name'] => john ['last_name'] => doe ['ssn1'] => 123 ['ssn2'] => 45 ['ssn3'] => 6789 ) how can create new key ['ssn'] combine values of other three, result in following: array ( ['first_name'] => john ['last_name'] => doe ['ssn'] => 123456789 ) it comes in separated because there 3 separate inputs such [   ]-[  ]-[    ] keep user screwing up. so, effective/elegant way of doing this? thanks! edit looks came same simple solution. have give first. everyone! assuming data comes web form, use input naming convention advantage. name elements in order first_name, last_name, ssn[1], ssn[2], ssn[3]. $_request automatically assign 3 elements structured array. <input type=...

ruby on rails - Automatically run tests on deploy with capistrano -

is there way have capistrano run unit tests on rails app when run cap deploy , , fail if don't pass? know can , should done deployer, i'd love automatic. ideas appreciated. thanks in advance! edit: ended using this solution. this capistrano task run unit tests on server being deployed, in production mode: desc "run full tests on deployed app." task :run_tests run "cd #{release_path} && rails_env=production rake && cat /dev/null > log/test.log" end found solution here: http://marklunds.com/articles/one/338 :d

Javascript to get entire contents of frame -

i want have script rewrite simple text-file opened source of frame -- 1 lacks html. tried frames[1].document.innerhtml without success. tried .outerhtml , got nothing. can either (a) frame entire contents of frame manipulate using script , .write() result frame? or (b) add <html> , <div> tags, wrapping document can inner html , manipulate that? appreciated. as long main page , iframe page follow same origin policy , can access frame's html this: window.frames['iframe01'].document.body.innerhtml or window.frames['iframe01'].contentdocument.documentelement.innerhtml to write: window.frames['iframe01'].contentdocument.write("[content here]");

svn - Substitute keyword value ONLY in subversion keyword substitution -

in subversion keyword substitution, can that $author$ replace $author: hkalex@gmail.com $ however, how can substitution value only . what want $author$ replace hkalex@gmail.com . this not possible using subversion alone. substitution done match not historic cvs behavior, make easy , obvious see inserted text done through keyword expansion , not inserted manually. if you're trying part of cleaning files for, say, public release, you'll want build script perform replacement you. bit of grep , sed should trick.

Call C++ programs from C# /WPF -

can point me full example of how run compiled c++ programs (executables) c#. thanks in advance. i think want that: process myprocess = new process(); try { myprocess.startinfo.useshellexecute = false; // can start process; helloworld do-nothing example. myprocess.startinfo.filename = "c:\\helloworld.exe"; myprocess.startinfo.createnowindow = true; myprocess.start(); // code assumes process starting terminate itself. // given is started without window cannot terminate // on desktop, must terminate or can programmatically // application using kill method. } catch (exception e) { console.writeline(e.message); }

email - Is there a sendmail library for PyQt4? -

i have bunch of qstring() inside contains bunch of non-english characters (chinese). i'd send qstring() email using pyqt4. is there such , option? sure, use standard library. here examples: http://docs.python.org/library/email-examples.html regarding chinese characters, see: how send non-english word (chinese) email using django

How to remove trailing zeros using Sybase SQL? -

possible duplicate: remove trailing zeros decimal in sql server i have column decimal(9,6) i.e. supports values 999,123456. but when insert data 123,4567 becomes 123,456700 how remove zeros in sybase sql? using this didn't work! do in application/presentation layer. sql not place cosmetic changes dropping trailing zeroes.

html - passing a long xml string to href -

i trying pass long xml string through href jsp page. when clicking on link displaying blank page. link should take me spring controller isn't going there. there limit on length of param being passed in url. , if how can pass web page. even though standards don't dictate there limit length of uri differs per browser general consensus 2048 bytes. should post xml data.

.net - Intelligencia UrlRewriter with RegEx is not working -

i have following rewrite rule: <rewrite url="^/membership/(.+)/(.+)/(.+)/(.+)" to="/membership/index.aspx?parentf=$3&amp;f=$4"/> which expecting should work url: /membership/benefits/member-groups/sub-groups/motorcycle-live.aspx however, in page rewritten url maps (/membership/index.aspx), retrieving filename ("f" in querystring) , parentfilename ("parentf" in querystring) use in query current page information. value of filename in case sub-groups,motorcycle-live.aspx (when expecting motorcycle-live.aspx ) value of 'parentfilename' in case member-groups (when expecting 'sub-groups') i have few other rewrite rules lower levels, example: <rewrite url="^/membership/(.+)" to="/membership/index.aspx?f=$1"/> <rewrite url="^/membership/(.+)/(.+)" to="/membership/index.aspx?parentf=$1&amp;f=$2"/> <rewrite url="^/membership/(.+)/(.+)/(.+...

memory management - Reading a large input files(10gb) through java program -

i working 2 large input files of order of 5gb each.. output of hadoop map reduce, not able dependency calculations in map reduce, switching optimized loop final calculations( see previous question on map reduce design recursive calculations using mapreduce i have suggestion on reading such huge files in java , doing basic operations, writing out data of order of around 5gb.. i appreciate if files have properties described, i.e. 100 integer values per key , 10gb each, talking large number of keys, more can feasibly fit memory. if can order files before processing, example using os sort utility or mapreduce job single reducer, can read 2 files simultaneously, processing , output result without keeping data in memory.

Link imports by name (C++/Visual Studio) -

i have few nt imports want use in program, problem unable use them without going though lengthly process of downloading , setting wdk use 2 functions. prefer not use getmodulehandle , getprocaddress. i know in vb6 can manually define imported functions dlls this: private declare function ntfunction lib "ntdll.dll" (function arguments) type is there similar can c++ in visual studio without having headers/libs? you don't want use getprocaddress , that's vb6 declare function (and .net p/invoke) does. you need complete prototype, can recreate enough of header file documentation. the import library little more difficult, there tools create import libraries .dll. if create .def file, can use lib.exe tool comes visual c++ (and available free download part of windows sdk), see building import library here more information . mingw comes tool automating creation of .def file: http://www.mingw.org/wiki/createimportlibraries (the import library cre...

issue with zend form element displaying -

please check code below, problem no form element displayed in test action not able locate test.php-->form class class application_form_test extends zend_form { public $t_fileup; public $t_submit; /*function init * initialise elements * */ public function _init() { $this->t_fileup=new zend_form_element_text('image'); //$this->t_fileup->setdestination(uploads); $this->t_submit=new zend_form_element_submit('add'); } /*function generate form specific function * */ public function generateform() { return $this->addelements(array($this->t_fileup,$this->t_submit)); } } testaction public function testaction() { $objform=new application_form_test(); $forms=$objform->generateform(); $this->view->form=$forms; } test.phtml <?php //e...

c# - Dynamic tables from fluent nHibernate -

i in prototype phaze of large system developing. using nhibernate , fluent on top of that. have huge number of classes in core project. in main web application have list countries, currencies , such, , have been looking ways of doing that. i datatables plugin jquery, , use that. and make things dynamic possible, select list of country , currency classes in 1 usercontrol. but having problems ... here have ideas? it sounds case dto, , named query nhibernate perspective. read more here: http://gustavoringel.blogspot.com/2009/02/creating-dto-in-nhibernate-hql-using.html .

java - Returning an empty array -

question this may silly question, there difference between foo() , bar() ? code private static file[] foo() { return collections.emptylist().toarray(new file[0]); } private static file[] bar() { return new file[0]; } i'm trying think of best way return empty array, rather null . a different way return empty array use constant empty arrays of given type same. private static final file[] no_files = {}; private static file[] bar(){ return no_files; }

Can someone elaborate on these basic concepts of hosting via Amazon Web Services? -

i read on amazon documentations, i'm still confused or should overwhelmed different terms. i'm coming traditional web hosting environment concept understand how storage have , how bandwidth i'm allowed. here understand far amazon , questions lot of it. ec2 - assume instances can set webserver (iis) , run .net application? or setup me? ebs - database? if not, database server? database server (sql server 2005 or 2008) installed? snapshot requests? , snapshot put request? s3 - used for? thought ebs storage, confused here. why need s3? elastic load balancing - thought load balancing way alleviate burdens on web servers. how work amazon? mean "elastic" load balancing? data transfer between region - mean? , how control region data transfers , from? my requirements following i need iis webserver run page i need database server i need location store files (can on same "server" #1)? i need database , file servers recoverable. ...

javascript - Make a form submit() behave like location.replace() -

in short: there's web page needs submitted when user loads page. there reason it, long story. would possible make form post submit() behave location.replace()? no history trace. thanks. long story: in cms, have 1 page each product. products listed on section pages, user invited choose product : small $10 buy medium $20 buy large $30 buy clicking on buy send user payment page, off-site. the product details come cms page, defined specific fields price, product id, etc. product detailes rendered form. i don't want show independent, permalink product pages, ever. but, being cms, products listed on section pages , whatnot, , user may end choosing products clicking on link instead of full rendered page form. if end on product page, want them redirected purchase page. of course don't want keep page in history, same reasons location.replace() invented: avoid button of eternal redirection. just ajax post followed location.replace . ajax post ...

c# - Does Java make distinction between value type and reference type -

c# makes distinction of two. java same or differently? in java, objects , enums reference types, , primitives value types. distinction between 2 same in c# respect copy semantics, cannot define new value type in java.

objective c - How to call function/method in parent view controller -

i have myviewcontroller has uinavigationcontroller subview , uinavigatiocontroller has customview popped on stack. want in customview call method in myviewcontroller.. tried this: uinavigationcontroller *main = (uinavigationcontroller*)[self parentviewcontroller]; myviewcontroller *parentcontainer = (myviewcontroller*)[main parentviewcontroller]; [parentcontainer myparentmethod]; this code not correct. the parentviewcontroller property works navigation controller, tab bar controller, or in modal presentation relationship. although myviewcontroller object has view of uinavigationcontroller object subview, doesn't mean myviewcontroller parentviewcontroller of uinavigationcontroller object. if have keep design , need access myviewcontroller object customview object, best way of doing let customview object have weak reference myviewcontroller object (like delegate properties).

java - not able to parse string into date using jexcel api -

i faced problem faced few days ago. have parse file , convert string date. had done same csv file few days ago. however, new file giving error: java.text.parseexception: unparseable date: ""3/4/2011"" why string getting printed 2 "" around it? think root cause of problem. posting code below . please note same code works file date printed 3/4/2011 no "" around it. writableworkbook wbwrite=null; writablesheet sheet=null; label lwrite=null; bufferedreader br=null; number n=null; string strfile="quotes.csv"; string strline = ""; string st[]; string delimiter="[,]"; int linenumber = 0, tokennumber = 0; int length=0; int counter=0; calendar cal = calendar.getinstance(); datetime datecell=null; if(strfile.equals("quotes.csv")) { system.out.print("in loop if"); try { file file=new file(...

java - How to preserve and object instantiated in a thread -

supposing have following public class foo { private map<integer,someobject> mymap; public foo() { this.mymap = new hashmap<integer,someobject>(); } private class runner implements runnable { public void run() { someobject someobj = new someobject(); foo.this.mymap.put(10,someobj); //'soobj' null upon retrieval later... } } } if create thread runnable of type 'runner' , start thread, run. in run method, create instance of 'someobject' , place in map of outer class. however, when attempt value 'mymap' later on, 'someobject' instance null. can't understand why have placed reference map 'mymap' still lives on in heap after thread finishes. there way around this?! thanks much it problem way objects instantiated. should be: foo foo = new foo(); thread thread = new thread(foo.new runner()); thread.start();

c++ - Using Namespace visibility in header -

i working on c++ library split multiple namespaces. since trying avoid "using" directive in header files forced alternative "namespace::class" variables, returns , parameters. can imagine messy. so, tried putting using statement inside namespace decloration (see below) , seemed trick, doesn't appear visible in files including file. namespace project { namespace utility { class a; } namespace system { using utility::a; class b { *a; // instead of utility::a *a }; } } my question is, okay instead? // header namespace project { namespace utility { class a; } namespace system { using utility::a; class b { *a; // instead of utility::a *a }; } } // end header class {}; int main() { using namespace project::system; a; } test.cpp:25:5: error: reference 'a' ambiguous a; ^ test.cpp:20:7: note: candidate found name lookup 'a' class {}; ^ test.cpp:9:20...

xcode - ScrollView offsets when superview is setframe?! (iphone) -

so have view , scroll view inside view. call a [view setframe:cgrectmake(55,70,260,420)]; i put nslog(@"%f %f",scrollview.frame.origin.x, scrollview.frame.origin.y); before , after setframe , reads 6,112 , 6,172. 112 correct, have no idea 60 comes from. searched 60 in implementation file, , there nothing affect y @ all. there rule doing setframe when there view inside view? thanks if take @ uiview reference, frame property states frame the frame rectangle, describes view’s location , size in superview’s coordinate system. @property(nonatomic) cgrect frame discussion this rectangle defines size , position of view in superview’s coordinate system. use rectangle during layout operations size , position view. setting property changes point specified center property , size in bounds rectangle accordingly. coordinates of frame rectangle specified in points. so guess when nslog frame scrollview displayed based o...

javascript - Fancybox - Can't Set CSS with jQuery? -

i trying adjust position of fancybox jquery: $('#fancybox-wrap').css("top", "200px !important"); and wasn't working @ !important bit. if css, it's ok deal: #fancybox-wrap { top: 200px !important; } which leaves me curious: there inside fancybox' codes that's preventing me changing wrapper's css via javascript? the css function put styles in style attribute. navigators seem not allow usage of !important in inline style. inline style should overpass css rule if "important". so $('#fancybox-wrap').css("top", "200px"); should work?

xcode - iPhone app in simulator works on one mac but not another mac -

i hired 2 developers work on app , both developers have no problem loading app in simulator. however, on imac, won't load app @ in simulator , gives me icon screen of app. i got paranoid , did clean install of os x , upgraded 10.6.6 erased hard drive before install running xcode 3.2.5 developers running xcode 3.2.5 ios sdk 4.2 i did clean targets did reset in simulator maybe in xcode preference settings? has happen before? -- have see them load app? here few suggestions/options: try load test app , see if computer. http://www.tuaw.com/2009/04/27/iphone-dev-101-the-hello-world-app/ have developers use teamviewer (http://www.teamviewer.com/en/index.aspx) load app in phone you. you have sign app through apple dev store, on list of developers can open/edit app?

sql server 2005 - Why isn't database version control considered as important as application version control? -

i've started using kiln source control projects vb.net code, , don't know how managed without it! i've been looking database source control, stored procedures, udfs etc. however, i've found there not available database version control there web files. why database version control not considered important web files? surely programming in database important code in code-behind , .aspx files? version controlling database objects important! however, maybe isn't considered important because people see database merely tool assists them? , external tools (normally) aren't version controlled. one thing i've found hard manage release process. right we're using red gates source control connected svn. when it's time release same rest of code: merge 1 branch other. deploy use sql compare create diff script between merged revision , actual database. aside minor quirks , beginners mistakes think works in environment there no downtime (purposef...

jQuery Context Menu clashes with jQuery Draggable -

i'm trying jquery context menu jquery draggable rows in jqgrid . the problem i'm having since added jquery context menu draggable action triggered on single click (as normal drag). looks little weird when rightclick row menu, , click outside on row (to discard menu) , row starts following cursor. does have evt.stoppropagation(); in following snippet jquery context menu? $(this).mousedown( function(e) { var evt = e; evt.stoppropagation(); $(this).mouseup( function(e) { e.stoppropagation(); var srcelement = $(this); $(this).unbind('mouseup'); if( evt.button == 2 ) { // hide context menus may showing $(".contextmenu").hide(); is there besides choosing between draggable or context menu? i've had related problem--draggable items attached context menus not draggable. in case draggable item (a div element floating in larger containing div element) attached context menu dr...

java - SocketTimeoutException problem - how to continue after exception -

i write , read in function using socket class. used synchronized(socket){ .//write; //read; } i doing (repeat) every 50-1000 ms. problem when ( unknown reason ) pluged off cable ( got sockettimeoutexception). when pluged in again, need continue. ? need close socket in catch block , create new ? or else ? you don't have anything. continue. if other exception, close socket , restart (if appropriate).

No pre-built ActionBar for Android pre-3.0? -

i note release few days ago of static library bringing fragments android versions prior 3.0, library include actionbar? suspect not. i assume app work on pre-3.0 versions, needs hand-built actionbar implementation versions 2.3 , use os default actionbar in v3.0? for reason assumed library had actionbar in it, dig further i'm not finding evidence of presence. the static library not contain actionbar. because actionbar window feature , not added static library. you should fall applications use today. namely "action bar" google uses in i/o app example.

windows phone 7 - Listbox-selecting items that are read from isolatedstorage -

ok, here simple code, explain need do: isolatedstoragefile store = isolatedstoragefile.getuserstoreforapplication(); streamwriter writefile; if (!store.directoryexists("savefolder")) { store.createdirectory("savefolder"); writefile = new streamwriter(new isolatedstoragefilestream("savefolder\\savedfile.txt", filemode.createnew, store)); } else { writefile = new streamwriter(new isolatedstoragefilestream("savefolder\\savedfile.txt", filemode.append, store)); } stringwriter str = new stringwriter(); str.write(urlholder.text); writefile.writeline(str.tostring()); writefile.close(); so, have isolatedstorage keep links, read textbox(urlholder), on other side, read links , put them in listbox: isolatedstoragefile store = isolatedstoragefile.getuserstoreforappli...

actionscript 3 - Font size of title property of TitleWindow component in Flex -

how can set font size of title property (header) in titlewindow component? if use fontsize property, sets font size components in titlewindow, not want. want set title. i'm using flex 3 thank you set title-style-name css attribute, , assign font size in block uses css class name. titlewindow { title-style-name: "mytitle"; } .mytitle { font-size: 16; }

jsp - What is the difference between a variable using declaration and a variable is declared using Scriptlet? -

what difference between variable using declaration , variable declared using scriptlet? <%! ... %> : in declaration <% ... %> : in scriplet the first 1 same declaring instance variable in java class. the second 1 same declaring local variable inside method in java class.

What's wrong with this javascript? -

i'm using javascript switch out tables based on time. i'm getting error in dw. <script type="text/javascript"> <!-- function changewebsite() { var currenttime = new date().gethours(); if (7 <= currenttime&&currenttime < 18) { document.write(' <table id="table_01" width="200" height="400" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_vc01.png" width="200" height="45" alt=""></td> </tr> <tr> <td> <a href="http://www.itsnotch.com" onmouseover="window.status='visit biography website'; return true;" onmouseout="window.status=''; return true;"> <img sr...

How to FTP in Ruby without first saving the text file -

since heroku not allow saving dynamic files disk, i've run dilemma hoping can me overcome. have text file can create in ram. problem cannot find gem or function allow me stream file ftp server. net/ftp gem using requires save file disk first. suggestions? ftp = net::ftp.new(domain) ftp.passive = true ftp.login(username, password) ftp.chdir(path_on_server) ftp.puttextfile(path_to_web_file) ftp.close the ftp.puttextfile function requiring physical file exist. stringio.new provides object acts opened file. it's easy create method puttextfile , using stringio object instead of file. require 'net/ftp' require 'stringio' class net::ftp def puttextcontent(content, remotefile, &block) f = stringio.new(content) begin storlines("stor " + remotefile, f, &block) ensure f.close end end end file_content = <<filecontent <html> <head><title>hello!</title></head> <b...

javascript - Closing Fancybox after editing inline TinyMCE produces WRONG_DOCUMENT_ERR: DOM Exception 4 -

i have fancybox loads form collects user input. in form tinymce editor. i'm using oncomplete event of fancybox init editor , works fine until try close fancybox after doing significant editing in tinymce. doesn't matter if click close x, or let ajaxform call fancybox close method upon submitting. the fancybox closes, hangs in loop console logging "wrong_document_err: dom exception 4" before getting rid of shadow overlay. tried disabling overlay , made no difference. page still hangs looping error. similar errors produced in firefox. understand error has trying manipulate dom nodes different elements. suspect it's because dom tree doesn't match 1 fancybox trying close after adding elements to tinymce (adding image, list item, etc causes it). has dealt similar issue before? i did googling didn't find solution, after testing found solution. try oncleanup command in fancybox options: $.fancybox(data_html,{ oncomplete:function(){ ...