Posts

Showing posts from February, 2013

php - validation for phone number in a form....Really Stuck -

before start flaming or @ all, read this! have regular expression verifying format of phone number entered in form correct. hoping find if knows way verify if number exists...so if number doesnt exist , user enters it, user error message phone number not exist , prompted enter working phone number.... i have looked on seas of google not find phone number validator not format checker regex... this last hope.. in order check if phone number exists (and belongs user who's filling form) , see 1 solution : try communicate phone. what's done sending sms validation code phone number -- , ask user type code once has received sms. this way, you'll sure : the phone number exists, and belongs current user. of course, make sure put security measure in place, prevent using form spam number : make sure 1 user cannot send more x sms per hour/day, make sure no more 2 or 3 sms can sent same number per day/week

How to select XML attribute - Converting MSSQL to MySQL -

i need convert mssql query below mysql. query selects value of "id" attribute out of "page" element in xpath. expect mysql query return 3 rows values 1,2,3 respectively. know how in mysql? please let me know. declare @inputxml xml set @inputxml = '<pages><page id="1"/><page id="2"/><page id="3"/></pages>' select node.value('@id', 'bigint') id @inputxml.nodes('/pages/page') tempxml (node)) edit: forget said earlier. courtesy of dave, want @ this: http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html (previous answer left in place reference): mysql doesn't xml. short answer is: "you can't". the long answer is, depending on context runs in, have few options. normalize data proper sql schema, instead of relying on xml inside sql. pull xml database plain strings, , xml processing in logic (php, c#, vb, whatever

c# - Binding to events in dynamically loaded user controls -

i constructing test project demonstrate (to me) how dynamically load user controls. works except wiring of control notify parent has happened. problem line tries connect event in user control event handler in parent page. "notifyparentevent" event not visible , compiler barfs on (the event not defined in system.web.ui.control). have tried using usercontrol instead of control, no avail. control control = page.loadcontrol(savedcontrolvirtualpath); if (control != null) { control.id = control.gettype().name; >>>>> control.notifyparentevent += new eventhandler(usercontrolnotificationhandler); controlplaceholder.controls.add(control); } code behind user control: public partial class usercontrols_webusercontrol1 : system.web.ui.usercontrol { public event commandeventhandler notifyparentevent; private void notifyparent(string message) { if (notifyparentevent != null) { commandeventargs e = new commandeventar

java - how to run playframework FunctionalTest through Eclipse? -

and second question: is possible run them in bunch through eclipse? functionaltest , unittest extend basetest, annotated playjunit4testrunner, should find can run tests other test (i.e. run > junit test). you'll see play environment being initialised on console before tests run. one problem i've found running whole package of play tests in eclipse buggy, tend run 1 @ time in eclipse , use play's own testrunner verify whole suite.

version control - Mercurial - log the command executed -

we've been using mercurial while , working fine. the problem encounter when runs "bad command". an example be, merging unstable branch in stable trunk or pulling named branch on unrelated overwriting bunch of stuff... you've got hg log people won't believe output saying "i didn't that"...now in interest of public shaming :) , giving rightful priviledges "you broke built hat", i'm wondering, there way have mercurial log every command given text file give like: hg pull -b hg merge totallywrongbranch hg ci -m "i didn't it!" -u bsimpson ok, had few minutes on hand wrote exe , named hg.exe , renamed mercurial's original exe real_hg... an ugly hack don't mind code quality please works! public static streamwriter sw; static void main(string[] args) { sw = new streamwriter("hgcommandlog.txt", true); stringbuilder sbarguments = new stringbuilder(); if (args.length > 0)

segmentation fault - NGINX + PHP5-FPM segfaults under high load -

i have been dealing problem day , driving me insane. google results , searches here lead dead ends. hope can work me provide solution myself , future victims. here go. i running popular website on 3m page views day. on average 34 page views per second, more realistically, during peak hours, gets on 300 page views per second. think of these requests. i running ubuntu 10.04 64-bit server 2 e5620 cpus, 12gb ram, , micron p300 6gb/s ssd. during peak hours cpu , memory load average (20-30% cpu , half of memory used). the software powers site is: nginx, mysql, php5-fpm, php-apc, , memcached. ok, meat of post, here error logs. there bunch of these errors logged. /var/log/php5-fpm jul 20 14:49:47.289895 [notice] fpm running, pid 29373 jul 20 14:49:47.337092 [notice] ready handle connections jul 20 14:51:23.957504 [error] [pool www] unable retrieve process activity of 1 or more child(ren). try again later. jul 20 14:51:41.846439 [warning] [pool www] child 29534 exite

html - Extract the contents of a div using Flash AS3 -

i have sfw embedded in php page. there div on page id="target" . i want access content of div (ie: characters inside it) , hold them string variable in as3. how can this? my attempt far import flash.external.externalinterface; var mydivcontent = externalinterface.call("function(){ return document.getelementbyid('target');}"); var mydivcontent2:string = mydivcontent.tostring(); test_vars.text = mydivcontent2; //dynamic text output you're there : var res : string = externalinterface.call("function(){return document.getelementbyid('target').outerhtml}"); if want content of target , use innerhtml instead of outerhtml .

c++ - CUDA debugging procedure for non-deterministic output -

i'm debugging cuda 4.0/thrust-based image reconstruction code on ubuntu 10.10 64-bit system , i've been trying figure out how debug run-time error have in output images appear random "noise." there no random number generator output in code, expect output consistent between runs, if it's wrong. however, it's not... i wondering if 1 has general procedure debugging cuda runtime errors such these. i'm not using shared memory in cuda kernels. i've taken pains avoid race conditions involving global memory, have missed something. i've tried using gpu ocelot , has problems recognizing of cuda , cusparse function calls. also, code works. it's when change 1 setting these non-deterministic results. i've checked code associated setting, can't figure out i'm doing wrong. if can distill can post here, might that, @ point it's complicated post here. are sure of kernels have proper blocksize/remainder handling? 1 place have s

Gap size after placing JSeparator in Java Swing -

Image
i have simple problem here in java swing. simplified code following snippet. not sure how can minimize gap size between horizontal jseparator next jtextfield, current code generates huge gap between two. grouplayout layout = new grouplayout(jpanel1); jpanel1.setlayout(layout); layout.sethorizontalgroup(layout.createparallelgroup() .addgroup(layout.createsequentialgroup() .addgroup(layout.createsequentialgroup() .addcomponent(button) )) .addcomponent(jseparator) .addcomponent(jtextfield) ); layout.setverticalgroup(layout.createsequentialgroup() .addcomponent(button) .addcomponent(jseparator) .addcomponent(jtextfield) ); and in general, how can control gap size integer represented value, instead of using addpreferredgap ? thank you. okay, window gener

accelerometer - Android Workaround for non-working sensors when screen is off -

[edit: removed mention of android version - issue present on versions of android] background: when screen off, many android phones not provide updates applications of accelerometer readings calling onsensorchanged() when screen off. behavior discussed on s.o. , further documented here http://code.google.com/p/android/issues/detail?id=3708 on phones (nexus s, droid x2, ...) accelerometer values provided when there significant change in value. sitting still on table, example, there might 1 or 0 updates per minute in order produce code robust across phone models, how distinguish between lack of update events per screen off, vs. lack of updates per non-movement? should maintain database of phone models? this hard detect. android's api provides way control wake lock. manufacturers have done terrible job of implementing os on side. terrible. need grab partial_wake_lock keep phones cpu running when screen turned off. however not devices use , not respond - half/ha

java - How to pass a variable number of arguments to ant exec -

i have ant target takes variable number of arguments passed exec task. using old mechanism trivial: <exec command="cmd /c ${_full-path-to-exec}" osfamily="windows" failonerror="true"> </exec> however, use of 'command' deprecated in favor of nested elements. this: <exec executable="cmd" osfamily="windows" failonerror="true"> <arg value="/c"/> <arg file="${_full-path-to-exec}"/> <arg value="${_param-one}"/> <arg value="${_param-two}"/> <arg value="${_param-three}"/> </exec> which makes variable argument lists impossible. how solve problem? how this: <arg line="whatever args need"/>

c++ - Working with a vector of a class -

i newbie @ c++, , starting work container called classes. i working on program object defined, , stored inside vector. the program follows, , description of error got. this "car.h" #ifndef car_h_guard #define car_h_guard class car{ int v;//the velocity int loc;//location public: //default constructor, copy constr., cp. assgnmt. optr., destructor car(); car(const car& j); car& operator=(const car& j); ~car(); void set_v(int); //sets velocity void set_pos(int); //sets position int get_v (){return((v));}//returns velocity int get_pos(){return(loc);}//returns position }; #endif this "car.cpp" #include "car.h" #include <iostream> using namespace std; //constructor car::car() { v=1; loc=0; } //copy constructor car::car(const car& j){ v=j.v; loc=j.loc; } //copy assignment operator car& car::operator=(const car& j){ v=j.v; loc=j.

Mac OS X Leopard showing different version of Rails after install -

so i'm installing rails gem install rails and didn't have version of rails prior 1 i'm installing (3.0.9). by time installation finishes documentation error installing ri documentation rails-3.0.9... file 'lib' not found installing rdoc documentation rails-3.0.9... even though says rails 3.0.9 installed successfully. if run gem list rails it shows me version 3.0.9, when run rails -v it shows me version 2.3.5 ( don't know here came ). see: http://cl.ly/353h1o1b3y3t260l3f3p any please? if don't care, remove rails 2.3.5 gem uninstall rails , chose appropriate 1 when asks which.

asp.net mvc 2 - How to use getChangedCells method? -

i found getchangedcells method somehow applicable application building right now. can show me on how use getchangedcells method? thanks regards jason var temp= $("#grid").getchangedcells('all') // return rows or var temp= $("#grid").getchangedcells('dirty') / returns changed cells. also try looking @ official docs @ozczecho mentioned

android - Launch ContextMenu when 'back' key is hit? -

i need override button launch context menu. i have @override public boolean onkeydown(int keycode, keyevent event) { switch (keycode) { case keyevent.keycode_back : return true; } return super.onkeydown(keycode, event); } @override public void oncreatecontextmenu(contextmenu menu, view v,contextmenuinfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); menu.setheadertitle("quit"); menu.add(0, v.getid(), 0, "yes"); menu.add(0, v.getid(), 0, "no"); } @override public boolean oncontextitemselected(menuitem item) { if(item.gettitle()=="yes"){quit(0);} if(item.gettitle()=="no"){quit(1);} else {return false;} return true; } how can call contextmenu within 'case keyevent.keycode_back :'? use opencontextmenu : you'll need pass in view want have context menu opened, shoul

javascript - Retrieving a file list from a remote file system with Node.js -

is possible retrieve directory listing of remote file-system using node.js. know how locally using readdir(...) or readdirsync(...) can use methods return list of remote files http or ftp server? edit: want in webos i'm limited supported api's seems. may have real round-a-bout method have script creates file contains list of files in folder , accessing that. guess brings second question fire remote script local script? sure. find ftp client node, if server has ftp server going can interact it. the following how might go getting real filesystem access remote server if have root access remote machine trying interact with, yes should possible. otherwise, no. i not super familiar of this, need along lines of: configure network file system server (something this ) on remote machine. set nfs client on local machine node being run , mount network file system. then i think , should able use node filesystem library browse network file system mounted locally nor

How to declare good old C-Array in Objective-C inline? -

this piece of code: nsuinteger indexarr[] = {1,2,3,4}; nsindexset *indexset = [nsindexpath indexpathwithindexes:indexarr length:4]; is there way declare indexarr inline, like nsindexset *indexset = [nsindexpath indexpathwithindexes:{1,2,3,4} length:4]; or something? it's because i'm writing test reference paths , want save lines of code not usefull anybody... best regards, hijolen the problem attempt need cast compiler knows right type. nsindexset *indexset = [nsindexpath indexpathwithindexes:(nsuinteger[]){1,2,3,4} length:4];

iphone - isn't launching my URL? -

i've got question regarding sharedapplication. i'm reading particular link xml file onto app itself, , had stored inside nsstring. tried convert nsstring nsurl sharedapplication open it, doesn't seems work. way me work define string myself without passing in information xml. currently, code stands this: nsstring *urlstring = [item objectforkey@"officialweb"]; // reading xml nsurl *url = [nsurl urlwithstring:urlstring]; nslog(@"url: %@", url); // displays (null) printf("url: %s, \n", [urlstring utf8string]); // displays proper url [uiapplication sharedapplication] openurl:url]; if use codes above, safari not launch , nsurl returns (null) results. i've searched site , googled solutions, best saw include: urlstring = [urlsting stringbyaddingpercentescapeusingencoding: nsutf8stringencoding]]; into code. app launches safari after adding that, url turns out in extremely weird manner. "http://url.com/%0%0%a" or wh

android - Weird Admob error -

weird admob error. still noob not sure if there wrong code. admob not giving application error admob ads not appear in app. even stranger when viewing main.xml in graphical layout see "ads google" ads should viewable. i've installed app several times , refreshed nothing appears on real device. using updated admob jar / package googleadmobadssdk-4.1.1.jar. my main.xml below <com.google.ads.adview android:id="@+id/adview" android:layout_alignparentbottom="true" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adsize="banner" ads:adunitid="a14e27391701ceb" ads:loadadoncreate="true"/> </linearlayout> and manifest is: <!-- admob begin code --> <meta-data android:value="a14e27391701ceb" android:name="admob_publisher_id" /> <activity android:name="com.admob.android.ads.admobactiv

directory - Scripting.FileSystemObject location (from JavaScript) -

i have file windows sidebar gadget stores settings user, fso object seems pick native residence desktop, meaning if don't specify directory, put file on desktop. specify whole location, want able put on other people's computers without having stuff on desktop or elsewhere besides gadget folder. i know possible in xmlhttprequest, i've had trouble in past, , better if avoid altogether, if possible. function writesetting(text) { var fil = new activexobject("scripting.filesystemobject"); var writer = fil.opentextfile("loc.txt", 2, true); writer.writeline(text); writer.close(); } use system.gadget.path property gadget's path , append needed. see example in link. happy coding.

sql - Get second highest salary from each deptno -

how second highest salary each deptno following table? id name age deptno salary -- -------------------- ---------- ---------- ---------- 1 shasank 25 11 2025 2 raju 27 12 2027 3 son 33 12 2131 6 bali 31 10 2031 4 rambo 34 11 2345 5 don 32 11 2132 7 dimpu 31 12 2121 8 rahul 28 10 2341 9 janny 28 10 2123 if you're using system supports sql ranking functions, dense_rank you're seeking. below sql server 2005 or later: select * --todo - pick columns ( select *,dense_rank() on (partition deptno order salary desc) rnk table ) rnk = 2 ( sql server documentation on

How to hinder PHP files to Global Access -

i have includes files , don't want expose them via http. used being included other php files. should configure .htaccess file , add lines specify that? thanks in advance... you use .htaccess rules or put them outside of web directory! edit: it seems looking easy answer. have googled it, here one, try it: <files filename.php> order allow,deny deny </files>

facebook - Implementing Notifications in Rails -

in application, want notify user, when he/she mentioned in comment or post. user handle @user_name , similar facebook . database table mentions looks like: mention mentioned_by: user_id (foreign key) user_mentioned: user_id (foreign key) comment_id: (foreign key) post_id: (foreign key) i can't figure out way implement though. how facebook / twitter it? what decided go with, use activerecord callbacks/ observer design pattern , whenever new comment/post saved database, can go through contents of post/comment, , out mentions , execute notifications required. i feeling there missing pieces , not getting right. best way of doing it? facebook , twitter not mid-size rails applications. companies. tech runs them distributed , custom, in case of facebook. the part seem grasping how determine notify in performant , scalable way. shit gets real. can find lot of information architecture behind each on of them, , there lot of great stuff think these things,

jquery - How can I get smooth transitions on nested sliders using AnythingSlider? -

i'm trying create nested sliders using anythingslider, your appreciated i'm not sure having trouble, here demo of slider nested inside of 1 using latest version of anythingslider, available here .

c++ - The purpose of stdafx.h (And: Why doesn't this work?) -

i working on project has vendor-provided api. i've made class uses api in project , i've included vendors header file in stdafx.h file. things not compile. i put #include directly class' header file , things compile (and yes, class includes stdafx.h isn't reason. do of have guesses why wouldn't compile first time around? isn't project-stopper far i'd prefer if keep vendor api files in stdafx.h belong. edit: problem solved, i'd created cyclic dependency forgetting #ifndef header file , including them in wrong order. feel idiot. stdafx.h used in vs generated projects 'container' of headers precompiled. when added new #include stdafx.h didn't included because project configured use precompiled headers, , when add stdafx.h need regenerate .pch file contains precompiled information. one way have .cpp file in project nothing #include "stdafx.h" . maybe call `precompile.cpp". go project settings for 1 .cp

ruby on rails - Heroku "connection limit exceeded for non-superusers" -

i using free heroku plan shared database. cedar stack, rails 3.1.0.rc4. when launching application error, breaks process , disappears after random push: 2011-07-21t08:36:17+00:00 heroku[web.1]: starting process command: bundle exec rails server -p 11382 thin 2011-07-21t08:36:23+00:00 app[web.1]: => booting thin 2011-07-21t08:36:23+00:00 app[web.1]: => rails 3.1.0.rc4 application starting in production on http://0.0.0.0:11382 2011-07-21t08:36:23+00:00 app[web.1]: => call -d detach 2011-07-21t08:36:23+00:00 app[web.1]: => ctrl-c shutdown server 2011-07-21t08:36:23+00:00 app[web.1]: exiting 2011-07-21t08:36:23+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:987:in initialize': fatal: connection limit exceeded non-superusers (pgerror) 2011-07-21t08:36:23+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0.rc4/lib/active_record/c

SQL Server 2008 R2 Developer Edition installs two installation center shortcuts? -

Image
i've installed sql server 2008 r2 (developer edition). have selected database engine , full text search features. why creates 2 shortcuts? 1 should use modify current installation?

coldfusion - Login to coldbox application when login to core project -

i have following project structure.. www core project files , folders ticketsystem (coldbox project) ticket system built on framework coldbox 3.0.0. want user automatically logged in ticket system login our core project , share application , session variables between 2 projects. following steps have tried. to share session , application variables define same application name in root project , coldbox project , seems work fine. to login ticket system call security.dologin handler through cfhttp while login core project pass session.urltoken make sure use same application , session variables. but still not satisfied this. looking proper solution share data/call model between coldbox , non-coldbox application. i appreciate feedback on this. thanks pritesh have thought using session cookie user logged in? work if on same domain. you'll want encrypt user identifier in cookie. don't usserid = 1 change value gain access user's account.

c# - Getting collection of all members of a class -

i want collection of members present in class. how do that? using following, giving me many names along members. type obj = objcontactfield.gettype(); memberinfo[] objmember = obj.getmembers(); string name = objmember[5].name.tostring(); if want collection of properties , there values, : class test { public string name { get; set; } } test instance = new test(); type type = typeof(test); dictionary<string, object> properties = new dictionary<string, object>(); foreach (propertyinfo prop in type.getproperties()) properties.add(prop.name, prop.getvalue(instance)); note, need add using system.collections.generic; , using system.reflection; example work.

c# - If statment on button content . WPF -

i have listview 1 button( default content == "add") , 1 textbox. on list view double click event buttons.content=="edit" , text box fills information listview. this if statment not work correctly if (btnaddfloor.content == "add") { hprodatacontext db = new hprodatacontext(); floor f = new floor { floorname = txtfloorname.text }; db.floors.insertonsubmit(f); db.submitchanges(); refreshlistviewfloor(); } else { int currentid = convert.toint32(listviewfloors.selectedvalue); hprodatacontext db = new hprodatacontext(); floor f = db.floors.single(p => p.id == currentid); f.floorname = txtfloorname.text; db.submitchanges(); refreshlistviewfloor(); txtfloorname.text = null; refreshlistview

How to get perl script to generate every combination of two variables -

#! /usr/bin/perl use strict; use warnings; #always use these! @no = (1 .. 100); foreach(@no) { print "\#world" . $_ . " \{ background: url(/images/1.png) 0 0 no-repeat; float: left; width: 1%; height: 2%; position: absolute; top: " . $_ . "\%; left: " . $_ . "\%; z-index: -1; margin-top: -10px; margin-left: -10px; \} \#world" . $_ . ":hover \{ background-position: 0 -20px; cursor: pointer; \}"; } currently perl script outputs #world1, top: 1%; left: 1%; percentages same. how can modify script output world(1 through 100) top: 1%; left: (1% through 100%)%; world(101 through 201) top: 2%; left: (1% through 100%)%; world(19001 through 20000) top: 100%; left: (1% through 100%)%; this add unique number $world every top/left value pair. my $world = 1; $top (1 .. 100) { $left (1 .. 100) { # print he

node.js - CoffeeScript main? -

i'd have main function run if not imported run , not imported. is there equivalent python's name == " main " in coffeescript? right i'm using is_main = process.argv[1]==__filename if is_main main() but don't know if more idiomatic exists, , noticed did not work older versions of coffeescript. related js question main() if require.main module

compilation - Compiling Ncurses on Solaris - "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"? -

i'm trying compile gnu stack on solaris 10 (x86). i've managed following far: gmp mpfr mpc gcc binutils libiconv gettext i'm trying build ncurses, , i'm hitting error: /db/pub/eq/tools/bin/g++ -i../c++ -i../include -i/db/pub/eq/src/ncurses-5.9/c++ -dhave_config_h -d__extensions__ -d_xopen_source=500 -d_file_offset_bits=64 -dndebug -i. -i../include -i/db/pub/eq/src/ncurses-5.9/c++/../include -i/db/pub/eq/tools/include/ncurses -o2 -c /db/pub/eq/src/ncurses-5.9/c++/cursesf.cc -o ../objects/cursesf.o <command-line>:0:0: warning: "_xopen_source" redefined [enabled default] <built-in>:0:0: note: location of previous definition in file included /usr/include/iso/stdlib_iso.h:30:0, /usr/include/stdlib.h:18, /db/pub/eq/src/ncurses-5.9/c++/internal.h:53, /db/pub/eq/src/ncurses-5.9/c++/cursesf.cc:34: /db/pub/eq/tools/lib/gcc/i386-pc-solaris2.10/4.6.1/include-fixed/sys/feature_tests.h:341:2: error: #

.net - ConvertAll fails with NullReferenceException -

i trying flatten multi-dimensional array convertall can't work: private function flatten(byref object) object dim elements integer = 0 dim size integer r = 0 a.rank - 1 size = a.getupperbound(r) - a.getlowerbound(r) + 1 if elements = 0 elements = size else elements = elements * size end if next dim result(elements - 1) object ' fails ! result = a.convertall(a, new converter(of object, object)(function(x) x)) return result end function sub main() dim a(,) integer = {{1, 2, 3}, {4, 5, 6}} dim b(5) integer b = flatten(a) end sub why throw nullreferenceexception? thanks according msdn documentation , array.convertall() takes 0 based one-dimensional array tinput . have a(,) defined 2 dimensional

MySQL server not running as service -

i have installed mysql-server root command : sudo apt-get install mysql-server i have configured , changes many things related mysql-server problem mysql not working service not in /etc/init.d i want mysql server started @ boot time means make service. now have please help. i find chkconfig easy use: sudo chkconfig --list|grep mysql might outdated mode of handling it. of servers have long used find desktop ubuntu didn't have , complains if use it. if don't have chkconfig, sudo apt-get install chkconfig to turn on: chkconfig mysql on

Zend Framework Structure for Datamapper, Controller and Model -

i have started zend framework, have lots of questions structure. hope can explain properly, it's rather difficult. ok, have done quickstart tutorial , decided use similar structure first project. so have datamapper, model , database table file. i have created form can enter information(item) , upload images it. i have 2 datamapper (item , image) 2 models them. have item controller, 1 jumps itemmapper. in datamapper have save method. please see below: public function save(application_model_item $item) { $data = array( 'item_title' => $item->getitemtitle(), 'item_description' => $item->getitemdescription(), ); $this->getdbtable()->insert($data); // add image information ($imagedata session data) $table = new application_model_dbtable_image(); foreach ($imagedata $filedata) { $image = new application_model_image($filedata); $data = array(

WPF Strange problem with dynamically binding items to a new ListBox -

Image
here's code. is, creates new listbox control inside stackpanel , adds new item. problem described @ bottom of page. mywindow.xaml <window.resources> <datatemplate x:key="itemstemplate"> <border width="200" height="50" > <listbox itemssource="{binding title}" /> </border> </datatemplate> </window.resources> <grid> <grid.columndefinitions> <columndefinition width="100"/> <columndefinition width="*"/> </grid.columndefinitions> <itemscontrol grid.column="1" grid.row="0" itemssource="{binding elementname=mainwindow, path=dataitems}" itemtemplate="{staticresource itemstemplate}"> <itemscontrol.template> <controltemplate> <scrollviewer ho

java - Freemarker, Maps and Mongo. Getting a value out a nested structure -

i have mongo database , making small web application display values database. i'm having little problem getting value nested structure. the database structure have is: { "_id": objectid("4e244ddcb1633b25c38f2155"), "id": "2173", "type": "p", "title": "test title", "tag": { "0": { "_id": objectid("4e244ddcb1633b25c38f1fc1"), "name": "education", "id": "6" } } } what is, database database , put in map , map put several other maps 1 map (root) , put .ftl page. can read value in .ftl like: ${root.title} ofcourse print 'test title' in above example. i value of name in tage can print 'education' i don't know how this. ideas. you can access value using freemarker's built-in's hashes. similar below: <#assign tagkeys = root.tag?

c++ - Using numeric_limits to default parameter values -

i have template statistics class has range parameters. template <typename t> class limitstats { public: limitstats(t mx, t min) : max(mx), min(mn), range(mx-mn) {;} private: const t max; const t min; const t range; } i put default values of maximum , minimum allowable values, minimum value not same floating point , integer types. normally can write t min_val = numeric_limits<t>::isinteger ? numeric_limits<t>::min() : -numeric_limits<t>::max(); i have found can't use default parameter limitstats(t mx = std::numeric_limts<t>::max(), t mn = numeric_limits<t>::isinteger ? numeric_limits<t>::min() : -numeric_limits<t>::max()) is there way of achieving this? you might want rethink design. trying limitstats std::numeric_limits doesn't provide? don't replicate badness of design of std::numeric_limits . example, std::numeric_limits<double>::min() t

c# - Fill in PDF with fields -

i have few pdfs various customers/vendors. goal building web app potential customer fills out single form of data , can generate of pdf's print , sign. the pdf's have fields in them in adobe reader can click , type in data. however, sensitive financial data, , pdf won't let save desktop. there warning in adobe reader when open pdf , prevents saving completed form. don't care feature. users can save if want take risk if becomes opened when generate completed pdf myself. the problem need generate these pdfs data injected them without altering style. want avoid manually building them, if have to. how can generate exact pdf format gave me data filled in? you have @ itextsharp , pdfstamper class - allows load existing pdf, 'stamp' data fields , flatten out pdf can sent user: http://sourceforge.net/projects/itextsharp/ note itextsharp paid for commerical products - there may other open sources librarires can this.

c++ - How to inspect std::string in GDB with no source code? -

i'm trying debug program has no source code available, , need @ has stored in std::string. i've been googling , looking on here, , i've found information outputting stl containers, of refers variables, no source or debug information have memory offset of class data. there way this? every std::string implementation has pointer raw characters in somewhere. g++ 4.x , pointer @ offset 0 string. if know string resides @ e.g. 0x7fffffffda88 , then print *(char**)0x7fffffffda88 is need.

android - How to drawan overlay with buttons, text and image on a google map -

i new android. working on project uses map. want draw overlay item on specific geopoint contains rectangle, location info , button makes overlay invisible when clicked. can draw rectangle , text using drawrect() , drawtext() in draw method of overlay. problem how draw button part of overlay clickable or that. can suggest something...??? read following links , download code in links https://github.com/jgilfelt/android-mapviewballoons https://github.com/jgilfelt/android-mapviewballoons#readme . it working nice display button on map.

How to return datatable using Take() using C# -

i have function returns datatable, added code sort datatable using dataview , should return top 10 rows sorted dataview. dataview dvdt = dtdata.defaultview; dvdt.sort = "value desc" var vlist = dvdt.totable().asenumerable().take(10); i want know how can make sure datatable return item. how convert "vlist" datatable? i use: c# , .net 3.5 framework. you can use datatableextensions.copytodatatable : var table = vlist.copytodatatable();

c# - Asp.net: Page won't refresh after clicking dynamically generated Button controls -

clicking on of dynamically generated button controls indeed call b_click method , delete given user, however, upon deleting page not reload 'new' list of users. protected void page_load(object sender, eventargs e) { dbdb db = new dbdb(); list<user> users = db.getusers().executetypedlist<user>(); foreach (user u in users) { button b = new button(); b.text = u.firstname; b.click += new eventhandler(b_click); placeholder1.controls.add(b); } } } void b_click(object sender, eventargs e) { button b = (button)sender; dbdb.user.delete(x => x.firstname == b.text); } protected void page_load(object sender, eventargs e) { loadusers(); } void b_click(object sender, eventargs e) { button button = (button)sender; string firstname = button.commandargument; dbdb

c - Delayed Write errors -

for past few months, we've been losing data delayed write errors. i've experienced error both custom code , shrink-wrap applications. example, error message below came visual studio 2008 on building solution windows - delayed write failed : windows unable save data file \vital\source\other\ochshp\done07\lhftinstaller\release\lhfai.cab. data has been lost. error may caused failure of computer hardware or network connection. please try save file elsewhere. when occurs in adobe, visual studio, or word, example, no harm done. major problem when occurs our custom applications (straight c apps writes data in dbase files network share.) from program's perspective, write succeeds. deletes source data, , goes on next record. few minutes later, windows pops error message saying delayed write occurred , data lost. my question is, can help our networking/server teams isolate , correct problem (read, convince them problem real. telling them many, many

geometry - How to detect if a polygon has self-intersections? -

imagine have 2d polygon (a 2d closed polygonal chain more precise). how check if contains self-intersections? can convex or concave, oriented clockwise or counter-clockwise. now, run standard o(n log n) algorithm check if 2 segments cross. believe because have additional structure -- order of segments , fact each 2 consecutive segments meet @ endpoints -- simpler , faster (maybe o(n) ?) algorithm devised. any ideas? do need check self-intersections, or find of them? latter harder o(n log n) , can have o(n^2) intersections n segments. if need find out if self-intersections exist, or find small amount of them, here . paper seems claim need, particularly in polygon planarization section. doubt implementing algorithm described there simple, or worthwhile problem of reasonable size. such algorithm exist. disclaimer: haven't tried work through paper , understand it.

c# - Datetime? to string -

i need convert datetime? string. ?? operator dosent work , calling tostring on null make things fall over. advice on how handle datetime? thanks below code context. o.customerrequireddate datetime? , predictedactivationdate string . both need stay datatype are. { rsp = (from r in db.btrequests join o in db.neworders on r.id equals o.requestid join s in db.status on r.status equals s.id.tostring() select new datalayer.orderresponse { requestid = requestid, message = s.statusdescription, orderstatus = r.status.tostring(), predictedactivationdate =r.status == "3" ||

sql server - Can anyone help me find a good host that supports MDF file? -

can me find host supports mdf file? have site works in desktop when uploaded arvixe wont work , can't straight answer them. please need bad. thank you. no. small operations use mdf - serious hosts isolate sql servers on dedicated machines. there transfer wizard available allowing data upload server database. and should sql server express, not "mdf files". server technology.

dataframe - R-Transposing a data frame -

i need transpose large data frame , used: df.aree <- t(df.aree) df.aree <- as.data.frame(df.aree) this obtain: df.aree[c(1:5),c(1:5)] 10428 10760 12148 11865 name m231t3 m961t5 m960t6 m231t19 gs04.a 5.847557e+03 0.000000e+00 3.165891e+04 2.119232e+04 gs16.a 5.248690e+04 4.047780e+03 3.763850e+04 1.187454e+04 gs20.a 5.370910e+03 9.518396e+03 3.552036e+04 1.497956e+04 gs40.a 3.640794e+03 1.084391e+04 4.651735e+04 4.120606e+04 my problem new column names(10428, 10760, 12148, 11865) need eliminate because need use first row column names. i tried col.names() function haven't obtain need. do have suggestion? edit thanks suggestion!!! using obtain: df.aree[c(1:5),c(1:5)] m231t3 m961t5 m960t6 m231t19 gs04.a 5.847557e+03 0.000000e+00 3.165891e+04 2.119232e+04 gs16.a 5.2486

java - Jersey REST: Importing headers from a Map into a WebResource instance -

i trying take in arbitrary set of http headers , dump webresource instance. webresource interface allows 1 query parameters offers both webresource.queryparam(key, value) and webresource.queryparams(multivaluedmap<string, string> querymap) the api however, not allow same done headers. there 1 function, webresource.header(key, value) which allows 1 enter key-value pair http header, no function webresource.headers(multivaluedmap<string, string> headersmap) to solve problem, tried retrieve builder webresource , iterate on it, adding headers 1 one webresource.builder builder = webresource.getrequestbuilder(); for(map.entry<string, string> headersmapentry : headersmap.entryset()){ builder = builder.header( headersmapentry.getkey(), headersmapentry.getvalue()); } but doesn't seem solve problem. does have idea how can workaround jersey can dump arbitrary map headers of w

c++ - OpenGL transparent effects displayed quite awful on Meego -

Image
we've been creating several half-transparent 3d cubes in scene opengl displays on windows 7 , fedora 15, become quite awful on meego system. this looks on fedora 15 system: this looks on meego. color of line has been changed us, otherwise cubes see more pathetic: the effects implemented using normal glcolor4f function, , made transparent setting value of alpha. how that? both freeglut , openglut have been tried on meego system , failed display better. i've tried use engine irrlicht implement instead there nothing black on screen when zbuffer argument of beginscene method set false (and normal when it's true, not want). this should not problem of display card or driver, because we've seen 3d game transparent ball involved on same netbook , system. we failed find reason here. 1 give on why happening please? it sounds if may relying on default settings (or behavior), may different between platforms. are explicitly setting of opengl's bl

javascript - Equivalent of window.screenTop in firefox and chrome -

i have requirement need "window.screentop". works in ie. found equivalent firefox - "window.mozinnerscreeny". there similar chrome? or can same result using other methods? http://www.w3schools.com/jsref/prop_win_screenleft.asp seems it's cross browser

glTexParameter on Android -> OpenGL Error -

i have strange problem when using above mentioned method: gl.gltexparameterx(gl10.gl_texture_2d, gl10.gl_texture_mag_filter, gl10.gl_linear_mipmap_linear); while works great on android emulator open gl error on actual device (samsung galaxy). error gl_invalid_value (code 0x501 ). why that? gl_texture_mag_filter doesn't take anything other gl_nearest or gl_linear

linux - select one of outcomes randomally in sh -

i trying randomly choose 1 of 2 outcomes in sh #!/bin/sh if [$[ $random % 2] -eq 1 ] echo yes else echo no fi gives sh-3.2$ sh test.sh test.bash: line 4: [1: command not found no obviously, it's trying execute (0,1) command. doing wrong? just put space after first [, like #!/bin/sh if [ $[ $random % 2] -eq 1 ] echo yes else echo no fi

oop - Not Feeling Right about Data Access Design using Many Methods -

when started had interface: public interface iblogreader { blogpost getlatest(); ienumerable<blogpost> findbydate(datetime from, int limit); ienumerable<blogpost> findbycategory(string category, int limit); ienumerable<blogpost> findbyauthor(string author, int limit); } then needed different permutations of queries (findbyauthorwithcategory, findbydatewithauthor, etc.) figured needed change approach keep growing. need more , different queries. next had interface such as: public struct findcriteria { datetime? from; string category; string author; } public interface iblogreader { blogpost getlatest(); ienumerable<blogpost> find(findcriteria criteria); } the interface smaller , refrain making many methods. however, moved many method implementation big-honking single method implementation. made me feel better while. thinking of moving approach wrapped big-honking query method series of individual objects each object