Posts

Showing posts from May, 2010

Rock Mongo mongodb config settings -

i have installed rockmongo http://code.google.com/p/rock-php/ manage mongodb database. installed in subdirectory of site http://mongo.example.com . default config settings follows: "host" => "192.168.1.1", // replace mongodb host ip or domain name here "port" => "27017", // mongodb connection port "username" => null, // mongodb connection username "password" => null, // mongodb connection password i'm not sure should changing these to? on log in is: mongodb connection exception: connecting mongodb://192.168.1.1:27017 failed: operation in progress. please check configuration. this see wiki login admin username , password, set "admin" , "admin" default

EF CTP5 mapping problem when using a Entity base class -

i'm having odd problem many-to-many relationships in ef ctp5 when base class involved. i'll first show simple mapping works. i have following 2 classes (entities): public class product { public int id { get; set; } public string name { get; set; } public virtual icollection<process> processes { get; set; } } public class process { public int id { get; set; } public string name { get; set; } public virtual icollection<product> products { get; set; } } and mapping classes: public class productmapping : entitytypeconfiguration<product> { public productmapping() { totable("products"); haskey(t => t.id); property(t => t.id).hascolumnname("product_id"); property(t => t.name).hascolumnname("name"); } } public class processmapping : entitytypeconfiguration<process> { public processmapping() { totable("processes");

c# - Running example of NAppUpdate updater -

hi can give me running example of nappupdate nappupdate nappupdate comes 2 sample applications, winforms 1 working , commented. see here: https://github.com/synhershko/nappupdate/tree/master/samples/winformssampleapp . for other particular questions may want visit discussion group @ http://groups.google.com/group/nappupdate .

php - Drupal Register user upon node create -

how can add user register form node create form in drupal? there module http://drupal.org/project/inline_registration , has bugs. think saw alternative one, cant find now. beware many security problems possible when giving anonymous users access node creation. said, here thoughts. if can live without having form registration on same page, easier solution redirect user node create form after successful login. amounts perhaps 1 line of code (more if want redirect on conditions - e.g. user registers type of account). way can use built-in validation , submit handlers of user module. if must have both on same page, use hook_form_form_id_alter, , output user registration form fields if $form['#node']->nid isn't set. sure validate input well.

.NET Remote debugging domain/networking issues -

i have been trying implement remote debugging in 2 different scenarios both without success. 1: debug server in our office not on our network, use bt , server on static peer ip address while rest of lan on single dynamic ip. ever since setup peer ip server dissappeared our workgroup ((i think may have contact bt regarding this). more info here regarding peer ip's interested: http://business.forums.bt.com/t5/broadband-and-internet/static-ip-s-on-bt2700hgv-aren-t-always-static/m-p/17183 ) but server allows users on lan rdp users wan cannot. 2: our production server outsourced. possible remote debug on wan? both fail when try attach process. the error message returned when trying attach process on office server using username@ip-address is: unable connect microsoft visual studio remote debugging monitor named 'username@ip-address' visual studio remote debugger on target computer cannot connect computer. authentication failed. please see assistance that firew

.htaccess - RewriteRule Pattern Problem after RewriteBase called -

i want js-files in folder scripts redirected php handels caching. .htaccess looks this: options +followsymlinks rewriteengine on rewritebase /eval/widget/scripts rewriterule ^(.*)\.js$ func.php?src=$1 the filename (without extension) should passed php-file, instead src parameter 'scripts/javascript_filename'. what's wrong this? seems rewritebase doesn't set correctly... change rewrite rule to rewriterule ^.*?/(.*)\.js$ func.php?src=$1 you understanding of rewritebase incorrect.

JPA Hibernate EHCACHE issue with onetoone associations - QueryCache -

i have entity directly mapped ui has lookup tables data not change @ all. in controller using findall on tables values , set model. main entity @entity public class mainentity implements serializable { @onetoone(cascade = cascadetype.all, optional=true) @joincolumn(name="lookup_entity_key") private lookupentity luentity; } lookup entity: @entity @table(name="lookup_entity") @cacheable public class lookupentity implements serializable { } i have enabled second level cache in persistence.xml. configuration below <property name="hibernate.cache.use_second_level_cache" value="true" /> <property name="hibernate.cache.use_query_cache" value="true" /> <property name="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.singletonehcacheregionfactory" /> <property name="javax.persistence.sharedcache.mode" value="enable_selective"

MySQL SQL Statement Syntax, is there a legend for the documentation's notation? -

looking page defines formatting , syntax used described mysql sql statement syntax ; meaning there notation system used describe mysql's sql syntax statements, , i'm looking source defines how read formatting. questions, feedback, comments -- comment, thanks! are looking page? http://dev.mysql.com/doc/refman/5.5/en/manual-conventions.html

ios - The nav bar doesn't resize properly in landscape mode -

in ib created xib navigation bar , grouped tableview. in landscape mode, nav bar doesn't resize properly. i tried change autosizing mask. changed ib. nav bar, have set flexible width (red arrow) , edge distances superview ones set except bottom margin (no red line, flexible bottom margin). tableview lines red except top margin (so flexible top margin)... nav bar resizes, 2 buttons on don't resize. tried other combinations, nothing. this doesn't work me. the same thing happens xib navigation bar, grouped tableview , image between them. both views corresponding these xib modal . how problem be? i'd prefer not set them manually. tried modal view navbar, image , tableview , don't succeed in doing work it. thanks. in ib removed navbar , in code used: myviewcontroller *controller = [[myviewcontroller alloc] initwithnibname:@"myviewcontroller" bundle:nil]; uinavigationcontr

c# - Performance issues with the existing coding approach using global :: keyword -

i have been asked refactor particular module in application , tweak performance related issues (if any). coming module,there portions needs strings displayed. strings supplied language assembly(.dll) referred in project, returns string xml file containing strings if pass keyword. for ex: language.getstringfromid("txt_warning"); return warning !! the original developer has generously used global :: language.getinstance().getstringfromid("keyword") whenever fetch string question 1, approach ?? i had second thoughts approach, ran performance profiler , see everytime when string requested, takes 500ms return string queried keyword. before conclude indeed culprit, need thoughts .net experts in stackoverflow question 2 is there performance hit if use global :: in general ?? cheers it should used eliminate namespace conflicts. no performance hit using global:: . it's handled compiler. theres nothing namespaces @

winapi - Windows .inf files: how do I set the default Network Connection name during network driver install? -

i'm trying adapt open source tap-win32 driver project. when installs (at least on windows 7, , think windows xp too) creates device named "tap-win32 adapter v9" in devices control panel. easy change editing oemwin2k.inf file comes it . however, device gets attached network in windows networks browser, named default "local area connection 2." can rename using gui: click on network , press f2. but problem this: network device i'm working on not "local area connection", it's virtual network device. can make name by default show using more descriptive name of choosing? is there general documentation should reading? have tried script attached here , it's open vpn community , use after installation make little bit nicer.

doctrine2 - Is it possible to integrate Doctrine 2 with Zend Framework 1.1x? -

i'd use , test doctrine 2 , zend framework, don't start, , don't know if both compatible? do have feedback? how integrate doctrine 2 zend framework 1.1x? thanks in advance. after long day of search, found 2 implementations of 1 liked because of documentation , simplicity. it part of zend framework extension called bgy library , there application resource bootstraping both web application , cli.

Extract data from Wikipedia as clean as possible using Rails 3 -

i developing rails 3 application want able extract data (title , short text) topic wikipedia. i need info "clean" in other words free html, wikitags , irrelevant data reference list , such. is possible title , text topic? i using gem data ugly. {{for|the television series|solsidan (tv series)}} {{infobox settlement |official_name = solsidan |image_skyline = |image_caption = |pushpin_map = sweden |pushpin_label_position = |coordinates_region = se |subdivision_type = [[country]] |subdivision_name = [[sweden]] |subdivision_type3 = [[municipalities of sweden|municipality]] |subdivision_name3 = [[nacka municipality]] |subdivision_type2 = [[counties of sweden|county]] |subdivision_name2 = [[stockholm county]] |subdivision_type1 = [[provinces of sweden|province]] |subdivision_name1 = [[uppland]] |area_footnotes = {{cite web | title=tätorternas landareal, folkmängd och invånare per km2 2000 och 2005 | publisher=[[statistics sweden]] | url=http://www.scb.se/statistik/mi/mi

joomla - Add javascript action to all links on a webpage -

good morning, know if possible add automaticalliy javascript action links (or classes) on webpage, example wanna add following javascript action: "playflashsound();", links on web page should be: <a onmouseover="playflashsound();" href="#">link text</a>" the problem adding manually javascript action i'm using joomla, , don't know how it. thanks. with jquery this. $(document).ready(function() { $('a').click(function() { playflashsound(); return false }); });

android - Factors to consider to choose among client-side application or web application -

it seems there 2 choices develop solution android platform : client-side application , web application. according http://developer.android.com/guide/webapps/index.html the approach choose application depend on several factors... but tutorial doesn't mention factors should consider. may know factors need consider? or in word, what pros , cons of each solution ? p/s : when talk web application, mean solution provided http://www.phonegap.com/ well. seems able pack html, javascript , css single package looks native app. (i haven't try out) go native if... you need capabilities cannot achieved such accelerometer you need run processes in background, such polling servers updates, downloading information in background, listening changes made on device you need know orientation of device, such locking user portrait or landscape or if need alerted when changes you need access system services such sound manager it's important have launcher icon y

android - Why I cannot compile source code on my phone? -

after clicked run shown below [2011-02-23 22:12:06 - cas1] uploading cas1.apk onto device '100082d63935' [2011-02-23 22:12:15 - cas1] failed install cas1.apk on device '100082d63935': timeout [2011-02-23 22:12:15 - cas1] launch canceled! please me solve problem is actual device or emulator? app installed market? if should uninstall market version. if emulator, happens me , restarting emulator , waiting until home screen appears fixes it.

c++ - On RCF Middleware Binary Size -

rcf library/framework rpc , distributed messaging. rcf framework following reasons in line service - interface - rpc call specification (i.e., no separate compilation of idl). c10k design style (layers ontop of windows iocp or boost asio). supports windows named pipes , unix domain sockets (i absolutely cannot compromise on this). ssl. messaging paradigms, 2-way, 1-way, client-callback, 1-way batched. protocol buffers support (tho think can stick built-in-serialization). publish/subscribe functionality. i using gcc 4.4.3 on 64-bit ubuntu install. compile trivial server , client code using following line in demo subdirectory of distribution. g++ -o3 -drcf_use_boost_asio client.cpp ../src/rcf/rcf.cpp -i ../../boost/ -i ../include/ -lpthread ../../boost/lib/libboost_system.a -s the resulting client , server binaries fluctuate between 1.7 2.2 megabytes . alarm bells ringing; use following 3 examples yard sticks: boost::asio: server 2 example compiled in release ve

asp.net - Using Structuremap how do i inject a property of an MVC Controller into the Constructor of a Service the Controller uses -

i'm new using structuremap ioc container asp.mvc. 1 of controllers takes istreamservice interface in constructor. this linked concrete class implementation of streamservice so for<istreamservice>().httpcontextscoped().use<streamservice>(); the problem i'm facing concrete class constuctor takes iprincipal parameter, needs injected. want pass user property of instantiating controller concrete service. please point me in right direction? no problem, add line configuration: for<iprincipal>().use(() => httpcontext.current.user); the use of lambda causes evaluated every time dependency requested (as opposed being single instance @ configuration time.

xslt - XSL for-each filtering; how to evaluate TWO variable in select? -

<xsl:variable name="filtervalue" >@subject = 'subject filter on'</xsl:variable> <xsl:for-each select="$rows[$filtervalue]"> it seems me $filtervalue being treated literal string rather being evaluated. how can make variable's value evaluated instead? desired result : <xsl:for-each select="$rows[@subject = 'subject filter on']"> i apologize if has been answered before, don't know terminology xsl i'm having trouble searching online. thanks. dynamic evaluation of xpath expressions not supported in both xslt 1.0 , xslt 2.0. usually, there workarounds. in specific case can have (global/external) parameters: <xsl:param name="attrname" select="'subject'"/> <xsl:param name="attrvalue" select="'subject filter on'"/> and in code: <xsl:for-each select="$rows[@*[name()=$attrname] = $attrvalue]">

php - Hightest value of an associative array -

is there easy way hightest numeric value of associative array? $array = array( 0 => array( 'key1' => '123', 'key2' => 'values we', 'key3' => 'do not', 'key4' => 'care about' ), 1 => array( 'key1' => '124', 'key2' => 'values we', 'key3' => 'do not', 'key4' => 'care about' ), 2 => array( 'key1' => '125', 'key2' => 'values we', 'key3' => 'do not', 'key4' => 'care about' ) ); awesomefunction($array, 'key1'); // returns 2 ($array key) please kind since question written phone. thanks. if know data in format, should work. function getmax( $array ) { $max = 0; foreach( $array $k => $v ) { $max

javascript - strange debugging issue -

my code changes not being reflected in ie or ff. in ie: commented out alert('start'), still see alert when stop-restart visual studio debugger. in ff: same code change, none of alerts show @ all. uncommented alert('start') , still dont see in ff. i tried setting port stay fixed @ 5204. stopped asp.net development server prior starting debugger again. still doesnt help. environment: vs 2010 ie7 , ff3.6. code simplexhr = { doxhr: function (container, url) { //alert("start"); if (!document.getelementbyid || !document.createtextnode) { alert("no js support"); return; } simplexhr.outputcontainer = document.getelementbyid(container); if (!simplexhr.outputcontainer) { alert("no output container"); return; } var request; try { //alert("mozilla ajax"); request = new xmlhttprequest()

mysql - 'Ballparking' Number of DB Records to Save Cpu Cycles -

i noticed gmail started 'ballpark' number of results searches , wondered if aesthetic change or if saved on cpu cycles. when performing search in gmail says along lines of viewing 10 results of (hundreds, thousands, etc) are there sql techniques this? there performance benefits? anything point me in direction learn more helpful. pretty sure google search not using mysql. can ball park table's size in mysql doing show table status 'table_name';

python - ElementTree namespace incovenience -

i can't control quality of xml get. in cases is: <collada xmlns="http://www.collada.org/2005/11/colladaschema" version="1.4.1"> ... </collada> in others get: <collada>...</collada> and guess should handle <collada:collada xmlns:collada="http://www.collada.org/2005/11/colladaschema"> ... </collada:collada> it's same schema over, , need 1 parser process it. how can handle these cases? need xpath , other lxml goodies through this. how make consistent during etree.parse time? don't want check on namespaces every time need use xpath. my usual recommendation preprocess first, normalize namespaces. has 2 benefits: normalization code highly reusable, because doesn't depend on how data being processed subsequently; , logic process data considerably simplified. if documents use 1 namespace, or none, , not use qualified names in content of text or attribute nodes, transformation achiev

compilation - How can I compile an Emacs elisp extension (nXhtml)? -

i'm new emacs , installed nxhtml extension. how can compile extension? assumption: have installed xhtml bazaar repository on launchpad bzr branch lp:nxhtml . now answer: readme.txt file told us note 3: may optionally byte compile nxhtml nxhtml menu (recommended). add (load "~/.emacs.d/nxhtml/autostart.el") .emacs , m-x eval-buffer , activate mode , have nxhtml entry in menu, browse nxhtml → nxhtml , setup → byte compile nxhtml . et voilà !

PHP Custom array sort filenames by year and month, newest first -

i've got array of files looks this: array ( 0 => 'scpt-01-2010.phtml', 1 => 'scpt-01-2011.phtml', 2 => 'scpt-02-2010.phtml', 3 => 'scpt-02-2011.phtml', 4 => 'scpt-03-2010.phtml', 5 => 'scpt-04-2010.phtml', 6 => 'scpt-05-2010.phtml', 7 => 'scpt-06-2010.phtml', 8 => 'scpt-07-2010.phtml', 9 => 'scpt-08-2010.phtml', 10 => 'scpt-09-2010.phtml', 11 => 'scpt-10-2010.phtml', 12 => 'scpt-11-2010.phtml', 13 => 'scpt-12-2010.phtml', ); how can sort 2011 files appear first, in order of month (so should lead scpt-02-2011.phtml )? i've tried main sorting functions natsort, rsort, arsort etc i'm not getting anywhere fast! thanks in advance. function customsort($a, $b) { // extract values simple regular expression preg_match('/scpt-(\d{2})-(\d{4})\.phtml/i', $a, $matches1);

passing parameter in asp.net c# -

possible duplicate: passing data between asp.net pages how pass value of textbox 1 page page in asp.net c# need, not using url string query method. need passing 1 page without passing values url. use session state. session["textboxvalue"] = textbox1.text; then, retrieve on other page: string val = session["textboxvalue"];

Spring Portlets with Liferay server or Websphere Portlet Factory? -

any recommendation to go spring portlets liferay server or websphere portlet factory? assuming websphere portlet factory solution expedites portlet development not sure maintenance point of view. personal experience utilising these 2 technology stacks? additional information: have knowledge of spring mvc , have corporate license websphere portlet factory. in experience, websphere portlet factory might alright putting lot of cookie-cutter portlets, awful debug. don't have direct access code generates, so, when see stack traces in code, difficult figure out what's going on. moreover, end being limited whatever within wpf's paradigm, , things tough when have outside of boundaries. lot more flexibility spring portlet mvc, including advantage skills using have application outside of strict, portal context.

(f)lex can you have multiple expressions in one state? -

is possible have multiple expression in 1 state similar? hoping group few expressions make life easy myself. want similar below not working , recognise 1st expr , although match expr doesnt save array using yytext. im guessing im doing wrong appreciated.thanks <some_state>"milk;" | "honey;" | "cinnamon;" | "cardamon;" | "rum;" | "brandy;" | "whiskey;" | "aquavit;" | "kahula;" { printf("example"); array[i].addition = yytext;begin(amount_state);} if flex allowed, can use start condition scope following: <some_state>{ "milk;" | "honey;" | ... | "kahula;" { printf("example"); ... } } if at&t lex allowed, unfortunately may invalid...

Unit-testing SharePoint workflows -

i wondering if there existing solutions unit-testing windows workflow foundation workflows run in sharepoint context . unfortunately, sharepoint libraries not designed possibility of testing or mocking in mind. such workflows tightly bound sharepoint classes require sharepoint instance installed , running, absolutely ineffective testing. following list of challenges faced while trying unit-test existing workflow: workflows make calls static sharepoint objects; some eventargs classes necessary mocking internal sharepoint assembly; workflows may use special sharepoint workflow activities in turn make calls sharepoint; there no convenient api starting workflow in sharepoint context , monitoring state. i solved these problems workflow had test using microsoft moles , someday release solution open source. meanwhile, i'm wondering if of ever unit-tested sharepoint workflows. if so, i'd hear solutions these (and other) problems. i'd know if library, if rel

.net - Certificate invalid forb netTCP in WCF -

i'm trying wcf service use certificate-based encryption in local environment it'll talk machines in different domains when out in live environment. had service working before trying implement security, i'm confident fault isn't in service. i generated certificates using makecert.exe. start created 2 called wcfclient , wcfserver , added them trusted folder current user in mmc. yielded error: identity check failed outgoing message. expected dns identity of remote endpoint 'localhost' remote endpoint provided dns claim 'wcfserver'. if legitimate remote endpoint, can fix problem explicitly specifying dns identity 'wcfserver' identity property of endpointaddress when creating channel proxy which figured occured because issuing certificate non-existent domain called "wcfserver". created cert , gave cn of "localhost" , tried configure both client , server use it. i'm getting message: the rem

Algorithm to Map Strings to Short Replacements -

i'm looking @ ways deterministically replace unique strings unique , optimally short replacements. have finite set of strings, , best compression achieve far through enumeration algorithm, order input set , replace strings enumeration of char strings on extended alphabet (a..z, a...z, aa...zz, aa... zz, a0...z9, aa..., aaa...zaa, aaa...zaaa, ....). this works wonderfully far compression concerned, has severe drawback not atomic on given input string. rather, result depends on knowing all input strings right start, , on ordering of input set. anybody knows of algorithm has similar compression doesn't require knowing input strings upfront?! hashing example not work me, depending on size of input set i'd need hash length of 8-12 hashes unique, , long replacements (currently, replacement strings 1-3 chars long use cases (<10,000 input strings)). also, if theoreticians among know wasted effort, interested hear :-) . you use enumeration scheme, sorted order

dllimport - How can I use a DLL from Python -

i trying load dll in python, want use econnect() function using ctypes what know source code of dll: from *.cpp source code: bool econnect( const char *host, uint port, int clientid=0); from dependency walker tool: function ordinal 6 , undecorated name is ?econnect@eclientsocket@@uae_npbdih@z i tried access econnect 2 ways myfunction , myfunction2, wrong. here code: from ctypes import * def main(): ip = c_char_p('127.0.0.1') port = c_uint(7496) client_id = c_int(0) myfunction = getattr(cdll.twssocketclient, "?econnect@eclientsocket@@uae_npbdih@z") myfunction2= cdll.twssocketclient[6] print myfunction print myfunction2 print myfunction(ip, port, client_id,ip) if __name__ == "__main__": main() i below error: "windowserror: exception: access violation reading 0x0000002d" i badly need here (i not know c++). thanks! to make things easier, more pythonic, might want ctypesgen: http://code.google.com/p/ctypesgen/ it

c# DateTime convert to string -

i have result set times stored in datetime variables. if value null want set var string "still logged in". i've tried tostring() things had no luck yet. this code doesn't work. queryresult.egresstime type datetime , can't string. if (convert.isdbnull(rdr["timeout"])) { queryresult.egresstime = "still logged in"; } that seems flaw in design if absolutely must keep this, set precise date ridiculously far in past , check before rendering date render "still logged in" if it's particular date. terrible way design things though!

c++ - Warning : overflow in implicit constant conversion -

in following program, line 5 give overflow warning expected, surprisingly line 4 doesn't give warning in gcc: http://www.ideone.com/u0bxn int main() { int = 256; char c1 = i; //line 4 char c2 = 256; //line 5 return 0; } i thinking both lines should give overflow warning. or there i'm missing? the topic led me experiment this: typedef type checking? there said following(which deleted answer, because when run it, didn't show had expected): //however, you'll warning case: typedef int t1; typedef char t2; t1 x = 256; t2 y = x; //possible overflow warning! (but doesn't give warning :() -wall doesn't include many options. -wconversion 1 of them , warns behavior you're interested in. see http://gcc.gnu.org/onlinedocs/gcc/warning-options.html

ajax.net - Update one updatePanel without Updating the other? -

i have 2 updatepanels, each label , button. want click on button 1 , updates label 2, without updating/refreshing updatepanel 1 @ all. doable? because button 1 in updatepanel 1, updatepanel seems refresh. thank you. probably fix problem: http://jalpesh.blogspot.com/2010/12/programmatically-updating-one-update.html

android - Screen blinking when using a webview with flash -

edit: made demo apk, can understand mean: http://cl.ly/3g0s1p030j243y0p3m2f for application, want kind of "super power point", or keynote (the commercial team present product customers) using android goodness, gestures, etc... on android tablet. honeycomb not yet ready , because need before march, choose random froyo tablet (archos 101), issue every tablet/phone tried. i made great application, animations during presentation, customer wanted use flash animations. because couldn't code animations (sort of little movies/ animated graphics) in android , lack of time, seemed idea. so, after search on web, used webview , code: webview mwebview1 = (webview) findviewbyid(r.id.webview1); mwebview1.getsettings().setjavascriptenabled(true); mwebview1.getsettings().setpluginsenabled(true); mwebview1.loadurl("file:///android_asset/graph_01.swf"); this work pretty well, on every device tried (archos 101, nexus one, nexus s, galaxy s, xperia, des

php - Best way to scale data, decrease loading time, make my webhost happy -

for facebook application, have store list of friends of user in mysql database. list requested db, compared other data, etc. currently, store list of friends within user table, uids of friends put in 1 'text' field, '|' separator. example: id - uid - name - friends => 1 - 123456789 - john doe - 987654321|123456|765432 my php file requests row , extracts list of friends exploding field ('|'). works fine, every 1000 users 5mb diskspace. now problem: for feature, need save names of friends of user. can in different ways: 1) save data in table. example: id - uid - name => 1 - 1234321 - jane doe if need name of friend id 1234321, can request name table. however, problem table keep growing, until users on facebook indexed (>500million rows). webhost not going this! such table take 25gb of diskspace. 2) solution extend data saved in user table, adding name uid in friends field (with separator, let's use ','). example:

Help Unit Testing cascading calculations -

i have class used part of financial application. class bound ui form , accepts handful of values used calculate financial data. calculated values presented properties on object. several of these calculations use other calculations. for example, calculationa may return propertya + propertyb. calculationb returns propertyc - calculationa. (this extreme over-simplification). i trying write unit tests make sure these calculations performed correctly , wondering approach should taking. my first approach manually recalculate expected result in test method. example, when testing calculationb, populate test object set expected result equal propertyc - propertya + propertyb. since real object has 25 properties involved, quite cumbersome. on option thought of create test object, populate values write test verifies calculationa equals propertya + propertyb , test verifies calculationb equals propertyc - calculationb. latter assumes calculationb correct, matter purpose of unit

php - How to use prepared and bound statement in SQL query -

i have been told query below susceptible sql injection - should using bound parameters instead, class search { public $mysqli = null; public function __construct($mysqli,$keyword = null) { $this->mysqli = $mysqli; } public function get_result($parameter) { $sql = " select * root_contacts_cfm root_contacts_cfm.cnt_id = '".$parameter."' order cnt_id desc "; $item = $this->mysqli->fetch_assoc($sql); return $item; } } can ask - how can turn search class prepared , bound statement? i have read articles online why should use prepared statements, article 1 article 2 but still don't have clue how improve query... tried amendment below, class search { public $mysqli = null; public function __construct($mysqli) { $this->mysqli = $mysqli; } public function get_result($parameter) { $sql = "

https - JMeter stops sending JSESSIONID cookie when switched to SSL -

i have test plan runs fine under http, , cookie manager correctly keeping sessions in place. capable of talking same server when switched ssl, , thinks working correctly because gets 200 response our custom message not being logged in. all need reproduce behavior switch http https. test still able talk server, can see in "view results in table" log cookies has jsessionid under http, , empty under https. , each request under ssl answered set-cookie jsessionid. interesting scenario. jmeter log file offer clues? could jmeter needs copy of certificate store ssl cookie? console display handshake problem, can resolved adding certificate key store: http://www.java-samples.com/showtutorial.php?tutorialid=210 you might able further debug writing out cookie value variable , logging value: received cookies can stored jmeter thread variables (versions of jmeter after 2.3.2 no longer default). save cookies variables, define property "cookiemanager.save.coo

symfony1 - Avoiding Spam Filters for account confirmation emails -

i have application built in php/symfony. part of requires sending account verification email users. unfortunately, seems email triggering spam filters (gmail, hotmail, others) , not making users inboxes. what strategies can use avoid being filtered? rather sending mail server website runs, it's better use trusted external mail server. can swift_smtptransport. you can use gmail account purpose: http://www.symfony-project.org/more-with-symfony/1_4/en/04-emails#chapter_04_sub_sending_emails_via_gmail

.net - How can I change the ForeColor of all labels on a form? -

is possible change forecolor of labels on form @ runtime, including form yet called? labels have same color throughout app. you need loop through of form's controls looking labels. controls can have child controls want recursively: private sub updatelabelfg(byval controls controlcollection, byval fgcolor color) if controls nothing return each c control in controls if typeof c label directcast(c, label).forecolor = fgcolor if c.haschildren updatelabelfg(c.controls, fgcolor) next end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load updatelabelfg(me.controls, color.red) end sub

jQuery Selects Plugin, pull variables from database -

i'm using code able generate dynamic select: demo: http://www.erichynds.com/examples/jquery-related-selects code: https://github.com/ehynds/jquery-related-selects i have changed code of orignal script from: $counties = array(); $counties['1']['barn'] = 'barnstable'; $counties['1']['plym'] = 'plymouth'; $counties['2']['chit'] = 'chittenden'; $counties['3']['ande'] = 'anderson'; to $counties = array(); $sql = "select id, naam, klant_id contactpersoon order klant_id asc "; if(!$res = mysql_query($sql,$con)) { trigger_error(mysql_error().'<br />in query: '.$sql); } else { while ($row = mysql_fetch_array($res)) { $counties[$row['klant_id'][$row['id'] = htmlentities($row['naam']); } } but reason pulldown select list not created when changes made. when test query, no

javascript - Triggering an event when a css value changes -

how can call function when specific css variable changes (eg: height of particular div), using jquery? there no "native" solution this. if you're strictly using jquery manipulation of css propertys, function hook or ( duck punshing ) best shot: (function($) { var _oldcss = $.fn.css; $.fn.css = function() { if( typeof arguments[0] === 'string' ) { console.log('css property ', arguments[0], ' change elem: ', this); } return _oldcss.apply(this, arguments); }; }(jquery)); this of course incomplete. if arguments[0] object need iterate on key/values. basic principle. the thing solution is, .height() call .css() . so $('div:eq(2)').height(55); would trigger css property height change elem: [div#custom-header]

mysql - How do I store URL fragments in a database? -

how urls (fragments) stored in relational database? in following url fragment: ~/house/room/table it lists information on table, , perhaps information table. this fragment: ~/house outputs: street 13 , room, garage, garden ~/house/room outputs: my room , chair, table, window what database schema looks like? if rename house flat ? possible solution i thinking create hash url , store along parentid , information. if rename upper-level segment need update rows contain given segment. then thought store each segment along information , level: select items key=house , level=1 , key=room , level=2 how solve problem if url can arbitrarily deep? check the adjacency list model , the nested set model described in joe celko's trees , hierarchies in sql smarties you should find plenty information topic. 1 article here update the nested set model if looking task 'retrieving single path' . have 'find immediate subordinates of nod

vb.net - System.Net.Sockets.Socket -

hi have chat program using system.net.sockets.socket works on lan. my question - same program work on net little or no modification , if provide client ip of machine or of router , use port forwarding ? my ip not static (i understand implications of this) thanks it should work identically, long can connection through. there technically no difference between lan communication , internet communication (one huge , complex)

Comparing two ISO8601 dates strings in PHP -

i need compare (actually rank/sort) dates in php script. dates iso-8601 date format i.e. yyyy-mm-dd i wrote comparison function splits dates , compares year/month/day. however, seems may overkill , done simple string comparison like: if ($date1 < $date2) // elseif( $date1 > $date2) //do else else //do yet thing is assumption (iso-8601) date string comparison correct - i.e. can rid of function (to save few clock cycles on server), or safer explicity comparison in custom function? http://en.wikipedia.org/wiki/iso_8601#general_principles date , time values organized least significant: year, month (or week), day, hour, minute, second, , fraction of second. lexicographical order of representation corresponds chronological order, except date representations involving negative years. allows dates naturally sorted by, example, file systems. go ahead string sorting. if wikipedia not enough, surely http://www.ietf.org/rfc/rfc3339.txt is, search strcmp

java - Distributed JMS based logging .. falling flat? -

in our fancy esb, logging of each request done via common infrastructure based on jms based logging. here happens in nutshell: service gets request service prepares data in logdata object service calls database time taken db interaction captured in logdata object service ready send response logdata object sent messaging destination service sends response very rosey! yes paper architects. here actual issue: jms service provider becomes unavailable - due system level error or software crashes. service waits @ step (step no. 6) has make jms connection send logdata object. resulting in delayed response, leading bad performance , user experience. so biggest shortcoming of "distributed logging using jms" touted lot of developer websites. note presance of logdata kind of critical non-functional requirement. means messages sent in persistent mode, leading wait until jms provider confirms receipt of message sender (the service in case) - blamed? immature des

iOS - encoding/decoding enums - crash on accessing after relaunch -

what doing wrong? encoding/decoding enum type properly? gamesettings interface: typedef enum { catwhite = 0, catblack = 1, catorange = 2 } catcolor; ... catcolor catcolor; ... @property catcolor catcolor; gamesettings implementation: @synthesize catcolor; ... + (gamesettings*)getinstance { if (sharedsingleton == nil) { sharedsingleton = [[super allocwithzone:null] init]; sharedsingleton.catcolor = catwhite; } return sharedsingleton; } -(void)encodewithcoder:(nscoder *)coder { [coder encodeint:self.catcolor forkey:@"catcolor"]; } -(id)initwithcoder:(nscoder *)coder { if((self = [super init])) { self.catcolor = [coder decodeintforkey:@"catcolor"]; } nslog(@"initwithcoder: %d", self.catcolor); //this logs correct int return self; } appdidfinishlaunching: - (void)applicationdidfinishlaunching:(uiapplication *)application { nsus

excel - Need the cell reference for a cell with unknown row and known column -

i trying take id in columnx , verify find occurrence of id in columny using match() function. function returns row number of match. need take row number , combine columnz in order make reference value later run comparison on value. here code have far: if(exact(match(x:x, y:y, 0), z:z), "y", "n") the bug in code passing parameters exact function. wants 2 strings (i.e. cell values), z:z statement correctly satisfies this, there anyway achieve this: if(exact(("z" + match(x:x, y:y, 0)), z:z), "y", "n") i trying create cell reference known column number (what don't know how do) , unknown row number (produced match function). i have tried using vlookup function , not produce desired results. have tried use indirect ? i believe that's function might need. you'll need check where need add it. i'd guess it's here: =if(exact(indirect("z" & match(x:x, y:y, 0)), z:z), "y

java - Where is com.google.android.mms.*? -

i writting application send mms messages android phone , trying follow instructions on post: how send image via mms in android? my problem can't find libraries used there, com.google.android.mms.* can point me that? is there mms library can plug in project? kinda weird google not provide developers... thanks, joao paulo farias you can way class pduparserclass = class.forname("com.google.android.mms.<the class>"); since class present on device not in sdk. not work on emulator

Passing PHP Result to JS via jQuery .get -

i have several instances form brought page in overlay via ajax. on these forms have "math validation" question (i know not secure). using following generate problem: <?php $randomnum = rand(0,9); $randomnum2 = rand(0,9); $randomnumtotal = $randomnum + $randomnum2; ?> the random number displayed in text box so: <input type="text" name="somename" value="<?= $randomnum ?> + <?= $randomnum2 ?>" readonly> and validated: ... somename: { required: true, equal: <?php echo $randomnumtotal; ?> } ... this works fine when form on page, hidden , displayed .click function. store files remotely , display them via ajax. no problem doing that, problem when this, numbers generated don't match value. i've tried putting php $randomenumtotal function on both form brought in via ajax , on parent page. neither works. so question this: can store php function in remote file "random.

javascript ok cancel pop-up button -

i've tried lot of things, still can access .js file inside form: please, can tell me how can done? this trying call: <script type="text/javascript"> if (confirm("press 'ok' leave, or 'cancel' if want stay: ")) { window.location="http://google.com"; } else { <a href="javascript:history.go(-1)">go back</a> } </script> this how i've been trying call: <input type="button" value="back main page" onclick= ??? > thank you. var answer = confirm ("press ok leave. cancel stay.") if (answer) window.location="http://google.com" else window.location="http://www.mysite.com/"

ruby on rails - Model tries to use different table name in production than in development -

i have model called user . have pluralize_table_names set false table user uses user . (that's kind of mouthful!) interestingly, model behaves correctly in development in production user tries use table called users doesn't exist. other models use singular table names. @ this: $ rails console loading development environment (rails 3.0.3) irb(main):001:0> client.table_name => "client" irb(main):002:0> appointment.table_name => "appointment" irb(main):003:0> user.table_name => "user" irb(main):004:0> $ rails console production loading production environment (rails 3.0.3) irb(main):001:0> client.table_name => "client" irb(main):002:0> appointment.table_name => "appointment" irb(main):003:0> user.table_name => "users" irb(main):004:0> as can see, everything's fine except user in production. gives? edit: here's model code in production: class user < ac

jquery - reLayout items with isotope, doesn't seem to maintain structure -

i've been playing isotope bit http://isotope.metafizzy.co/demos/relayout.html , have been trying create parent container remains fixed size, having 6 smaller items, , reshuffling fit 7th larger item. here have far on jsfiddle http://jsfiddle.net/pedalpete/lgbg6/ what hoping happen after clicking on block, total number of smaller blocks in 1 row 3. for reason, either user .isotope('resize'), or resorting , recreating isotope i'm doing, end number greater 3 in top row, items not sorted evenly. i have thought arrangement static after resorting. there way have isotope obey width , height parameters of binding box?? see http://jsfiddle.net/desandro/s5vag/ solution. is there way have isotope obey width , height parameters of binding box?? the first step disable isotope resizing container. set resizescontainer option false . now accomplish fitting blocks container, there several ways this. build own layoutmode, or try playing around sortin

problem with parsing json in jquery autocomplete -

i'm having trouble in parsing json data in jquery autocomplete. json comes code: <cfset theq = lcase(q)> <cfquery datasource="#source#" name="qry" maxrows="20"> select top 10 lastname info lower(lastname) '#theq#%' order lastname </cfquery> <!--- before can serialize query, need convert array of structs. ---> <cfset rows = [] /> <!--- loop on query convert it. ---> <cfloop query="qry"> <!--- create row struct. ---> <cfset row = {} /> <!--- add each column our struct. ---> <cfloop index="column" list="#qry.columnlist#" delimiters=","> <cfset row[ column ] = qry[ column ][ qry.currentrow ] /> </cfloop> <!--- append row struct row array. ---> <cfset arrayappend( rows, row ) /> </cfloop> <!--- have converted our query array of structs, can serialize using serializejson() metho

c - about malloc calloc and realloc -

possible duplicates: how malloc() implemented internally? how free , malloc work in c? whenever write program using malloc , calloc , realloc varies go , sit, i.e in part of memory go , reside. whether variables (in cases) allotted contiguous space or variables go , sit wherever space available the requested memory allocated contiguously on heap if enough space available. otherwise, functions return null indicate failure.

How to get the Google Map based on Latitude on Longitude? -

i want display google map in web page based on longitude , latitude. first user want enter longitude , latitude in 2 text box's. click submit button have display appropriate location in google map.and want show weather report on it.how that? thank you. create uri one: http://maps.google.com/?q=[lat],[long] for example: http://maps.google.com/?q=-37.866963,144.980615 or, if using javascript api map.setcenter(new glatlng(0,0)) this, , other helpful info comes here: http://code.google.com/apis/maps/documentation/javascript/reference.html#map

How to Set an array as Tag to any View through layout xml in android -

i want bind data view. using tag in xml file add information. if data string ( android:tag="extra info" ), able data using gettag() in code. but want bind multiple data object view, setting array tag. when tried set android:tag="@array/xyz_array" , still getting string object instead of array gettag() . can body tell me, if doing wrong ?? you can't xml, xml supports strings view tags.

iphone - touchesbegan touches only registers one touch even with two fingers -

i touch down @ same time 2 fingers. [touches count]=>1 , [[event alltouches] count] =>2 shouldn't 2 both of them? also, when first place 1 finger down on same cell. second finger event doesn't cause touchesbegan drigger? shouldn't call touchesbegan twice? i have table cell set: multipletouchenabled = yes; here touches began: -(void) touchesbegan:(nsset *)touches withevent:(uievent *)event{ nslog(@"began touch count %d", [touches count]); nslog(@"all touches %d", [[event alltouches] count]); } there seems going on touches when using uitableviewcell . guess is has built in handling of detecting swipes , touches cell being able handle scrolling of uitableview itself. workaround can add own view cell's contentview able detect touches. along lines of: mycustomview *customview = [[mycustomview alloc] initwithframe:...]; customview.multipletouchenabled = yes; [cell.contentview addsubview:customview]; [customview

wireless - Installing TinyOS 1.x and TOSSIM in Ubuntu -

i've been project evaluating performance of wireless sensor network. need work tinyos 1.x , nesc. need install tossim simulator. i'm using ubuntu 10.04. there way it? i went through myself. there's lot of different installation instructions tinyos 1.x, , many of them out of date or run issues--source packages needing patches, etc. this guide found worked: gems tinyos 1.x ubuntu guide of course, tinyos 1.x cvs has been taken down, think, instead of grabbing cvs source, take latest tarball (1.1.15) here: tinyos 1.x source distribution good luck! p.s. if don't work, there's xubuntos vmware image, built tos2.x, still has of tos1.x system in place , available. xubuntos vmware image

Is there a Java library for processing ONIX files? -

i've had search around, couldn't find java libraries process onix files. i guess there option of processing xml directly, thought i'd check see if there libraries available. try excellent jonix library @ https://github.com/zach-m/jonix . it's fast, effective, accurate , easy tweak.

How can I update the usernames/emails in Git commits? -

i wish update usernames user in git history, possible? it blunder of mine, migrated cvs while ago , didn't realise until started using git repo missed few usernames. you want git-filter-branch. example, change email address of every commit in entire history, can do: $ git filter-branch --env-filter git_author_email=new_address you can set filter modify commits based on whatever criteria need. example, if want set email address commits authored "barry", do $ git filter-branch --env-filter ' if test "$git_author_name" = barry; git_author_email=barrys-correct-address fi' this modify sha1s of every commit.

actionscript 3 - AS3 XML object not throwing exception if invalid data is given? -

i remember darkly xml class in as3 throw exception if tried give data in it's constructor not valid xml string. got case xml happily takes every kind of data no matter it's valid xml or not... var xml:xml; try { xml = new xml("some bogus string content."); _valid = true; } catch (err:error) { _valid = false; } ... missing something?? update: qname somehow null somehow it's not, see here: var qname:qname = xml.name(); if (!qname.localname) { _valid = false; } ... throws exception. obvioulsy qname null! ... var qname:qname = xml.name(); if (!qname || !qname.localname) { _valid = false; } ... doesn't throw exception. qname seems not null. wth? your example should give xml object no name , nodekind equal "text". how text nodes represented in xml. in addition try/catch, may check name().

c# - How to send big image from wp7 to wcf? -

i'm trying send image wcf use ocr. now, succeeded in transforming image byte[] , sending server using wcf. unfortunately, works array size <16kb , doesn't work array >17kb. i've set readerquotas , maxarraylength maximum size in web.config on server size. do know how send big data wcf server, or maybe library use ocr directly on wp7? if else fails, send in fragments of 16kb, followed "all done" message commits (reassembling if necessary)