Posts

Showing posts from February, 2010

entity framework - Table-per-type inheritance with EF 4.1 Fluent Code First -

i have pretty straight forward set of database tables, like: vehicle id regno car id (fk of vehicle.id) otherstuff bike id (fk of vehicle.id) morestuff my class model you'd expect: vehicle being abstract class, , car , bike being subclasses of it. i have setup ef4.1 code first configuration follows: class vehicleconfiguration : entitytypeconfiguration<vehicle> { public vehicleconfiguration() { totable("vehicles"); property(x => x.id); property(x => x.regno); haskey(x => x.id); } } class carconfiguration : entitytypeconfiguration<car> { public carconfiguration() { totable("cars"); property(x => x.otherstuff); } } class bikeconfiguration : entitytypeconfiguration<bike> { public bikeconfiguration() { totable("bikes"); property(x => x.morestuff); } } however getting numerous strange exceptions when ef tried build ...

python - Security question relating to executing server-side script -

i've written python script using selenium imitate browser logging in , buying stuff website. therefore, python script contains log-in information along payment information (checking account info, etc). if configure apache webserver able execute python scripts, when client presses button runs purchasing script, there anyway client see contents of python script (thereby gaining access sensitive login , payment info)? i remember reading if error occurs, script show in plain text in browser? should prevent using try , except blocks or there better method i'm not aware of? thanks in advance. it idea put such information in external config file can't served webserver directly , read file in script. in case of configuration error client might see sourcecode not sensitive information

Not able to compile C/C++ code that's using ncurses -

i've discovered ncurses , have started learning it, examples in tutorial don't compile on computer. i had install ncurses manually , did entering "apt-get install libncurses5-dev libncursesw5-dev". had because before having done got error saying not "#include ". installing worked, error instead: touzen@comp:~/learning_ncurses$ g++ -o hello_world hello_world.cpp /tmp/ccubzbvk.o: in function `main': hello_world.cpp:(.text+0xa): undefined reference `initscr' hello_world.cpp:(.text+0x16): undefined reference `printw' hello_world.cpp:(.text+0x1b): undefined reference `refresh' hello_world.cpp:(.text+0x20): undefined reference `stdscr' hello_world.cpp:(.text+0x28): undefined reference `wgetch' hello_world.cpp:(.text+0x2d): undefined reference `endwin' collect2: ld returned 1 exit status the code compiled looks this: #include <ncurses.h> int main(){ initscr(); printw("hai thar world..."); refresh...

memory - PHP (or MySQL) crash when retrieving a big database record (~5MB) -

it doesnt display errors, blank page. tried die('test') before call function retrieve record , it, when place die('test') after retrieve row function empty page (on chrome says this: error 324 (net::err_empty_response): server closed connection without sending data.) .. have tried (with 128m, -1, 64m, etc) ini_set('memory_limit', -1); with no luck. using mysqli retrieve record , simple query 'select data tblbackup' (only 1 record in database) any help? thanks in advance update: tailed apache error log , when trying load page, [thu jun 30 13:47:37 2011] [notice] child pid 25405 exit signal segmentation fault (11) checkout php.ini variables execution time. sounds php might timing out. max_execution_time =3000 max_input_time = 6000 also, may have done @ .ini level, can add php error. put these @ top of file: error_reporting(e_all); ini_set('display_errors', '1');

content management system - Can you "unpublish" a page in Ektron without scheduling it to expire? -

i have pages in ektron based website , change status "approved (published)" unpublished status , prevent page displaying in navigation, etc. i have tried edit properties of page , can find no means of changing status of page. google searches have suggested schedule page expire date in past archive page, seems more workaround else. i don't think there "unpublish" button, , memory, setting expire date past ektron approved method of doing this. (checking out piece of content still leave previous version live)

c# - Maintaining a singleton object in WatiN tests -

i have problem keeping object singleton in nunit tests. this base class: [testfixture] public class suitebase { public mylib lib = null; [testfixturesetup] public void testfixturesetup() { lib = mylib.instance; } [testfixtureteardown] public void testfixtureteardown() { } } and 1 of test suites. [testfixture] public class suite1 : suitebase { [test] public void test1() { lib.foo(); //... } [test] public void test2() { lib.bar(); //... } } and mylib class defined following: //singleton class public sealed class mylib { public ie browser; //other public fields... public static mylib instance { { if (instance == null) { instance = new myliblib(); using (streamwriter sw = new streamwriter(@"c:\test.txt", true)) { sw.writeline(...

java - Problems with wikitude library to make AR on android -

hey guys developing , ar application , since wikitude , layar ones in knowledge using libraries being wikitude time. the following issues facing :- when on gps , out on streets shows poi else doesnt , have both permissions added in manifest , internet permission also when add title poi poi.setname("title"); not shown poi same goes description i have got key , added in wikitudearintent still whenever run application text "wikitude" come on bottom left corner in camera view is there other open source library making ar applications android ?? there better this?? thanks in advance mixare augmented reality library, free , open source www.mixare.org www.bango29.com/go/blog/2010/mixare-augmented-reality-tutorial

VB.NET read standard output -

from application need run command , parse output. can no problem don't want command displayed. hoped windowstyle = processwindowstyle.hidden work doesn't. take sample code below example. works fine command window still visibly opens , closes , need never show ugly face. how can fix this? dim myprocess new process dim lines string = "" myprocess .startinfo.filename = "c:\windows\system32\cmd.exe" .startinfo.arguments = "/c ipconfig" .startinfo.windowstyle = processwindowstyle.hidden .startinfo.redirectstandardoutput = true .startinfo.useshellexecute = false .start() end lines = myprocess.standardoutput.readtoend msgbox(lines) try setting createnowindow true too. if trying achieve find ip address(es) of local machine, there more direct ways of doing it .

c# - Folder Link of the uploaded file -

here situation i developing project management application in asp.net . in when customer gives project detail employee, uploads file (~ 100 mb). i don't want uploaded customer. we have drives connected in local network. what i'm thinking instead of uploading file can give link folder location , clicking on link in browser employee able access file. how should implement or please suggest practice or method solve type of problem. since it's intranet, have user provide unc path asp.net application pool identity has access to. in order provide file user, can either provide unc path href such as: <a href="file://///server/path/to/file.txt"/> or write file response: response.clear(); response.buffer= true; response.addheader("content-disposition","inline;filename=file.txt"); response.charset = "";

tsql - SQL: match time on several minutes -

i'm trying match datetimes 2 different tables. table has regular time (09:29:35). table b has rounded time (09:30). the time table b match time table a, or match minute before due rounding. how can match these times? or, how can 'remove' seconds table , round minutes on table well? thanks in advance! you can remove seconds cast: convert(varchar(16), getdate(), 120) this chops date after seconds, f.e. 2011-06-30 19:50 (16 characters long.) adding or substracting minutes can done dateadd . if combine in join, like: select * tablea join tableb on convert(varchar(16), tablea.datecolumn, 120) between convert(varchar(16), dateadd(m,-1,tableb.datecolumn), 120) , convert(varchar(16), dateadd(m,1,tableb.datecolumn), 120)

c# - Can't connect to Oracle database -

i working on asp.net project, uses c# code-behind. attempts connect oracle database using following code, existed in project when began working on it: oracleconnection myconnection = new oracleconnection(); myconnection.connectionstring = configurationmanager.connectionstrings["orafincnstring"].connectionstring; myconnection.open(); the application runs locally (opens in browser on localhost ), , attempts connect remote oracle database. when run it, the last line above gives following error: "invalidoperationexception unhandled user code. attempt load oracle client libraries threw badimageformatexception. problem occur when running in 64 bit mode 32 bit oracle client components installed." the connection string provided client, presume correct, , doesn't seem sort of error caused incorrect connection information. i'm pretty stumped problem is, , appreciate insight. please take @ following link. need install oracle 11g oracle data ac...

javascript - Greasemonkey to change value of Radio buttons in a form? -

i writing greasemonkey/tampermonkey script , need turn on radio buttons depending on name , value of radio control. this how looks: <input type="radio" name="11" value="xxx" class="radio"> <input type="radio" name="11" value="zzzz" class="radio"> so want set buttons have name of 11 , value of zzzz checked. this super easy when use jquery. here's complete script: // ==userscript== // @name _radio button check // @include http://your_site/your_path/* // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js // @grant gm_addstyle // ==/userscript== /*- @grant directive needed work around design change introduced in gm 1.0. restores sandbox. */ $("input[name='11'][value='zzzz']").prop ('checked', true); the input[name='11'][value='zzzz'] jquery selector gets <input> s have initial v...

html - vertical spacing between images -

Image
i cut 1 image 3 equal images , have in html code this: <img src="images/disclosure2_01.jpg" alt="disclosure"> <img src="images/disclosure2_02.gif" alt="disclosure2"> <img src="images/disclosure2_03.gif" alt="disclosure3"> the images render @ website this: i want know if possible remove vertical spacing between images , images 1 whole picture. in advance help. try this. remove lines between them. <img src="images/disclosure2_01.jpg" alt="disclosure"><img src="images/disclosure2_02.gif" alt="disclosure2"><img src="images/disclosure2_03.gif" alt="disclosure3"> or tinker css. img { padding: 0; margin: 0; }

javascript - jQuery incrementation param passing weird behavior -

let me describe scenario before question: let counter defined number starting 0. i have 2 tags: let them a1 , a2 i first dynamically added a1 html , used this: jquery("a.adder").click(function(){adder(this, counter)}); then did counter++ then dynamically added a2 html , used again on both tags jquery("a.adder").click(function(){adder(this, counter)}); then did counter++ also, in adder(param1, param2) , alert(counter) okay here's question: after doing that, when clicked on a1 has 2 handlers, alert output 2 (it alerts twice each handler) , a2, alert 2 when clicked. why happening? the reason returns 2 both anonymous functions creating closure on counter variable. means methods don't have current value of counter when bind them, have reference variable. any changes in variable later on reflected in captured variable. you can prevent creating new variable second binding: var counter = 0; function adder(e, counter) { ...

Python library for editing XML preserving formatting and comments -

i need make few changes existing xml files, while preserving formatting , comments - except minor changes should untouched. i've tried xml.etree , lxml.etree no success. the xml generated ide, editor lacking in functionality, have make few manual changes. want keep formatting diffs pretty , not polluting history. with multitude of python xml libraries thought i'd ask here if has done similar. how many , kind of changes need make? sounds me may better served using standalone xml editor (just google them, there lots). frankly, i'm kind of surprised ide doesn't have adequate search-and-replace needs. (most of ones i've seen have regex facilities this.) if need write program make xml changes, , don't want mess formatting , comments, best bet may open xml regular text file in python, , use regular expression library ( import re ) search-and-replace.

c# - Why Process.Start doesn't work from asp.net web service? -

why code runs on development computer (win7 32bit) , on target server(2008r2 64bit) console app. when try run web service on target server nothing. no error, nothing. if remove exitmsg = proc.standardoutput.readtoend(); then fail error: system.invalidoperationexception: process must exit before requested information can determined. [webmethod] public string getrunningprocesses() { processstartinfo pinfo = new processstartinfo(); pinfo.filename = @"e:\bin\pslist.exe"; pinfo.windowstyle = processwindowstyle.hidden; pinfo.createnowindow = true; pinfo.useshellexecute = false; pinfo.redirectstandardoutput = true; string exitmsg = ""; int exitcode = 1; using (process proc = process.start(pinfo)) { exitmsg = proc.standardoutput.readtoend(); proc.waitforexit(1000); exitcode = proc.exitcode; } return e...

Render a page as a saved HTML file using Rails 3.0? -

i'm building simple website generator application in rails 3.0. i'd "publish" action in controller works ordinary "show" action, instead, saves page html file in "public" directory instead of displaying in browser. is, i'd use rails render mechanism create file instead of providing http response. what's best way this? should add caches_page :publish controller? or use render_to_string , file.new ? you can use render_to_string method: http://apidock.com/rails/abstractcontroller/rendering/render_to_string you still need respond controller though. maybe redirect page saved?

python - Is it time.time() a safe approach when creating content types on plone programatically? -

i have use _createobjectbytype on plone. have argument id of object. going safe, in scenario, create id based on time.time() avoid collisions? can 2 requests have same timestamp shown time.time() ? you'll safe doing this, in unlikely event 2 requests processed @ same time, in event of conflict zodb raise conflicterror , retry request. responding discussion below: on single computer defition both transactions must overlap (you got same result time.time() in each thread.) zodb mvcc, each thread sees consistent view of database when transaction began. when second thread commits, conflict error raised because write object has changed since beginning of transaction. if have clients running on multiple computers need think possibility of clock drift between clients. transaction ids, zodb chooses whichever greater of either current timestamp or last transaction id + 1. however, perhaps should consider not using timestamp id @ all, lead conflicts under heavy load, r...

RegEx to validate a string, whether it contains at least one lower case char, upper case char, one digit,one symbol and no whitespace -

possible duplicate: regex make sure string contains @ least 1 lower case char, upper case char, digit , symbol what regex make sure given string contains @ least 1 character each of followings --- upper case letter lower case letter no whitespace digit symbol string length >=5 , <=10 how combine these above criteria validate string. if has regex: ^ # start of string (?=.*[a-z]) # upper case (ascii) letter (?=.*[a-z]) # lower case letter (?=.*\d) # digit (?=.*[\w_]) # symbol \s # no whitespace {5,10} # string length >=5 , <=10 $ # end of string or, if regex flavor doesn't support verbose regexes: ^(?=.*[a-z])(?=.*[a-z])(?=.*\d)(?=.*[\w_])\s{5,10}$

math - Sites with up-to-date OpenGL tutorials and examples -

i'm looking sites examples , tutorials opengl. opengl superbible seemed must-have got , seems bit complicated me @ moment due lack of math knowledge. therefore, have decided start out simple 2d-games shouldn't hard. tutorials , examples need up-to-date seems hard find. i'd love simple 2d game example pong or similar build upon. also: math necessary 3d-programming? possible me learn of myself (i'm 15 years old) or have wait college/late high school? as mentioned in other posts, nehe great. getting bit old though. lighthouse 3d pretty helpful well. up-to-date references, go straight opengl . it's great resource. real-time rendering great book computer graphics. website has tons of resources well. regarding math should know, linear algebra must in computer graphics. many computer graphics books provide overview of math should familiar with. book mentioned above ( real-time rendering ) provides great overview. decent book relating math requ...

Ruby on rails querying with join and condition statement -

i need query joining tables without using primary key(id). class user < activerecord::base has_one :participant end class participant < activerecord::base belongs_to :user end the user has 'id' , 'name'. participant has 'user_id' user.id i trying find participant.id querying user.name what have tried is, participant_id = participant.all :joins => :users, :conditions => {:name => "susie"} if you're looking specific user's participant id, go: user.find_by_name("susie").participant.id since user has has_one relation participant(which belongs -- one-to-one) can go call participant on user. activerecord takes care of join magicks

Rails: Create a custom UI for a single specific object -

i've run problem i'm unsure how approach. i have app sharing architectural photos. users have_many photos, , users can create collections have_many photos. now have 1 customer big name in industry work me create totally customized collection different , feel "regular" collections, same functionality underneath. i'd accommodate request, have no idea how it. given have functioning collection model , collectionscontroller , plus views, i'd re-use of possible. so, instance, custom collection needs override user facing :show view, not admin :edit view. how approach this? i'm trying understand efficient, dry method creating custom ui single record in database. i'd appreciative of suggestions, including links articles / books etc, haven't been able find in area. i allow creation of liquid view templates associated user and/or collection (if want both - per-user templates per-collection variations - use polymorphic association) ...

c# - How to update a record by id? -

i new entityframework , having trouble understand why first code doesn't update second does. aim update record without querying db. is obvious? using (chatdbentities db = new chatdbentities()) { // update buddy onlines buddy = new onlines(); buddy.id = 56; buddy.last_seen = datetime.now; buddy.status = (int)userstatuses.status.chatting; buddy.connected_to_id = 34; buddy.room_id = 2; db.savechanges(); } using (chatdbentities db = new chatdbentities()) { // update buddy var buddy = db.onlines.first(); buddy.last_seen = datetime.now; buddy.status = (int)userstatuses.status.chatting; buddy.connected_to_id = 34; buddy.room_id = 2; db.savechanges(); } it looks related "id" primary identity key. you have retrieve entity in order update it, can't create new 1 same id record database , expect ef magically know needs...

javascript - Password protect html page -

i need tack simple password protection onto arbitrary html files. need need secure, keep out random roff-raff. tried using below js: var password; var thepassword="secretpassword"; password=prompt('enter password',' '); if (password==thepassword) { alert('correct password! click ok enter!'); } else { window.location="http://www.google.com/"; } this works fine in firefox, seems prompt function fails in ie , redirect google... any suggestions on how simple password protection using straight html pages? edit: clear, works fine in firefox, , in ie not prompt popup asking "enter password" works fine me in ie. demo: http://jsfiddle.net/u2n3p/ one possible reason may not working you're populating prompt empty space, using ' ' , when start typing there may space @ end. change prompt to: password=prompt('enter password', ''); fyi, know said didn't need super ...

dynamic - Generating gnuplot eps files via script in php -

i asked similar question few days ago, of different flavor; more specific. i have php file creates gnuplot script dynamically, , runs script using 4 text files (1 per line of plot) created beforehand php file. the problem graph.eps files generated blank , cannot figure out. have feeling has directory text files in. this file generate , run. set terminal postscript enhanced color set size ratio 0.7058 set output '/srv/../a.2.5.1a.eps' set grid set key font "arial,10" set key center bot set key out vertical set key horizontal center set key box set style line 1 linetype 1 linecolor rgb "red" linewidth 2.000 pointtype 6 pointsize default set style line 3 linetype 1 linecolor rgb "#daa520" linewidth 2.000 pointtype 6 pointsize default set style line 4 linetype 1 linecolor rgb "#006400" linewidth 2.000 pointtype 6 pointsize default set style line 6 linetype 1 linecolor rgb "blue" linewidth 2.000 pointtype 6 ...

Java List toArray(T[] a) implementation -

i looking @ method defined in list interface: returns array containing of elements in list in correct order; runtime type of returned array of specified array. if list fits in specified array, returned therein. otherwise, new array allocated runtime type of specified array , size of list. if list fits in specified array room spare (i.e., array has more elements list), element in array following end of collection set null. useful in determining length of list if caller knows list not contain null elements. <t> t[] toarray(t[] a); and wondering why implemented way, if pass array length < list.size(), create new 1 , return it. therefore creation of new array object in method parameter useless. additionally if pass array long enough using size of list if returns same object objects - no point in returning since same object ok clarity. the problem think promotes inefficient code, in opinion toarray should receive class , return new array contents. is there rea...

c# - How can I run code inside a Converter on a separate thread so that the UI does not freeze? -

Image
i have wpf converter slow (computations, online fetching, etc.). how can convert asynchronously ui doesn't freeze up? found this, solution place converter code in property - http://social.msdn.microsoft.com/forums/pl-pl/wpf/thread/50d288a2-eadc-4ed6-a9d3-6e249036cb71 - rather not do. below example demonstrates issue. here dropdown freeze until sleep elapses. namespace testasync { using system; using system.collections.generic; using system.threading; using system.windows; using system.windows.data; using system.windows.threading; /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window { public mainwindow() { initializecomponent(); mynumbers = new dictionary<string, int> { { "uno", 1 }, { "dos", 2 }, { "tres", 3 } }; this.datacontext = this; } publ...

python - How to put html in django template variables? -

i want put in pieces of html in template variables. this: >>>t = django.template.template("<ul>{{ title }}<\ul>: {{ story }}") >>>c = django.template.context({"title":"this title",r"line 1.<br />line 2."}) >>>print t.render(c) <ul>this title<\ul>: line 1.&lt;br /&gt;line 2. i expected output this: <ul>this title<\ul>: line 1.<br />line 2. how can put in html within template variables? use safe filter, e.g.: t = django.template.template("{{ title|safe }}<\ul>: {{ story|safe }}")

jquery - How do I replace onclick button to link format -

here current code <input type="submit" value="result" id="loadbutton" /> $.ajaxsetup ({ cache: false }); var ajax_load = "<img class='loading' src='/loading.gif' alt='loading...' />"; var loadurl = "/result.php"; $("#loadbutton").click(function(){ $("#result").html(ajax_load).load(loadurl); }); how replace submit button <input type="submit" value="result" id="loadbutton" /> to link <a href="/result.php">result</a> the normal way: <a href="/result.php" id="result">result</a> <script> $('#result').click(function() { // }); </script>

jquery - Call custom client side validation function after WebForm_OnSubmit? .NET -

i want run simple js function after .net validator controls run javascript. onsubmit value javascript:return webform_onsubmit();, seems generated automatically , can't change it. am right in assuming need add function in field work? also, form validating after field has been changed (not once form has been submitted), great, there setting soimewhere turn on/off? thanks!!

php - Micro-optimizations: if($var){ ... } vs if($var): ... endif -

is if($var){ ... } faster if($var): ... endif ? which 1 use? i'm sure difference negligible, if there any. if difference is important you, should use faster (likely compiled) language. you better optimizing more intensive things, databases first (and writing clean code, @tim stated).

android - Necessary to quit a HandlerThread? -

my application makes use of handlerthread few operations shared across components need run on background thread. of time thread in wait state. can leave handlerthread running (waiting) in application, sending messages whenever necessary, never quitting via handlerthread.getlooper().quit() ? mean handlerthread continue exist in wait state after of application components have been destroyed. initially seemed big no me—something not want do—but i'm not sure now. when android kills process, when needs free cpu time or memory, it'll end thread along ui thread. additionally, thread waiting, wont consuming cpu time. , beyond that, application makes use of many asynctasks , know utilize thread pool. understanding, asynctask utilizes threadpoolexecutor , not adhere application lifecycle callbacks (the threads in pool when not in use, sit waiting). so question is, can use handlerthread across multiple application components, never (or rarely) quitting it, , leaving waiting...

android - Samsung Galaxy S adb driver details? -

i'm in pickle. live in korea , teach english developing android app. want test on samsung galaxy s. can't find adb driver drivers find versions of device. got driver details device? this question asked here link dead. can find american drivers here , chinese drivers here (i don't think there difference).

javascript - php:Mod rewrite giving me hard times finding base address.. need help -

im new mod_rewrite problem ruins ajax , php i use windows.location object current location javascript example: var str = location.pathname; str=str.slice(0,str.lastindexof('/')); problem never works since used mod_rewrite. .htaccess options +followsymlinks rewriteengine on rewriterule ^cars/([^/]+)/?$ profiles.php?carname=$1 [l] can body lead me way fix this. ? face same problem lading imgs , css/.js heard can write condition on .htaccess redirect .php !, i need way find base address ajax calls, , other way find base address php. the problem redirecting url php file , breaks other assets, including css , js. solution: use rewrite condition. way redirects if file or directory doesn't exist. rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^cars/([^/]+)/?$ profiles.php?carname=$1 [l] the first line : if file doesn't exist second is: if directory doesn't exist there redirect.

Create regex from samples algorithm -

afaik no 1 have implemented algorithm takes set of strings , substrings , gives 1 or more regular expressions match given substrings inside strings. so, instance, if i'd give algorithm 2 samples: string1 = "fwef 1234 asdfd" substring1 = "1234" string2 = "asdf456fsdf" substring2 = "456" the algorithm give me regular expression "[0-9]*" back. know give more 1 regex or no possible regex , might find 1000 reasons why such algorithm close impossible implement perfection. what's closest thing? i don't care regex also. want algorithm takes samples ones above , finds pattern in them can used find "kind" of text want find in string without having write regex or code manually. flashfill new feature of ms excel 2013 task want, not give regular expression. it's np-complete problem , open question practical purposes. if you're interested in how synthesise string manipulation multiple examples, go ...

scope - Tips for an intermediate javascript programmer to write better code -

so i'm decent javascript programmer , i've finished working on big web application involved writing quite bit of javascript. 1 of things can across when debugging script there namespace conflicts various global variables used throughout script. essentially, javascript file structured such: global var global var b global var c function1(){} function2(){} function3(){} with jquery document on-ready function bind various events buttons in html , call functions event handler callbacks. some people recommended encapsulating entire script in 1 gigantic function prevent scope-related errors. couldn't quite figure out entail. tips appreciated create web app involve quite bit of ajax page loads avoid browser refreshes , dom manipulation bound various events. thanks! i recommend reading jquery plugin authoring guide (i recommend consider using jquery if not) http://docs.jquery.com/plugins/authoring btw been asked many times (not criticism re-asking) jquery: ...

java - Best practice regarding REST services and I18N -

i have client app communicates server using rest services. client app multilingual means server must aware of user's locale during calls. want use "post location" approach has nice , restful feel it. when data gets posted actions resource uri is: /actions/{language} the language important can localize error messages (or returning data) get. when server responds needs send uri of resource. if send back /actions/{id} where id id of newly created resource, isn't entirely correct /actions/{language}/{id} would uri of localized resource. actual resource without language context. any opinions on best practice scenario? i'm not convinced language should part of "address", thing identifies resource, unless part of identity, , tension have between /actions/{id} and /actions/{lang}/{id} shows not right. one alternative approach use http header locale information pass language. pass language query parameter, modifier of reque...

How can I verify that a TCP packet has received an ACK in JAVA? -

after sending tcp data method (mine below) dataoutputstream outtoserver = new dataoutputstream(clientsocket.getoutputstream()); outtoserver.writebytes(string); how can verify in java tcp data sent successfully? or there way of reading ack received (from tcpserver) ? you cannot. operating systems typically not expose applications. if need know whether data has made other end, need implement acks @ application protocol, not @ transport level tcp concerns with.

gcc - Winsock2.h: FD_SET: comparison between signed and unsigned integer expressions -

excerpt winsock2.h: #define fd_set(fd, set) { u_int __i;\ (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) {\ if (((fd_set *)(set))->fd_array[__i] == (fd)) {\ break;\ }\ }\ if (__i == ((fd_set *)(set))->fd_count) {\ if (((fd_set *)(set))->fd_count < fd_setsize) {\ ((fd_set *)(set))->fd_array[__i] = (fd);\ ((fd_set *)(set))->fd_count++;\ }\ }\ } while(0) i passing in fd of type int , set of type fd_set * . looks cause of warning may originate #define fd_setsize . excerpt same header: #ifndef fd_setsize #define fd_setsize 64 #endif i redefined fd_setsize 64u prior including winsock2.h doesn't seem fix it. fd should of type socket u_int . the relevant line macro was: if (((fd_set *)(set))->fd_array[__i] == (fd)) { didn't occur me == comparison operator whatever reason.

php - htaccess block access to directory but allow access to files -

i have such situation. i'm developing application in zend framework , htaccess pointing every request index.php. if file or directory exists on request path htaccess allow access files css, js, images etc... now have example such link: example.com/profile/martin-slicker-i231 with zend router points controller account , action viewprofile. want add avatart users , created directory in public folder (so images accessible server css , js). directory named "profile" , subdirectory in "martin-slicker-i231". path visible server that: public/ .htaccess index.php profile/ martin-slicker-i231/ avatar-small.jpg the problem when point browser example.com/profile/martin-slicker-i231 points me directory not controller , action. when remove folder user flow go controller , action. how configure .htaccess example.com/profile/martin-slicker-i231 pointing controller , action request example.com/profile/martin-slicker-i231/avatar-small.jpg point f...

Android: Bundle.toString() and then create a Bundle from String -

i'm trying following: // have bundle , convert string bundle _bundle; // meanwhile put intergers, booleans etc in _bundle string _strbundle = _bundle.tostring(); later in code need create bundle _strbundle. how do that? far couldn't find information on this. of course don't wish parse _strbundle myself , hope fremawork provides string2bundle sort of functionality. as far know there no way framework know stored in string. same pattern have possible interpretations (string, boolean, integer) , don't think that makes sense. in fact can't imagine why need it. have bundle in first place. suggest keep original bundle , use when need or make parse of string , create bundle (which won't easy task if want cover possibilities).

javascript - Can we Directly remove Nodes from a NodeList? -

document.getelementsbytagname returned me nodelist object. i remove items (let's remove first item nodelist) is there way it? (i'm aware manually copy nodes array not wish if nodelist has functions remove elements in it) i aware removing items nodelist has no effect on display (and should not cause browser-display-refresh or stuff that, not wish nodelist object hold referennce node) is there way it? (or forced copy items in nodelist array?) as can see in specification , there no method remove element list. it not make sense anyway. nodelist live , meaning dom searched again whenever access property, e.g. length . mdc : (...) returned list lis live, meaning updates dom tree automatically. (...) so have to copy nodes array. you can quite though using array methods. e.g. copy , directly remove first element: var nodes = [].slice.call(elements, 1); the nodelist array-like object. hence can apply array functions it, using call [docs] . []...

groovy - What is the best approach to collect/define lastvisited information in Grails/spring security? -

what best practice or approach lastvisited information user in grails? user login, using spring security , want show few junks of information based on lastvisited date. far don't have property in user domain. please let me know different , possible approaches can collect aforementioned information within grails application. related query is, how can combat aforementioned problem when user closes window or tab in browser without pressing logout link/button? we ended pretty messy - happy know better way. we're saving visit info of: login - in action spring-security-redirect points to; login "remember me" - in applicationlistener.onapplicationevent(appevent) (we made service applicationlistener ): if (appevent instanceof authenticationsuccessevent) { if (appevent.source instanceof remembermeauthenticationtoken) { } } maybe place collect login events. logout - in our own logout action redirects j_spring_security_logout . we don't log ...

Nested and/or expression in subsonic 2.2 -

i need make query : select * table cola= "aaa" , ( (colb = "bbb" , (colc="ccc" or colc = "ddd")) or (colb="eee" , colc = "fff") ) i tried andexpression() , orexpression() , openexpression() or closeexpression() , can't figure out ! appreciated ! whereexpression , andexpression etc. should work (see this question ), doesn't work me time, neither. as long where clauses relatively simple, add repetition , use logical operator precedence : select * table cola="aaa" , colb="bbb" , colc="ccc" or cola="aaa" , colb="bbb" , colc="ddd" or cola="aaa" , colb="eee" , colc="fff" this result in this: db.select().from<table>() .where(table.colacolumn).isequalto("aaa") .and(table.colbco...

iphone - Help me to get the result based on condition -

i have created users class based on nsmanagedobject following attributes (id,name,age etc). i using core data model not sure how follwing... now know how can user detail based on user id. example: select * users id = 1 please me out. you should use nspredicate class executing sql commands. code: nsmanagedobjectcontext *context = self.managedobjectcontext; // specify moc object nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"users" inmanagedobjectcontext:context]; // specify entity (table) nspredicate *predicate = [nspredicate predicatewithformat:@"id == %d",yourid]; // specify condition (predicate) [fetchrequest setentity:entity]; [fetchrequest setpredicate:predicate]; nserror *error = nil; nsarray *array = [context executefetchrequest:fetchrequest error:&error]; // execute [entity release]; [predicate release]; [fetchrequest release]; if (array == nil) ...

.net - Entity Framework - GetObjectByKey don't allow the primary key -

i'm trying record using getobjectbykey function this: enumerable<keyvaluepair<string, object>> entitykeyvalues = new keyvaluepair<string, object>[] { new keyvaluepair<string, object>("journalid", new guid("6491305f-91d9-4002-8c47-8ad1a870cb11")) }; entitykey key = new system.data.entitykey(string.format("{0}.{1}", objectcontextmanager.current.defaultcontainername, "journal"), entitykeyvalues); but exception system.argumentexception: provided list of key-value pairs contains incorrect number of entries. there 54 key fields defined on type 'namespace.journal', 1 provided. parameter name: key the type journal view. how can use function 1 field, reason why need because don't want specify generic type , 1 given entity set name. thanks in advance view in database doesn't have key ef needs when insert view ...

objective c - How to use '||' in if-else statement in iphone appllication? -

if((([txtfldo1.text length] == 0 ) || ([txtfldo2.text length] == 0 ) || ([txtfldo3.text length] == 0 ) || ([txtfldo4.text length] == 0 ) || ([txtfldo5.text length] == 0 )) && (([txtfldr1.text length]== 0) || ([txtfldr2.text length]== 0) || ([txtfldr3.text length]== 0) || ([txtfldr4.text length]== 0) || ([txtfldr5.text length]== 0))) { //alert //return } this statement not work. access of propeties. tell me why? need access 1 txtfldo , 1 txtfldr. to access properties, try self self.txtfld00.text.length

servlets - jQuery scripts are not downloaded when the index page is opened on context root -

i have web application uses jquery ui. javascripts not downloaded , applied when browse context root directly , rely on welcome file: http://localhost:8080/projectname/ but javascripts downloaded , applied when browse welcome file: http://localhost:8080/projectname/myfiles/index.html my project structure below: projectname `-- webroot |-- myfiles | `-- index.html `-- web-inf `-- web.xml in web.xml , have defined welcome file index.html uses jquery ui. <welcome-file-list> <welcome-file>myfiles/index.html</welcome-file> </welcome-file-list> this can happen if path script source relative current request url, such example <script src="jquery.js"></script> when open page by http://localhost:8080/projectname/ then attempt download script from http://localhost:8080/projectname/jquery.js when open page http://localhost:8080/projectname/myfiles/index.html th...

.net - What alternative approach could be used in C# to avoid method returning `object` type? -

i know method returning list<string> @ moment. in (which occur quite in our application) scenarios, returns list having only one string. so return either string or list<string> . since it's unpredictable it'll return @ run time, @ present it's return type kept object . what alternative approach used avoid method returning object ? edit: have answer question what alternative approach used avoid method returning object ? ; without considering scenario described. list enough here. why return string ? list<string> single string in perfectly defined... use that! ambiguous api silly here. another option might ienumerable<string> , but... meh, return list single string !

class - C# Enumerations, Structs and Classes -

could enlighten me on main differences in c# between enumerations, structs , classes? use classes type of code never seen need use others? refering : introduction objects , classes in c# - introduction introduction objects , classes in c# - world's classes , objects in object-oriented programming programmers write independent parts of program called classes. each class represents part of program functionality , these classes can assembled form program. in our world have classes , objects classes. in our world considered object. example, people objects, animals objects too, minerals objects; in world object. easy, right? classes? in our world have differentiate between objects living with. must understand there classifications (this how name , concepts of class) of objects. example, i'm object, david object too, maria object. people class (or type). have dog called ricky it's object. friend's d...

properties - wix - fill edit-control with value from registry -

installer writting sql server's name registry during installing service. , created dialog window edit control user type servername . want fill control value registry in changemode. , if registry key empty fill default name. how possible resolve it? tried put registrysearch node control node. seems me it's not working.. appreciated p.s. looked information here: link1 . , tried code like: <property id="servconnstr" value=".\sqlexpress"> </property> <property id="connsearch"> <registrysearch id="servconstr" root="hklm" key="software\$(var.manufacturer)\service" name="sql server" type="raw"></registrysearch> </property> <setproperty id="servconnstr" value="connsearch" after="appsearch"><![cdata[connsearch , (!feature1=3 or !feature2=3 or !feature3=3)]]></setproperty> but i...

sqlite - how to remove u from sqlite3 cursor.fetchall() in python -

import sqlite3 class class1: def __init__(self): self.print1() def print1(self): con = sqlite3.connect('mydb.sqlite') cur = con.cursor() cur.execute("select fname tblsample1 order fname") ar=cur.fetchall() print(ar) class1() gives output shown below [(u'arun',), (u'kiran',), (u'kulku',), (u'sugu',)] i need remove u array , need output shown below ['arun', 'kiran', 'kulku', 'sugu'] if need strings retrieved sqlite database returned utf-8 instead of unicode, set-up connection accordingly using text_factory propery: import sqlite3 class class1: def __init__(self): self.print1() def print1(self): con = sqlite3.connect('mydb.sqlite') con.text_factory = str cur = con.cursor() cur.execute("select fname tblsample1 order fname") ar=cur.fetchall() print(ar) class1() see details: http://docs.python.org/library/sqlite3.ht...

javascript - how to pan two maps simultaneously overlay using div -

i having 2 maps overlayed using div. whenever pan map, map above base map moves , not base map. kindly tell if there way let mouse panning enabled both maps simultaneously. astha <style type='text/css'> /*<![cdata[*/ .modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .overlay { margin: auto; text-align: left; width: 800px; height: 532px; position:absolute; pointer-events:none; } .message { width: 800px; height: 532px; background-color: #fff; opacity: .35; filter: alpha(opacity=35); position:absolute; pointer-events:none; } /*]]>*/ </style> <script type="text/javascript" src="http://nls.tileserver.com/api.js"></script> <script src="http://maps.google.com/maps? file=api&amp;v=2&amp;sensor=false&amp;key=abqiaaaa9psslyayyyl6x8hkrhazvxs4-aljfz9cxp3qiyslghiyxf9uhht0nlb9b9bxguggdctso4qva1jlla" t...

Save Data of LogCat in android -

i want save contents of log cat specific file in android. used eclipse ide develop android application. how can achieve ? thanks. here way logcat contents progrmatically. process process = runtime.getruntime().exec("logcat -d"); bufferedreader bufferedreader = new bufferedreader( new inputstreamreader(process.getinputstream())); stringbuilder log=new stringbuilder(); string line = ""; while ((line = bufferedreader.readline()) != null) { log.append(line); } check this link more details.

ajax - use html5 multiple attribute to trigger multiple single uploads -

sorry confusing title. i have form-- form1 has 1 file input ( multiple attribute set user can select mutiple files). form doesn't submitted. i have form -- form2 has single file input . no mutiple attribute. now via javascript fetch each files fileinput previous form , assign file form2's input field , ajax submit. once ajax submit complete same 2nd file , 3rd file , on. i don't want use flash or java applet. aware ie doesn't support multiple attribute opera can use invalid min max attribute same. my basic question how fetch files form1 input field , assisgn form2's field .. is there solution ? or approach incorrect ? what want achieve on ui side ? file gets uploaded , server processing , returns data. want user can select 10 files 1st file uploaded output received. first : idea wrong. cannot assign value via javascript input type = file . i thought of idea using xmlhttprequest. here code : <form id="new_picture_form" meth...

C# Unit Test Case Help -

i learning c# (coming java background) , trying implement test cases in practice. have been through few examples of creating test cases basic , dealt obvious constraints (i.e., angle between 0-360). i going thru examples of creating forms , have not been able find examples on implementing tests forms. done , if give me few examples of test int following example: namespace tabcontrolexample { public partial class form1 : form { public form1() { initializecomponent(); createnewcompanytab("test company 1"); createnewcompanytab("test company 2"); } private void createnewcompanytab(string companyname) { basecompanypanel companypanel = new basecompanypanel(); tabpage tabpage = new tabpage(); // set tab text tabpage.text = companyname; // set companypanel.parent value tabpage // insert companypanel tab ...

jquery - Open pirobox lightbox on load instead of click -

i need in opening pirobox lightbox on page load instead of clicking on it. http://www.pirolab.it/pirobox/index.php pirobox doesn't support explicitly, can programmatically trigger "fake" click onload. for example: <script type="text/javascript"> $(function() { $('#myid').click(); }); </script> <body> <a href="big1.jpg" rel="single" class="pirobox" title="your title" id="myid"> <img src="small1.jpg" /> </a> </body> here's fixed version of original approach (though do not recommend using inline javascript this!): <script type="text/javascript"> function open_popup() { $('#myid').click(); } </script> <body onload="open_popup()"> <a href="big1.jpg" rel="single" class="pirobox" title="your title" id="myid"...

c# - .Net division rounding/decimal differences between web servers -

i've got problem that's baffling me bit. here's bit of background: in process of upgrading asp.net 2.0 web app .net 4 onto 64 bit server. have test app deployed both new , old servers make sure things work expected before go live; both of point same database on server. here's problem: double totalgross; double totalnet = 9999999.00; float taxrate = 15.00f; totalgross = totalnet * (1 + (taxrate / 100)); on old server, .tostring() on totalgross produces: 11499998.85 on new server, .tostring() on totalgross produces: 11499998.6115814 currently @ loss why might be? latter value doesn't represent first number un-rounded? by way - i'm not after ways correct/improve code... after possible reasons why happen! update i created console app , built in x86 , x64 , ran both versions on server , outputted 2 different figures. indeed seem sort of loss of precision between 32bit , 64bit when using double. surprise me 'loss of precision in question 0....

python - How do I get an event callback when a Tkinter Entry widget is modified? -

exactly question says. text widgets have <<modified>> event, entry widgets don't appear to. add tkinter stringvar entry widget. bind callback stringvar using trace method. from tkinter import * def callback(sv): print sv.get() root = tk() sv = stringvar() sv.trace("w", lambda name, index, mode, sv=sv: callback(sv)) e = entry(root, textvariable=sv) e.pack() root.mainloop()

Java <identifier> expected error? -

i 20 errors in middle loops when compiling program; following snippet: public static long[] bishopsmasks() { long[] masks = new long[64]; (int j = 0; j < 8; j++) { (int = 0; < 8; i++) { long x = 0l; (int = + 1, int b = j + 1; < 7 && b < 7; a++, b++) x |= bit(a, b); (int = + 1, int b = j - 1; < 7 && b > 0; a++, b--) x |= bit(a, b); (int = - 1, int b = j + 1; > 0 && b < 7; a--, b++) x |= bit(a, b); (int = - 1, int b = j - 1; > 0 && b > 0; a--, b--) x |= bit(a, b); masks[i + j * 8] = x; } } return masks; } i can't find wrong it! you can't declare multiple variables in for-loop initializer this: for (int = + 1, int b = j + 1; < 7 && b < 7; a++, b++) you can, however, (note removal of int before b ): ...

xcode - Stumped: property list works in simulator and in other Apps, but not when I test on the iphone 4 -

i'm working on app writes data out .plist view , pulls in populate uilabels in view. i've done several times in past , has worked fine on both device , simulator. time it's working fine on simulator not on device. i've been through looking @ connections , code can't find why it's not functioning. suspicion reason data not @ end of file path, if isn't can't understand why case. i've tried cleaning targets through menu , deleting , reinstalling app on testing device in hope may rectify situation, no joy. can offer insight why i'm having problem , how rectify it? it's why works on simulator not phone confusing me, when i've used same code in past make functioning apps. i'm using xcode 4 , testing on iphone 4: the code follows. first check see if there data @ end of data file path this: - (nsstring *)datafilepath { nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstrin...