Posts

Showing posts from June, 2010

unit testing - A.CallTo method that uses expression as a parameter -

i'm trying this, , doesn't work, although kinda should be a.callto(() => partyrepo.where(o => o.person != null)) .returns(new[] {new party()}); the call method exact code parameter returns empty enumerable the reason expression you're passing in call specification , 1 that's sent partyrepo not equal. there's no way fakeiteasy determine if arguments use equals-method. i'm not sure best workaround, this: public static class myargumentconstraints { public static func<myclass, bool> returnstruewhenpersonisnotnull(this iargumentconstraintmanager<func<myclass, bool>> manager) { return manager.nullcheckedmatches(x => { return x.invoke(new myclass() {person = "person"}) && !x.invoke(new myclass() {person = nu...

indentation - Vim editor indent problem when the first character of the line is a sharp # character -

this haven been bugging me since first day using vim 3 years. whenever try indent line via shift + > when first character of line starts "#", doesn't work @ all, regardless of file types (.php, .txt, etc.). because # used comment in php , use decoration text files like: # comment ### 1. instruction 1 # ------------ sample -------------- i use vim 7.2 in ubuntu following .vimrc settings syntax on set t_co=256 set incsearch set hlsearch set number set nowrap set nowrapscan set ignorecase set et set sw=4 set smarttab set smartindent set autoindent set textwidth=0 set noequalalways set formatoptions=1 set lbr set vb set foldmethod=marker thanks! insert following in .vimrc : set nosmartindent it smartindent causes lines beginning # not indented want. can read more typing :help smartindent . if use indenting file python scripts (or other syntax), include following too. filetype indent on

asp.net - Infragistics ultragrid client side event for row double click -

i wanna client side event row double click in infragistics ultragrid control. a server side event handler "ondblclick" available, hope there way in client side also. thanks help. this our working code cellclickevents: <igtbl:ultrawebgrid id="ultgridscenario"> <displaylayout> <clientsideevents dblclickhandler="ultgridscenario_celldblclick" cellclickhandler="ultgridscenario_cellclickhandler"></clientsideevents > </displaylayout> </igtbl:ultrawebgrid> added dblclick handler attribute , value example. function ultgridscenario_cellclickhandler(gridname, cellid, button) { if (button == 0) { var grid = igtbl_getgridbyid(ultgridscenario.clientid); var row = igtbl_getrowbyid(cellid); var rowid = row.id; var rowindex = rowid.substr(rowid.lastindexof("_") + 1, rowid.length - rowid.lastindexof("_")); var cellindex = cellid.substr(cel...

android - uses-feature overruling uses-permission? -

my app read sms , react on incoming calls, still want tablet users able download android market because whole lot more that. so, if app requests permissions reading phone's state , sms, tell android market app doesn't use telephony apis, android market then? <uses-permission android:name="android.permission.read_phone_state" /> <uses-permission android:name="android.permission.receive_sms" /> <uses-feature android:required="false" android:name="android.hardware.telephony" /> filtered wifi-only tablets or not filtered, question. any experiences? have great day tom given manifest elements above, market should allow app visible wifi-only tablets phones. ruboto irb application ran shortly after xoom became available. here blog post wrote after helping them fix matters.

null with PHP < and > operators -

can explain how null mapped in these statements? null>0; //=> bool(false) null<0; //=> bool(false) null==0; //=> bool(true) but null<-1; // => bool(true) i assume it's mapping problem, can't crack it. tried php 5.3.5-1 suhosin-patch. i point few pages: http://php.net/manual/en/types.comparisons.php http://php.net/manual/en/language.operators.comparison.php http://php.net/manual/en/language.types.boolean.php so in final example: null<-1 => bool(true) the null cast false , -1 cast true , false less true in first 2 examples null cast false , 0 cast false , false not less or greater false equal it. ohh fun of null ! :d

java - Ubuntu - UnknownHostException when connecting to a PC, using a Socket in an Ad Hoc network -

i have created filesystemlistener listens files in folder , sends them specified ip address. has been tested standard wireless network getting unkownhostexception when running on ad hoc network. i not sure if should ask on superuser, or here, not sure if issue code or ubuntu. i can ping other pc on wireless network keep getting above exception when connecting through java. not sure if helps here basic ssce can think of: import java.net.socket; public class clienttester { public static void main(string[] args) { socket s = new socket("192.168.0.1", 4440); } } anyone come across before, wanted see if java issue before cross posted in superuser. thanks! to compile correctly, unknownhostexception "must caught or declared thrown." for example: import java.io.ioexception; import java.net.socket; import java.net.unknownhostexception; public class clienttester { public static void main(string[] args) throws unkno...

.net - Version-sensitive ObsoleteAttribute -

the [obsolete] attribute handy marking classes have been deprecated in favor of better implementations, isn't sensitive version of .net project targeting. for example, i'm using home-rolled threadsafedictionary class versions of .net before 4.0. when .net 4.0 came out included new class called concurrentdictionary . i'd able mark threadsafedictionary [obsolete] only if project being compiled .net 4.0. doesn't appear stock obsoleteattribute supports controlling compiler's warnings framework version. is there way this? i guess roll out custom attribute , create post-build process examines compiled code through reflection searching attribute.

iphone - No connections shown in new xib file -

i trying add new view working nav controller app. edited detailviewcontroller.h , detailviewcontroller.m files new view (shown below), created new detailviewcontroller.xib file, added web view. issue cannot link file owner webview. when control drag file owner webview, webview label not show up, seems xib not connected .h , .m #import <uikit/uikit.h> @interface detailviewcontroller : uiviewcontroller { iboutlet uiwebview *webview; } @property(nonatomic,retain) uiwebview *webview; -(ibaction) goback:(id)sender; @end the top of .m #import "wwgt3appdelegate.h" #import "detailviewcontroller.h" #import "rootviewcontroller.h" @implementation detailviewcontroller @synthesize webview; you have set class of file's owner detailviewcontroller , interface builder knows outlets available. in ib, in inspector window.

ios - Removing all notification observer from a single place -

i want remove notification observer , using method: removeobserver: name:@"mynotification" object:nil for this. there many observers listening notification , want remove of them in 1 shot centralized place. can pass 'nil' in first parameter , remove observers listening mynotification? you can remove object notification center means no notifications triggered. example, when have view controller has registered notifications, include line in dealloc. [[nsnotificationcenter defaultcenter] removeobserver:self]; this @ object level...so unregister many notifications. won't unregister 1 notification in many objects. hope understood question correctly.

java - Delay between sound-playings? -

i'm building kind of simple game, it's red square can move around arrow keys, made finish object, detects when in it. now, made if "player" intersects "finish-object", play sound, play sound every tick. tried thread.sleep() , wait(), made whole game sleep, , not sound-delay. playsound method: public void playsound( string filename ) throws ioexception{ inputstream in = new fileinputstream(filename); audiostream = new audiostream(in); audioplayer.player.start(as); } and playerfinishing intersecting: //player1 level finishing if( player.getbounds().intersects(levelfinish.getbounds())){ message = "a winner you!"; try { playsound("d:/badgame/sounds/winner.wav"); } catch(exception ex){ ex.printstacktrace(); } } message string displays in middle of screen, works, needs kind of delay, sound won't play after each 10 seconds, or when intersect it, 1...

What is the difference between ado.net data services and WCF data services? -

i understand it's same thing. do concur? same thing. wcf data services known ado .net data services .

c++ - Template assignment operator overloading mystery -

i have simple struct wrapper , distinguished 2 templated assignment operator overloads: template<typename t> struct wrapper { wrapper() {} template <typename u> wrapper &operator=(const wrapper<u> &rhs) { cout << "1" << endl; return *this; } template <typename u> wrapper &operator=(wrapper<u> &rhs) { cout << "2" << endl; return *this; } }; i declare , b: wrapper<float> a, b; = b; assigning b a use non-const templated assignment operator overload above, , number "2" displayed. what puzzles me this: if declare c , d , wrapper<float> c; const wrapper<float> d; c = d; and assign d c , neither of 2 assignment operator overloads used, , no output displayed; default copy assignment operator invoked. why assigning d c not use const overloaded assignment operator provided? or instead, why assigning b a not use default co...

vb.net - Help with instructions for a login system -

i've been working last project 3 programming course, , right think i'm doing pretty well, gotta interact access tables, save, edit, create, etc... that has been working out pretty well, right i'm stuck login system, i've created methods encrypt password, , send password table called "security". fields in table are: username, password, email, type of account. i can insert respective data in it. right stuck validation. need create system let me verify if username exist (i did trying insert username again , if username exists return exception), don't know how verify password in same line. i wondering if there instruction can extract information of each field username verified? please me... idk if explain myself.. ? ok thank u know how can retrieve variable have "select contra seguridad usuaruio = @clave" you going want o read record table username field value of user name tested. if no record found insert record. if record f...

sockets - Single source pushing: how to send 5kb each 5 minutes to 50000 clients -

i need implement client server architecture server sends same message many clients on internet. need send single message every 5 minutes about. message won't excede 5kb. need solution scale big number of clients connected (50.000-100.000) i considered bunch of solutions: tcp sockets udp multicast wcf http duplex service (comet) i think have discard udp solution because solution clients on same network , won't work on internet. read somewhere wcf multicast cause bottleneck if have many clients connected can't find anywhere documentation showing performance statistics. tcp sockets seems me solution chose. think about? correct? i'm wrong when udp doesn't work on internet... thought because read articles pointing out need configured routers in network support multicasting... read of udp ports multicast range , thought meant locally. instead, range 224.0.0.1 - 239.255.255.255 (class d address group), can reached on internet considering in case r...

flash - Set Flex MX ComboBox background color using CSS -

is there way using css, set mx.controls.combobox 's background color. background color of each row when combobox clicked (expanded). i've tried backgroundcolor , fillcolors , backgroundgradientcolors without success. my combobox contained within formitem . i've tried setting formitem 's backgroundcolor , fillcolors , backgroundgradientcolors . it's not clear me combobox obtains or inherits list cell background color from. what want set dropdownstylename selector (let's call '.dropdownstyle') sets backgroundcolor since combobox actual made out of 2 parts .

Issue with receiving imap email in redmine -

my incoming emails keep getting ignored , not filed correct project. missing here? rake -f /home/kickapps/redmine/rakefile redmine:email:receive_imap \ rails_env="production" \ host=imap.gmail.com \ ssl=ssl \ port=993 \ move_on_success=filed \ move_on_failure=ignored \ username=redmine@kitops.com \ password=*************** \ unknown_user=accept \ no_permission_check=1 \ project=test \ allow_override=project,tracker if don't see email become read in gmail try adding --trace @ end of rake parameters (you should rake error). email must unread/new @ gmail box or won't read rake because thinks read it. another gotcha: 993 blocked firewall between redmine , gmail. check rails log/production.log right after running rake - check if there's error message mail. assuming rake task reading , changing status in gmail, might parameters. notice ssl different had. rake -f /home/kickapps/redmine/rakefile redmine:email:receive_imap \ rails_env="product...

mysql - Play Framework CRUD search issue -

when trying search on entities in crud module of play i'm getting exception: play.exceptions.javaexecutionexception: org.hibernate.exception.sqlgrammarexception: not execute query @ play.mvc.actioninvoker.invoke(actioninvoker.java:290) @ invocation.http request(play!) caused by: javax.persistence.persistenceexception: org.hibernate.exception.sqlgrammarexception: not execute query @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1235) @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1168) @ org.hibernate.ejb.queryimpl.getresultlist(queryimpl.java:250) @ play.db.jpa.jpaplugin$jpamodelloader.fetch(jpaplugin.java:431) @ controllers.crud$objecttype.findpage(crud.java:253) @ controllers.crud.list(crud.java:36) @ play.mvc.actioninvoker.invokecontrollermethod(actioninvoker.java:413) @ play.mvc.actioninvoker.invokecontrollermethod(actioninvoker.java:408) @ play.mvc.a...

asp.net - Object Reference not set to an instance or Index out of range error while adding values to lists -

below class file have different names 1 used in project. public partial class college { public list<students> students; } public partial class students { public list<activity> activity; } public partial class activity{ public list<string> name; } below aspx.cs code college.students.add(new students{ studentno= studentnumber.text}); int index2 = college.students.findindex(c => c.studentno== lineno); college.students[index2].activity= new list<activity>(); college.students[index2].activity.add(new activity{ }); int k = (college.students[index2].activity.count) - 1; college.students[index2].activity[k].name = new list<string>(); string ctrlstr = string.empty; foreach (string ctl in page.request.form) { if (ctl.contains("name")) { ctrlstr = ctl.tostring(); c...

Starting with OpenGL and C++, proper path? -

i need specific , general advice. i'm proficient java programmer , experienced web programmer, software development , i've been tackling c++. have great idea game i'd do, , realize huge undertaking--but i'm looking @ more opportunity learn c++, wrapping, whatever run in dev process... but can't foot in door conceptually! can handle c++ aspect fine, it's setting graphics, right way, that's confusing me. i've run through bunch of tutorials opengl c++ different things, none of can work... some use glut , glew. glut dead , freeglut thing now. ignore entirely , use bunch of files "glaux.h" can't seem find--and other tutorials devoted avoiding "glaux.h"... tutorials i've found come caveat in comments version of opengl dated , should using newer libraries-- , still others 3rd party libraries ogre , aurora. i've been looking through bunch of books , tutorials have different setup using opengl c++. realized there n...

Google AppEngine only deploys first version -

i changed app.yaml new version number before deploying appengine. appeared working fine, when visit website on appspot.com still shows old version, , https://appengine.google.com/ shows version 1 still live version. do make deploy new version? you need set default version in application's dashboard. to see non-default version url http://<version>.latest.<appname>.appspot.com/ . also, can (and should) use text names version labels instead of numbers.

c# - Trying to convert an xsl file and an xml file to html and then display that in a WebBrowser object -

so trying convert xml file uses xsl file convert both of html can bind webbrowser object. here have far isnt working: protected string convertxslandxmltohtml(string xmlsource, string xslsource) { string resultdoc = application.startuppath + @"\result.html"; string htmltopost; try { xpathdocument myxpathdoc = new xpathdocument(xmlsource); xsltransform myxsltrans = new xsltransform(); //load xsl myxsltrans.load(xslsource); //create output stream xmltextwriter mywriter = new xmltextwriter(resultdoc, null); //do actual transform of xml myxsltrans.transform(myxpathdoc, null, mywriter); mywriter.close(); streamreader stream = new streamreader(resultdoc); htmltopost = stream.readtoend(); stream.close(); file.delete(resultdoc); return (htmltopost); ...

nasm - ASM question, two's complement -

so book "assembly language step step" awesome, sort of cryptic how two's complement works when working on actual memory , register data. along that, i'm not sure how signed values represented in memory either, feel might what's keeping me confused. anywho... it says: "-1 = $ff, -2 = $fe , on". understand two's complement of number multiplied -1 , when added original give 0. so, ff hex equivalent of 11111111 in binary, , 255 in decimal. question is: what's book saying when says "-1 = $ff"? mean -255 + -1 give 0 also, didn't explicitly, set of flag? so in practice... let's have 11h, 17 in decimal, , 00100001 in binary. , value in al. neg al, , set cf , sf, , change value in al to... 239 in decimal, 11101111 in binary, or efh? don't see how 17 * -1? or poorly worded explanation book, means gives value need cause overflow? thanks! in two's complement, bytes, (-x) == (256 - x) == (~x + 1) . ( ~ c'is...

perl - How to read multiple files from a directory, extract specific strings and ouput to an html file? -

greetings, i have following code , stuck on how proceed modify ask directory, read files in directory, extract specific strings , ouput html file? in advance. #!/usr/local/bin/perl use warnings; use strict; use cwd; print "enter filename: "; # should enter directory $perlfile =stdin; open input_file, $perlfile || die "could not open file: $!"; open output, '>out.html' || die "could not open file: $!"; # evaluates file , imports array. @comment_array = ; close(input_file); chomp @comment_array; @comment_array = grep /^\s*#/g, @comment_array; $comment; foreach $comment (@comment_array) { $comment =~ /####/; #pattern match grab #s # prints comments screen print results in html format # writes comments output.html writes results html file } close (output); take 1 step @ time. have lot planned, far haven't changed prompt string ask directory. to read entered directory name, your: my $perlfile =s...

regex - Extract data from a Google Chrome bookmarks export with PHP -

i wanting google chrome bookmarks database, first step taking exported .html file chrome php , getting data variables, hoping php code able run data below , extract url, add_date, icon, , link text there own variables. i know need use regex this, can help? thanks, add bounty when time allows. <a href="http://snipt.net/public/tag/css" add_date="1271801059" icon="data:image/png;base64,ivborw0kggoaaaansuheugaaabaaaaaqcayaaaaf8/9haaactkleqvq4jxwss2gtursgvzszyasxpss2vhe2wosgilgvhydqzo2iioog+eikciiufntgjuovblwcikarfcsfi7hqflt4qqp10sk11mkbgk3smjsdjdnzj4s+0fb/ztml/3z8596jmkdelxcvytuwxs3+gu7o9dysqzvstvt8kfvnp9ddvbfrz3w3n197dqgaepv2ayeppuj9fdknguzbg68/dzo/hjcm/gl0dcqrs4kro9pznvt+edvudovdwr6lsksdyuefr39nhundp7n2kvnrzti21brf856eo7aloqagul40ihgx3ysqsonxp3znih/avp6yx2lsxwesdrvprfe2fnhqfd8bdsduviqzxq19mcxlawaxporwkkxwxiyqjwxdmzu1i2ytjutxskev2dllsvjmalgxo5ymrqymhe1zpjw6sbalqbsuxziyonzc9upk3qjarsfa7qjoil5ywx/15yqa6vyinc3m0vl2c0bejxukqqch6gu074miioiwjwhh55lipkio...

css - Text on footer Bar -

Image
my website url http://www.hentaireader.com at bottom right corner, wish put small link on red footer bar. i have created simple image of wish do. how can achieve this?? the code on page disaster. said have remove http://www.hentaireader.com/images/bar.gif image html , use css create background-image. something similar required... css: #footer-bar { width:100%; background-color:#f40000; background-image: url(http://www.hentaireader.com/images/bar.gif); background-position:top center; background-repeat:no-repeat; text-align: right; margin-bottom: 10px; } #footer-bar ul { width: 950px; height: 30px; margin-left: auto; margin-right: auto; position: relative; left: 0px; top: 0px; } #footer-bar li { display: inline; line-height: 30px; margin-left: 6px; } #footer-bar li { color: #ffffff; } html: <div id="footer"> ...

javascript - Dynamic text in divs - how to get both to work on same page? -

i have 2 div tags (and maybe more) dynamic text. need them cycle in loop. got working 1 div tag. when apply same script second div tag, 1 works. how both work @ same time on same page? <script type="text/javascript"> var text = ['foo', 'bar', 'baz']; = 0, $div = $('#div1'); setinterval(function () { $div.fadeout(function () { $div.text(text[i++ % text.length]).fadein(); }); }, 1000); </script> <script type="text/javascript"> var text = ['foo', 'bar', 'baz']; = 0, $div = $('#div2'); setinterval(function () { $div.fadeout(function () { $div.text(text[i++ % text.length]).fadein(); }); }, 1000); </script> seperate script tags share same variables <script type="text/javascript"> var text1 = ['foo', 'bar', 'baz']; var i1 = 0, var text2 = ['foo', 'bar', 'baz']; ...

printing - Get Printer MIB with JAVA -

i doing java program printer's mib in network .. how can printer's * mib * data through java ." thank you.. check out snmp4j libraries , docs .

Ipad like CSS Form -

Image
i've been searching css form design looks below. 1 tell me whether has created this? how this: http://www.k33g.org/?q=node/55

javascript - How to check if element exists in the visible DOM? -

how test element existence without use of getelementbyid method? have setup live demo reference. print code on here well: <!doctype html> <html> <head> <script> var getrandomid = function (size) { var str = "", = 0, chars = "0123456789abcdefghijklmnopqurstuvwxyzabcdefghijklmnopqurstuvwxyz"; while (i < size) { str += chars.substr(math.floor(math.random() * 62), 1); i++; } return str; }, isnull = function (element) { var randomid = getrandomid(12), savedid = (element.id)? element.id : null; element.id = randomid; var foundelm = document.getelementbyid(randomid); element.removeattribute('id'); if (savedid !== null) { element.id = savedid; } return (foundelm) ? false : true; ...

Spring MVC - Response -

how can access response object bean? request object use following. servletrequestattributes attr = (servletrequestattributes) requestcontextholder.currentrequestattributes(); is there similar above response object? if in web application context (which looks are) can auto wire in httpservletrequest or httpservletresponse. the request/response current request scope injected. @component public class somecomponentinawebapplicationcontext { @autowired private httpservletrequest request; @autowired private httpservletresponse response; ... }

php - Compiling From Source vs. Pre-compiled Windows Binaries -

so in past i've used pre-compiled windows php binaries this guide caught attention. that brings me this: why want compile php sources when binaries available them? is there performance bonus should aware of? if so, significant enough amount should take notice? for reference, use php cli applications bulk data processing , website info collection. system specs: windows 7 x64, 6gb ram, intel q6600 (2.4ghz x 4). there 3 reasons can think of compiling php rather using binary build on windows: you need compiled in extension or compile-time-option not come standard available binaries you short of memory , need leaner php executable devoid of extensions not use you want binary compiled processor/environment gain small performance boost might achieve (possible if have unusual setup) otherwise, stick binary.

qt - Support for https using QNetworkAccessManager. Hitting SslErrors at runtime -

i performing https operation qnetworkaccessmanager. hitting sslerrors @ runtime. after researching while able program running after installing openssl. required 2 dlls: libeay32.dll , ssleay32.dll. cannot perform https "get" operation using qnetworkaccessmanager without openssl ?? doesn't qt support native https support using qnetworkaccessmanager. thanks, de costo. had install following dll's found @ following website machine: http://www.slproweb.com/products/win32openssl.html the encryption guarded closely nationality. so, more info at: http://developer.qt.nokia.com/faq/answer/how_can_i_add_ssl_support_to_my_qt_application

objective c - about using AVMutableComposition to composite clips, -

i'm using avmutablecomposition composite(concatenate) video clips, code apple sample project aveditdemo, there 3 clips: a.mov 7.4mb b.mov 24mb c.mov 10.9mb after exporting, result video 106.4mb, normal? there way compress it? you can try exporting different preset/quality.

iphone - Difference between the UIWebView methods loadHTMLString: and loadRequest -

i have uiwebview , want load svg image it. contents of file pure svg i.e. <svg>...</svg> . file loads fine normal , mobile safari, , in uiwebview using loadrequest: doing following: url = [nsurl fileurlwithpath:path]; nsurlrequest *req = [nsurlrequest requestwithurl:url]; [webview loadrequest:req]; however, if load contents of file string, , try load html string webview, nothing displays: html = [nsstring stringwithcontentsoffile:path encoding:nsasciistringencoding error:nil]; [webview loadhtmlstring:html baseurl:nil]; is there reason between above 2 techniques? should not give same results? file pure ascii, don't think there encoding issue. i guess can need done right using file, hate use filesystem non persistent data. any appreciated!!! thanks, ron to solve issue have use loaddata:mimetype:textencodingname:baseurl: instead. nsdata *data = [html datausingencoding:nsutf8str...

ruby - Using Regex as delimeter to split a string -

i want split following strings 2 substrings. "somestring(otherstring)" i came following regex split "somestring(otherstring)".split(/(.+)\((.+)\)/) but excludes following strings, dont have substring in braces.. "somestring" how can change regex that, if there not substring of pattern "(otherstring)", still generates first substring output. thanks lot in advance! >> "somestring(otherstring)".split(/[()]/) => ["somestring", "otherstring"] >> "somestring".split(/[()]/) => ["somestring"]

joomla - How does my MVC controller query one database table before writing to another? -

i working on custom joomla mvc component. my view has form user enters id. have retrieved id ($input_id) in controller. need query database name id = $input_id, write name different database table. can done within controller or have pass variables model somehow? not sure of correct way achieve within mvc framework. all data , data manipulation should done in model (e.g. model data). controller there determine path of execution , methods should called (e.g. manager aka controller determines needs done). have @ tutorial understand mvc joomla better taking through development of simple component.

while loop - Inno uninstall issue -

i not able stop uninstallation when application, process related running. result files not deleted completely. need way check whether application running or not during uninstallation, prompt message user close application , uninstall. use appmutex directive check mutex held app. inno stop uninstall until app has shutdown.

Help with unexpected LINQ query results -

Image
i have these 4 tables: this query var query = db.authors .where(x=> x.itemauthors .any(z=> z.item.categoryitems .any(b=> b.categoryid == 10))) .select(ci=> new { authortext = string.format("{0} ({1})", ci.text, ci.itemauthors.count()), authorid = ci.authorid }); which populates authors drop down list works expected. problem when try count number of items assigned each author counts every item author has in entire items table. so example if author 1 has 10 books total, 2 of these books show in above query, still count 10 books. when bind same query control correct data, it's count operation won't work correctly. to reiterate bound gridview , see 1 book per author, not of books author wrote. appears query should correct. ...

php - accept POST from only own server -

Image
i have developed project in php need process post data have been sent own server ! how ? referrer not solution, can blocked/removed or changed ! there code stop in .htaccess ? you try use cryptographic nonce : typical client-server communication during nonce-based authentication process including both server nonce , client nonce ( client nonce built using nonce recived server ) . now doesn't make super secure ( there people able bypass rather easy ) harder floks make post you're website . ( image shows how use nonces in authetification process , use non authentification purposes )

PHP exec and Batik rasterizer -

i'm using batik convert svg images pdf. when converting them through terminal everying fine , file gets converted. however, want convert dynamically php exec(). this see when convert terminal: about convert 1 svg file(s) converting output.svg /opt/lampp/htdocs/tool/generated/output.pdf... ... success when using exec() output limited 'converting output.svg... etc' without ...success part. if server won't wait script finish. also, resulting pdf-file generated empty. this call in php: $command = 'cd ~/downloads/batik-1.7 && java -jar batik-rasterizer.jar /opt/lampp/htdocs/tool/generated/output.svg -m "application/pdf"'; $string = exec($command); echo '{"success": true, "message": "design saved generated/output.svg' . $string . '"}';` this see in js console: design saved generated/output.svgconverting output.svg /opt/lampp/htdocs/tool/generated/output.pdf ... edit: using stde...

user interface - UI Acceleo Launcher Project fails -

i've followed simple tutorial http://wiki.eclipse.org/acceleo/getting_started create ui launcher...but when finish , make right click on uml model, don't have acceleo tag "acceleo model tex", i'm unable run plugin...do know how possible? use th eclipse version 3.6.1 topcased... i can see 2 ways popup menu not show. least extension of model not match "model file name filter" field "new ui project" wizard ("*.uml" default). not think case, thought mention anyways. what think problem in case : tutorial not explain people not familiar eclipse plugins how use ui project. namely : new "ui project" eclipse plugin. in order menu contributes show, have deploy project plugin in eclipse. can done exporting project deployable plugin (right-click => export => deployable plug-ins , fragments) or spawning new eclipse instance eclipse contains project (run => run configurations... => double click 'eclipse ap...

php - Instead of using a hard coded values in JavaScript, is it possible to use a cron to do it? -

it's easiest understand looking @ fiddle: http://jsfiddle.net/tdbdw/1/ - apologies lack of css. as can see, dynamically generated dropdowns , textboxes have big list of hardcoded values. have liked have pulled these straight database queries take long run them used in real-time - i.e. when user clicks on drop-down or tries type in auto-complete box. instead have relevant queries run nightly using cron job question how take results of query , put them javascript file. anyone have ideas how implement this? any appreciated. martin the best route achieve want ("cron job creates data use javascript") go via json. involves: create cron job a) fetches data, , b) writes file formatted using json conventions accessible web server, amend html include file created cron job. for simplicity create javascript file using contents similar following: var agentvalues = [ "excel", "msword", "ppt", ]; ...

Session validation in Apache and Mod_JK -

how apache or mod_jk validate session created or not ? , session valid or not ? , session id valid or not ? how apache handles sessions ? apache doesn't interfere (or "validation") jsessionid cookie @ all. propagates client tomcat, , tomcat client.

xml - Error submiting application to orkut sandbox -

i trying submit open social application orkut sandbox without success. xml looks this: <?xml version="1.0" encoding="utf-8"?> <module> <moduleprefs title="app title" author_email="myemal@gmail.com" description="my test application" author="my name" screenshot="http://www.jogodireto.com/280x240/sonic-sky-chase.jpg" thumbnail="http://i271.photobucket.com/albums/jj139/igorstz/120x60-2.png"> <require feature="opensocial-data"/> </moduleprefs> <content view="canvas" href="http://gadget-doc-examples.googlecode.com/svn/trunk/opensocial-09/mycontent.html"> </content> <content view="home"> <![cdata[ hello, home view! ]]> </content> </module> and when try submit it, following error: submit failed. please ensure gadget has title, description,...

java - If A extends B extends C, why can I cast to A but get a ClassCastException casting to C? -

i trying read asn1 object using bouncycastle on android. expect dersequence, in bouncycastle subclass of asn1sequence, subclass of asn1object. import org.bouncycastle.asn1.asn1inputstream; import org.bouncycastle.asn1.asn1object; import org.bouncycastle.asn1.asn1sequence; import org.bouncycastle.asn1.dersequence; ... asn1inputstream ais = ...; object o = ais.readobject(); // eclipse's debugger says o dersequence, expected. dersequence o2 = (dersequence)o; asn1sequence o3 = o2; asn1object o4 = o3; // , o4 want. asn1object o5 = (asn1object)o; // throws: /// java.lang.classcastexception: org.bouncycastle.asn1.dersequence based on feedback answers, have constructed another, shorter example: object o = new dersequence(); asn1object o1 = new dersequence(); // behaves fine. asn1object o2 = (asn1object)o; // throws classcastexception. what causes cast fail? android has modified class hierarchy here, see comment in http://www.netmite.com/android/mydroid/1.5/dalvik...

how to display xml formatted jsp -

i have xml string in jsp. xml in single line. want display xml string formatted in jsp. for example: <?xml version="1.0"?><catalog><book id="bk101"><author>gambardella, matthew</author><title>xml developer's guide</title><genre>computer</genre><price>44.95</price>...(is going on) i want display follows in jsp: <?xml version="1.0"?> <catalog> <book id="bk101"> <author>gambardella, matthew</author> <title>xml developer's guide</title> <genre>computer</genre> <price>44.95</price>...(going on) how can this? i have exact same problem. solved formatting xml string in java code before sending jsp (you can in jsp if want): transformer transformer = transformerfactory.newtransformer(); transformer.setoutputproperty(outputkeys.indent, "yes"); source...

c++ - Private inheritance: name lookup error -

i have following code example doesn't compile: #include <stdio.h> namespace { class base1 { // line 6 }; class base2: private base1 { }; class derived: private base2 { public: // following function wants print pointer, nothing else! void print(base1* pointer) {printf("%p\n", pointer);} }; } the error gcc prints is: test.cpp:6: error: `class my::base1' inaccessible test.cpp:17: error: within context now, can guess problem is: when looking @ declaration of print , compiler sees base1 , thinks: base1 base-class subobject of derived* this , don't have access it! while intend base1 should type name. how can see in c++ standard correct behavior, , not bug in compiler (i sure it's not bug; compilers checked behaved so)? how should fix error? following fixes work, 1 should choose? void print( class base1* pointer) {} void print( ::my:: base1* pointer) {} ...

linq - C# laziness question -

what's common approach design applications, rely on lazy evaluation in c# ( linq , ienumerable , iqueryable , ...)? right attempt make every query lazy possible, using yield return , linq queries, in runtime lead "too lazy" behavior, when every query gets builts it's beginning resulting in severe visual performance degradation. what means putting tolist() projection operators somewhere cache data, suspect approach might incorrect. what's appropriate / common ways design sort of applications beginning? i find useful classify each ienumerable 1 of 3 categories. fast ones - e.g. lists , arrays slow ones - e.g. database queries or heavy calculations non-deterministic ones - e.g. list.select(x => new { ... }) for category 1, tend keep concrete type when appropriate, arrays or ilist etc. category 3, best keep local within method, avoid hard-to find bugs. have category 2, , when optimizing performance, measure first find bottlenecks. ...

objective c - iPhone AVAudioPlayer release EXC_BAD_ACCESS -

i play sound making this: nsdata *data = [nsdata datawithbytesnocopy:buffer length:length freewhendone:no]; avaudioplayer *player = [[avaudioplayer alloc] initwithdata:data error:nil]; in buffer have sound aac format. ok, until want release it, , not exc_bad_access i release in way: [player release]; free (buffer); i think player stil wants data, data not longer exist after make free (buffer); but don't know when make free (buffer). if remove line ok. when remove free (buffer) have memory leaks:( best regards chudziutki (when putting code in question, put 4 spaces in front of line of code format code. inline code needs surrounding little quote marks this .) if have crash, there backtrace. from symptoms, apparently freeing buffer before avaudioplayer done it. need make sure audio player entirely done buffer before free memory. likely, effective solution like: buffer = malloc(...); .... fill buffer .... nsdata *data = [nsdata datawithbytesnocop...

ruby - Showing near "total_entries" in Rails -

using ror 2.3.8 usually have following code: showing <%= @shops.total_entries %> shops in canada. yields result: showing 46 shops in canada what if want show round-down value: showing 40+ shops in canada whereas <10 total entries, should show exact number. thankyou. def round(total) total > 10 && total%10 != 0 ? [total/10*10,"+"].join : total.to_s end showing <%= round(@shops.total_entries) %> shops in canada. and of course better wrap model method class shop < activerecord::base def self.round total = count total > 10 && total%10 != 0 ? [total/10*10,"+"].join : total.to_s # instead of using `[total/10*10,"+"].join` can use `(total/10*10).to_s+"+"` end end @shops = shop.were(:region => "canada") showing <%= @shops.round %> shops in canada.

php - format of number on downloading in csv format -

following code returns hours given seconds, working. <?php $hrs = seconds_to_dezi(278280); echo $hrs; $filename = "test"; header("content-type: application/vnd-ms-excel"); header("content-disposition: attachment; filename=$filename.xls"); function seconds_to_dezi($s) { $n = false; if ($s < 0) { $n = true; $s = -$s; } $h = round($s / 3600,2); $h = number_format($h,2, ',', ' '); $h = str_replace(".",",",$h); if ($n == true) { return ("-" . $h); } else { return ($h); } } ?> actual output in excel:- 77,3 expected output is:- 77,30 i.e on downloading values in csv format, trailing 0 after decimal truncated. want have 0 in excel. the function returning 77,30. thing excel doesn't show final 0, it's there. open file text editor.

sdk - Application doesn't work in iPad Simulator, fine in iPhone Simulator -

i created application , runs ok when use iphone simulator. when try run on ipad simulator doesn't work. several things may assist tries assist issue: in iphone simulator tried change hardware settings - selecting device---ipad , changing version (3.2 , 4.0). did not difference. when runs device---ipad selection opens iphone simulator when open ipad simulator without build , run xcode don't see app in applications list on simulator view. should define in xcode or in simulator (like saying "this application should run in ipad")? may problem related versions issue? other ideas? the simulator open ever device project target set to. therefore, if set iphone open in iphone simulator. if set ipad open in ipad simulator. if set universal, support both. it has nothing hardware type select in simulator. have change target devices.

c# - Difference between two lists -

i have 2 generic list filled customsobjects. i need retrieve difference between 2 lists(items in first without items in second one) in third one. i thinking using .except() idea don't see how use this.. help! using except right way go. if type overrides equals , gethashcode , or you're interested in reference type equality (i.e. 2 references "equal" if refer exact same object), can use: var list3 = list1.except(list2).tolist(); if need express custom idea of equality, e.g. id, you'll need implement iequalitycomparer<t> . example: public class idcomparer : iequalitycomparer<customobject> { public int gethashcode(customobject co) { if (co == null) { return 0; } return co.id.gethashcode(); } public bool equals(customobject x1, customobject x2) { if (object.referenceequals(x1, x2)) { return true; } if (object.referenceequa...

mod rewrite - mod_Rewrite conditions and rules ( confused ) help please -

help please, after numerous hours searching solution problem have become confused, appologies if been answered before. i have current url : http://www.mydomain.com/news/dentistry_dental/article_detail.php?article=2968&title=redefining-oral-hygiene-intervention i cleaning urls have created rewrite rule parse following previous url : http://www.mydomain.com/dental_news/2968/redefining-oral-hygiene-intervention the rule have used in .htaccess file below : rewriterule ^dental_news/([^/]*)/([^/]*)$ /news/dentistry_dental/article_detail.php?article=$1&title=$2 [l] this working expected, however.. need have old url ( indexed on many search engines ) point new url 301 redirect. i have tried numerous things of yet nothing errors, presume looping error have. does out there have idea how can achieve 2 way redirect without looping? any appreciated edit the above problem has been resolved, can see answer below, have query, should me in understanding whats going...

iphone - How do I add a map view to an OpenGL ES view? -

i making 3-d ios application using opengl es. have created square frame gets rendered opengl es context. how add map view square frame? i'd able apply 3-d effect map. i tried adding map subview of opengl es hosting view, didn't see 3-d effect applied it. doing wrong? i think might going wrong way. first, opengl es rendering self-contained within caeagllayer, can't add subview , expect part of scene. opengl es content render within flat layer, , added on top of stacked on layer. you grab image of map view, convert texture, , upload texture opengl scene, have terrible performance , don't think you'd able maintain user interaction map. if attempting provide perspective effect map, use core animation catransform3d rotate map view in 3-d , apply perspective it. see answer here example of how achieved. using core animation require far less code opengl es.

compiler construction - Using "umlauts" in C++ code -

possible duplicate: c++ source in unicode i discovered line of code in project: string überwachung; i surprised, because thought not allowed use umlauts 'äöü' in c++ code other in strings , on, , result in compiler error. compiles fine visual studio 2008. is special microsoft feature, or umlauts allowed other compilers too? are there potential problems (portability,system language settings..)? i can remember not allowed. when did change? kind regards clarification p.s.: tool cppcheck mark usage error, though compiles gcc complains on it: codepad : error: stray '\303' in program the c++ language standard limits basic source character set 91 printable characters plus tabs, form feed , new-line, within ascii. however, there's nice footnote: the glyphs members of basic source character set intended identify characters subset of iso/iec 10646 corresponds ascii character set. however, because mapping source fi...

java - What is the correct way to pass data to a running thread -

in cases when create thread can prepare data beforehand , pass constructor or method. however in cases open socket connection typically have thread created wish tell perform action. basic idea: c# private thread _mythread = new thread(mymethod); this._mythread.start(param); java private thread _mythread = new thread(new myrunnableclass(param)); this._mythread.start(); what? so correct way pass data running thread in c# , java? one way pass data running thread implementing message queues . thread wants tell listening thread add item queue of listening thread. listening thread reads thread in blocking fashion. causing wait when there no actions perform. whenever thread puts message in queue fetch message, depending on item , it's content can it. this java / pseudo code: class listener { private queue queue; public sendmessage(message m) { // executed in calling thread. // locking done either in function or in add below // depend...

jquery - JQM (jQueryMobile) HTML5 Form Validation -

i've found h5validate plugin having no luck when using jqm, have suggestions on html5 form validation w/ jqm? i have multiple forms need validated, loaded via ajax. here workflow: load main form, when page loading bind live() (this adds jqm functionality). on submission (which button click) load next form via ajax (the next form goes through same logic on loading) this want add form validation, if valid submit , load next form, else display errors need add form validation each form , wanted take advantage of html5 syntax, that's why liked h5validate plugin try nothing happens, ugh... i've looked @ jquery validation plugin additional syntax , markup i'm trying avoid. , i've looked @ html5form using jquery 1.4.2 , i'm using 1.5.x wanted know if else had luck html5 , multi form validation submission? i have had success multi forms validationengine.js plugin here http://www.position-relative.net/creation/formvalidator/ example here:...

javascript - How can I draw a black shadow in webkit browsers? -

how can draw black shadow in webkit browsers html5 canvas? i found problem! webkit not how process shadow when blur not set or set zero. in case shows shadow in same color text. firefox shows correctly in both case (blur not set or blur equal zero).

sql - MySQL fetch X colums for each category_id -

i don't know if possible in mysql via 1 query . assuming have table "products" has "id","category_id","product_name","price" case 1 : want fetch 5 products each category price more 100$ case 2: want fetch 1-"3 products category 1" 2- "5 products category 2" 3- "3 products category 2 price more 100 , not fetched in point 2 above" each case in 1 query , possible ? ps : table has 100k rows ... i found method : fast , gave me wanted : select l.* ( select category, coalesce( ( select id writings li li.category= dlo.category order li.category, li.id limit 15, 1 ), cast(0xffffffff decimal)) mid ( select id category cats dl ) dlo ) lo, writ...