Posts

Showing posts from July, 2014

ipad - Split view in portrait mode! -

apple provide split view landscape not portrait mode. there way achieve splitview in portrait mode also? [splitviewcontroller sethidesmasterviewinportrait:no]; this work. api not documented(private). thanks, manjunath for ios5+, go detailviewcontroller . detailviewcontroller should have uisplitviewcontrollerdelegate . , drop code in: - (bool)splitviewcontroller:(uisplitviewcontroller *)svc shouldhideviewcontroller:(uiviewcontroller *)vc inorientation:(uiinterfaceorientation)orientation{ return no; } this trick. , public api.

Django reset_password_confirm TemplateSyntaxError problem -

when use django.contrib.auth.views.password_reset_confirm without arguments @ works , can render template without problem, when adding uidb36 , token arguments fails. caught noreversematch while rendering: reverse 'django.contrib.auth.views.password_reset_confirm' arguments '()' , keyword arguments '{'uidb36': '111', 'token': '1111111111111'}' not found. most issue urls.py. need setup right pattern grab uidb36 , token values passed url parameters. if not, throw similar error see above. something like: (r'^reset/(?p<uidb36>[0-9a-za-z]+)-(?p<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name' : 'registration/password_reset.html', 'post_reset_redirect': '/logout/' }) registration/password_reset.html - custom template logout - custom logout action

html - php reservation system -

i m creating project php , html use.i create ticket reservation system university.firstly,the user choose date , number of persons wants reserve tickets.then,by pressing next button,he see list of events available in date checked in previous step.this list static,so think have create data base have data , if users selects ex monday,he see data events monday.could please me because have no big experience php?i have created 2 screens html , css 1st let me know how create data base data , secondly how connect them day oprtions! thanks lot! take at: php 101: simple seat reservation system

sql - It is possible to do a autonumber sequence in a SELECT on Oracle? -

i need task in oracle don't know how can possible this. ok, need select when define autonumber sequence on-the-fly. for example: select autonumber(1, 9000) auto some_table and result be auto ------ 1 2 3 4 5 6 7 8 9 10 ... 9000 this possible do? there oracle build in function me doing this? select rownum dba_objects, dba_objects rownum <= 9000;

php - mysql chinese column -

to store chinese characters in mysql, recommended store them utf8 or ucs2? (i using char , varchar) also, have seen utf8 uses 4 bytes of data store values. how many ucs2 use? i have seen utf8 uses 4 bytes of data store values. how many ucs2 use? utf-8 consists of variable length characters ranging 1 3 bytes, ucs2 (utf-16) fixed 2 bytes per character. to store chinese characters in mysql, recommended store them utf8 or ucs2? i have no experience chinese characters, top answer question answers basic question quite nicely: difference between utf-8 , utf-16? from there: most reasonable characters, latin, cyrillic, chinese, japanese can represented 2 bytes. unless exotic characters needed, means 16-bit subset of utf-16 can used fixed-length encoding, speeds indexing. it seems chinese characters, ucs-2 tends save storage space. if web project, tend use utf-8 because more widespread encoding, , standard in web world. additional arguments utf-8 here: sho...

django - how to restart single apache site on a ubuntu vps rather than all sites -

i've got ubuntu vps , apache mod wsgi installed , serving django sites. however have restart of apache rather site have amended , going bit shonky if tell clients have restarted site cos updated site. is there tutorial somewhere teach me how configure this? couldnt find 1 in googles keywords soup. i'm using virtualenvs if helps. assuming use mod_wsgi in daemon mode on unix/apache 2.x system run django , have shell access machine need touch wsgi configuration project. touch your_project.wsgi see mod_wsgi documentation on reloading source code , django - mod_wsgi wiki more references.

python - file_downloads..want to download an uploaded file -

hi project upload excel file , display content in template. have uploaded excel file in django using models.filefield .now want download particular file @ defined location(project).i trying click on uploaded file giving me error page not found (404) request method: request url: http://localhost:8001/admin/ikapp1/fileupload/2/file/erode/erode_3.xls/ file upload object primary key u'2/file/erode/erode_3.xls' not exist. shot in dark, omit last slash in url? indicates want directory.

javascript - mime-type autodetection of .js file fails for http upload in firefox -

i'm using http upload transferring javascript file server. however, firefox sends content mime type set 'x-c'. opera 11 better in assuming 'application/x-javascript' still incorrect. i'd prefer avoid server-side mime type detection, there chance override mime-type detection specific file extensions (namely '.js') or provide hints browser algorithm ? the ideal solution cross-browser ( @ least ff 3.6, ie8, chrome 8 should supported ). however, first step solution limited firefox welcome, too. platform details: ff 3.6.13 on winxp sp3 uploaded file: jquery 1.4.4 ( uncompressed , minified versions ), elementary test files files have .js extension thanks in advance efforts. best regards, carsten now html5 can read file properties using javascript file api, way can things checking mime type, name or file size. unfortunately available in firefox , chrome fir moment. <input type="file" name="file" id="file...

iphone - Will old source code run with SDK 4.2? -

i've been working on creating own iphone app source code company gave me. code created iphone sdk 3.0. i've worked on over year (i'm designer coding copy , paste) , test app on iphone says must update sdk 4.2. i'm wondering break app? don't have skills in xcode upgrade code if required rewrite parts. thanks, chris if none of code has been deprecated, changed or removed, chances still runs fine. projects run, , if have used external code (and noted got from) there might update available piece of code.

image - Google Traffic and CDN -

i have moved images website content delivery network on domain. and, result, lost google image search traffic. damage permanent or traffic return, images on domain still allow site in image search results? maybe should have moved images gradually? advise? it's gone because google can no longer find images had spidered, google of course find new locations there no guarantee rank images same before. the best way recover implement 301 redirects using .htaccess file. depending on how you've moved images , if in same or different folder structure may require bit of work fix.

.net - C# either return false or do nothing -

i wondering if there's way not have repeat same if construction rather call statuscheck() . can't return true when succeeds. anyone knows better title question? bool enable() { if (!getstatus(ref status)) { trace.writeline("error"); return false; } // stuff if (!getstatus(ref status)) { trace.writeline("error"); return false; } // more stuff if (!getstatus(ref status)) { trace.writeline("error"); return false; } // more stuff // 6 more times above return true; } you can create checkstatus() method throws exception if status not valid, handle exception in enable() method: public void checkstatus(int status) { if (!isvalidstatus(status)) { throw new invalidstatusexception(status); } } public bool enable() { try { checkstatus(status); // stuff checkstatus(status); // more stuff checkstatus(status); // more stuff // 6 ...

wcf - parameters in service route -

working on wcf webhttp project , had question on parameters in route composition. i have 2 services - project service (that allows user add , view projects) , item service allows users view items inside project. there can multiple items in single project. i have urls of form localhost//projects//addproject localhost//projects//{projectid}//item//additem localhost//projects//{projectid}//item//getitem//{itemid} i have twoservices itemservice , projectservice. itemservice has methods additem , getitem projectservice has methods addproject how declare these services in global routes? tried routetable.routes.add(new serviceroute("projects/{projectid}/item", new webservicehostfactory(), typeof(itemservice))); gives me error i can add code projectservice maintainability of code have both projectservice , itemservice just suggestion: you can create controller called, say: "projectcontroller". add methods it, call service(s), say: a....

javascript - Ajax response with newlines for textarea -

i have problem concerning ajax-request should return string server newlines (\n) fill textarea. when following javascript, works , shows 2 lines in textarea: function filltextarea(){ document.getelementbyid('mytextarea').innerhtml = "line1\nline2"; } but if value server using ajax, \n treated other characters of string , there's 1 line function filltextarea() { new ajax.request("/myurl/....",{ asynchronous:true, evalscripts:true, onsuccess:function(transport){ document.getelementbyid('mytextarea').innerhtml = transport.responsetext; } }); } does know how deal newlines in responsetext of ajax request? don't use .innerhtml = "line1\nline2" . use .value = "line1\nline2" instead. value form values. not setting html contents here.

c# - Adding Data to existing DataTable's DataRow -

i want add data existing datarow in datatable. idea is, without copying data exists. when writing tests, found out directly inserting data slower copying both existing data , new new row , add row. or doing wrong? first create datatable initial data. fill initial data: datatable table1 = new datatable(); int count = 15; (int = 0; < count; i++) { table1.columns.add("hallo" + i, % 2 == 0 ? typeof(int) : typeof(string)); } int newstartindex = table1.columns.count; datetime pre = datetime.now; (int = 0; < 100000; i++) { datarow row = table1.newrow(); (int j = 0; j < table1.columns.count; j++) { if (j % 2 == 0) { row[j] = 502; } else { row[j] = "test"; } } table1.rows.add(row); } afterwards add 15 columns , data. for (int = count; < 2 * count; i++) { table1.columns.add("hallo" + i, % 2 == 0 ? typeof(int) : typeof(string)); } foreac...

Email File Link via .bat file, full link isn't displaying email email body -

i'm trying write batch file in sendto menu, when send file it, email generated file hyper-linked in email's main body. but, output partial in email's body, believe until first space in file's path: <d:\documents below code generates above result. :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: batchfile : emaillink.bat :: author : darksprout :: purpose : email file link via outlook using richt-click 'send to' menu :: note : save file in %userprofile%\sendto :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[jan11]~~ @echo off set _attachmentlink=%~f1 :: echo %_attachmentlink% start mailto:?body=^<%_attachmentlink%^> i promise have looked throughout stack overflow possible resolution. thanks in advance. you need quotes around argument if may contain spaces. , need set of empty quotes satisfy start : start "" "mailto:?body=<%_attachmentl...

Observing keydown events in JavaScript when two keys are pressed simultaneously -

i'm developing browser game using javascript player can move avatar in 4 directions. in order register simultaneous key presses observe keydown , keyup events , keep track of keys pressed , released. way can move avatar in diagonal direction if example cursor up , cursor right pressed @ same time. it's same principle reply here on stackoverflow in javascript, how tell if user pressing 2 keys @ same time? demonstration http://jsbin.com/iloxi . however there's flaw in solution can reproduced in demo. example press cursor down , start pressing cursor right . box moves bottom right. release cursor right while still pressing cursor down . box stops moving. should happen box keeps moving down. the problem javascript stops sending cursor down keydown events cursor right pressed. once cursor right released there's no way of knowing cursor down still being pressed. is there solution problem? update: problem demo box moved either in keydown or keyup ...

c# - How do I suppress automatic generated columns in a DataGridView? -

Image
when assign source (a datatable) datagridview, automatically generates columns each data column in data table. want columns defined manually. how suppress creation of these columns? you need open column editor , uncheck box auto generate fields. towards bottom left of dialog. if creating gridview code there property: datagridview.autogeneratecolumns = false;

javascript - Mootools - Scope problem in IE -

im starting play mootools not sure why following hide me options in select list, in ie not: <select id="test_select" multiple> <option>a</option> <option>b</option> <option>c</option> </select> $$('#test_select option').each(function(el){ el.addclass('hide'); }); i appreciate bit of on this... to hide option in select must remove option select in ie. here explanation in further detail hide option in select to remove option element select w/ mootools can following: jsfiddle $$('#test_select option').each(function(el){ if(el.get("html") == 'a') el.destroy(); });

android - Clearing a multiline EditText -

i trying clear multiline edittext field inside oneditoractionlistener.oneditoraction method. but using of obvious ways i.e. ((edittext) view).geteditabletext().clear(); ((edittext) view).geteditabletext().clearspans(); ((edittext) view).settext(""); only clears visible characters - leaving the newlines in field (which have manually deleted). is there way 'completely' clear multiline edittext field ? (or @ least - know why above don't work ?) solved (in minute after night's sleep) - newline being added after clearing text because oneditoraction method implementation returning false (for other reasons). returning true indicates 'enter' has been processed/consumed , clear() behaves expected: edittext.setoneditoractionlistener(new oneditoractionlistener() { @override public boolean oneditoraction(textview view,int actionid,keyevent event) { post(view.gettext().tostring()); ((edittext) view).getedi...

Implement editor in Java -

i need implement editor 3 custom languages ( intellisense, search & replace, syntax highlighting, region in c# visual studio ) in java. best class ( jeditor, jpanel or other ) ? take @ xtext . it's framework on top of eclipse platform autogenerates of infrastructure (like syntax highlighting , autocomplete) language grammar - pretty powerful editor in minutes rather months of work.

Python's xml.etree.ElementTree equivalent to C++ XML library -

i found xml.etree.elementtree library versatile , handy xml processor. how c++? found c++ xml tools (xerces-c++, tinyxml), it's more xml.dom . have @ cpp-elementtree . it's tested @ point , designed mimic effortless api you're used to.

jsf 2 - Eclipse Java Build Path does not find jars when launch with eclipse Helios -

Image
hope can me out problem, have web apps(jsf 2.0) in eclipse helios, have created class uses apache.commons.validator because need validate url , ips addresses, compiles find launch quite nicely when ccame time use urlvalidator java.lang.noclassdeffounderror: org/apache/commons/validator/urlvalidator @ com.outboundfactory.bean.validator.urlconverter.getasobject(urlconverter.java:34) @ com.icesoft.faces.renderkit.dom_html_basic.baserenderer.getconvertedvalue(baserenderer.java:91) @ javax.faces.component.uiinput.getconvertedvalue(uiinput.java:1023) @ javax.faces.component.uiinput.validate(uiinput.java:953) so workaround found put jakarta-oro , apache-commons-validator tomcat libs directly thats no solution either. know if there special configuration put libs in eclipse. here shot of how have configured i you're using maven mvn eclipse:eclipse add in jars.

configuration - ASP.NET inner directory virtual path root -

i have 2 separate web applications named mainweb , reports. want deploy them way: there 1 virtual application mainweb, pointed, instance, c:\inetpub\www\mainweb . the reports application deploy in subdirectory of main web, @ c:\inetpub\www\mainweb\reports . thus can combine 2 logically coupled want have them in separate projects easy manipulation. the problem is, in reports project use constructs ~/style/whatever.css works fine when running standalone reports application when using subdirectory in main web, resolves http://localhost/style/whatever.css though need resolve http://localhost/ reports /style/whatever.css . so question is, possible handle situation, maybe way modify behavior of ~ in nested web.config? not webby guy, how shortcut real folder in reports?

javascript - Permitting moving only of <img>s within contentEditable <div> -

i struggling achieve desired behaviour div marked contenteditable . wish allow user move img around within div , maintained inline, not let them resize or otherwise modify img . should otherwise able modify text within div . the default browser behaviour may seen below, img being able both moved , resized drag-handles: <html> <head> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> </head> <body> <div id="edit" contenteditable="true"> here text, , <img src="http://img841.imageshack.us/img841/1747/imagead.png" /> image </div> </body> </html> i have been playing around various client scripts attempt achieve desired functionality, each combination attempt seems run difficulty. can achieve ultimate lockdown with: <script type="text/...

Authorize.net report refresh rate? -

i submitting transactions, don't see them in authorize.net account. getting response authorize.net. how long take records show in reports section? i submitting https://secure.authorize.net/gateway/transact.dll to see unsettled transactions in authorize.net account, click "search" in top navigation , "unsettled transactions" in left navigation. once have been settled show under "reports" section.

osx - Java DTrace bridge on OS X -

i trying grab filesystem events on os / kernel level on os x. there 2 requirements have follow. first 1 in java whole project im developing written in java. second 1 have find out when document opened. for linux used inotify-java, can't find equivalent on os x. jna doesn't provide helpful binding. i'm avoiding catching events calling lsof program. this, however, bad solution. thanks help. you can use dtrace on osx, since needs root privileges it's not you'd want put runtime of system. in case, won't able in pure java (any java api wrapper around lower level c introspection, , if you're doing kernel-wide, need done root). if want track when program opening files (as opposed other files on same system) can install own security manager , implement checkread() family of methods, should give idea of when accesses happening. import java.io.*; public class demo { public static void main(string args[]) throws exception { system.setsecu...

Windows 7 32-bit Program Files path in a Batch file Issue -

i have batch file inheriting , cannot work in 64bit windows 7 environment. batch file makes call java script, , passes 2 variables in it. old on looked this: c:\progra~1\salesf~1.com\apexda~2.0\bin\process.bat c:\progra~1\*path* *variable* this run onm 32bit xp has 1 program files. have tried every way can think of change being of the path program fiels x86. have tried set path, set execpath, %progrmafiles(x86), return cannot find path specified. sure answer easy, , know there beeter way this, , changed, moment, need work. help, appreciated. if type dir /x c:\ then shows directory listing in 8.3 format. program files expands progra~1 , program files (x86) expands progra~2 . think you'll need change script use progra~2 edit: agree mark isn't ideal -- depends how able change of legacy scripts. on win7 machine should able use %programfiles% , %programfiles(x86)% (note trailing '%').

c++ - Default inheritance access specifier -

if have example 2 classes a , b , such class b inherits a follows: class b: public a in case, i'm doing public inheritance. if write previous code follows: class b: a what type of inheritance doing here (i.e; public)? in other words, default access specifier? just side question here. call previous line of codes statements ? remember read in c++ without fear: beginner's guide makes feel smart book statements that end ; . think that? thanks. just small addition existing answers: default type of inheritance depends on inheriting type (b), not on 1 being inherited (a). example: class {}; struct b: /* public */ {}; struct {}; class b: /* private */ {};

Store images in a MongoDB database -

how can store images in mongodb database rather text? can create array of images in mongodb database? possible same videos? please see gridfs docs details on storing such binary data. support specific language should linked @ bottom of screen.

javascript - Set default value of a password input so it can be read -

Image
i want have password field says "password" in before user enters password (so know field is) i'd rather use javascript, importing jquery alone seems wasteful, have no idea how to. images explain quite clearly: what looks like: what want like: it's simple website , basic of logins (has no validation etc) any ideas? <input id="username" name="username" class="input_text" type="text" value="username" /> <input id="password" name="password" class="input_text" type="password" value="password" /> change password input simple input type text . then, javascript (or jquery) on focus event, change input type password . here little untested sample plain javascript (no jquery): <html> <head> <script type="text/javascript"> function makeitpassword() { document.geteleme...

java - How to reload web site each time the app is called -

i new android programming , trying find way make app loads web site each time called below code , works great first time if go app 2nd time displays app view , not web site. guess oncreate not right funcation use can please me public class mysite extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); string url = "http://www.mysite.com"; uri uri = uri.parse(url); intent = new intent(intent.action_view, uri); startactivity(i); } } your app isn't exiting, it's hiding... want onresume() not oncreate() http://developer.android.com/reference/android/app/activity.html#activitylifecycle

Magento Email Template If Statements -

the magento email template if statements aren't evaluating true when expect them to. can tell me what's wrong? take @ following code: {{var customer.group_id}} {{if customer.group_id}}print true{{else}}print false{{/if}} {{if customer.group_id==4}}print true{{else}}print false{{/if}} {{if customer.group_id=4}}print true{{else}}print false{{/if}} {{if customer.group_id eq 4}}print true{{else}}print false{{/if}} the output is 4 print true print false print false print false i tried putting quotes around 4, same result. how evaluate equalities magento email template if statements? digging through code, looks template logic implemented varien_filter_template (under lib\varien not app\code) in filter function issues callback ifdirective function if pattern matches regex. ifdirective in turn uses _getvariable function evaluate if condition. _getvariable tokenizes condition in varien_filter_template_tokenizer_variable either property or method. if($...

Basic JPA issue: "Could not determine type for: java.util.Set" -

i'm getting started building jpa schema in play framework web app. have reasonable understanding of sql, i'm jpa newbie, , i'm being tripped @ first hurdle. from play tutorials i'm assuming create java classes , jpa/play automagically create schema you. so want create manytomany relationship between 2 model classes, rankable , tag: @entity @inheritance(strategy = inheritancetype.joined) public class rankable extends model { public string name; private set<tag> tags; @manytomany() @jointable(name = "rankable_tags") public set<tag> gettags() { return tags; } @manytomany() @jointable(name = "rankable_tags") public void settags(final set<tag> tags) { this.tags = tags; } } and other class: @entity public class tag extends model { public string name; public string description; private set<rankable> rankables; @manytomany(mappedby = "tags...

javascript - Queue AJAX calls -

hello doing horizontal scrolling website like: http://vanityclaire.com/ however, rather having 1 large html file, after load of homepage, ajaxing in children of home, using jquery .load(). at present for-each div , ajax in ithe url sits in title. ajax returns out of order, , add more pages don't fancy spanging server 30+ http:// requests. how synchronously ajax calls, i.e. wait first comeback before request another, or send 2 @ time. i have been scouring, , cannot figure out need. this html: <div id="mainlayout" class="fullwidth scrollarea"> <div class="scrollitems"> <div id="page-1" class="scrollitem" title="/"> <div>home page content</div> </div> <div id="page-2" class="scrollitem" title="/page2.html"> <div class="loading"> </div> </div> <div id="p...

mysql - convert one specific query from text field to date for arithmetic functions -

i have thoroughly searched have been thoroughly confused @ how convert returned sql query fields. i've found how convert whole column text field date not specific query. i'm not sure how update, set, etc. imported csv file of names , ates, , query (in phpmyadmin) returns desired text field this: select meta_value `drabble_postmeta` meta_key = 'date_paid' this returns 130 fields need convert pure text field uniformly using mm/dd/yyyy (ie 11/2/2010) format using "date" field can sort date_paid. one meta_value has text field "11/2/2010". meta_value longtext. don't know if want use operator because i'll need read other meta_value fields id of columns == id of found date_paid . use str_to_date function. select str_to_date(meta_value,'%m/%d/%y') date_paid `drabble_postmeta` meta_key = 'date_paid'

.net - How would I get a numeric up down to wait until user is finished typing? -

almost same question .net --- textbox control - wait till user done typing but numericupdown says on textchanged event: (this event supports .net framework infrastructure , not intended used directly code.) . want user able type number , if key not pressed after interval (500ms example) valuechanged event fires (or custom method call made). i'd rather not go using textbox vscroll bar, there way or... msdn warning isn't justified use case? use valuechanged.

Android How to reuse a header layout as an empty view in a ListView -

i've been grappling problem throughout life of project. have many lists in project , of them have headers. have been making separate layout file , adding list using addheaderview(). problem when data (arraylist, in case) empty, header doesn't appear. after hours of searching way reuse header layout empty view, gave , decided replicate layout in code , assign empty view using setemptyview(). problem lot of headers contain clickable views , have double of clickable logic every view duplicated. tried include header before failed, because still don't quite understand how layouts inflated, etc. finally, have come solution share community, in case others having similar problem. don't know if best way solve problem , feedback or suggestions welcomed. here code layout contains list list view: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill...

Need to restrict TFS users by IP -

we have 2 subnets (vlan1 , vlan2). tfs installed on server both network interfaces . domain controller subnets. vlan1 main office many computers (and users). vlan2 in highly secured area developers only. vlan1 users use tfs posting bugs, viewing progress etc. vlan2 users use @ full. the problem - restrict access sources vlan1 even developer user accounts . denying access tfs vlan1 developer users - valid answer too, not know how(( any ideas?? edit - comment answer @robaticus the point restrict reading sources outside. if block (at network) port 8080 (the default), users won't have access tfs through team explorer, through website @ port 8090 (also default). valid users still able view source through web portal, not able update it. edit based on requirement restrict reading of sources people outside, if first mentioned above (blocking 8080), secure directories source control under team system web access. might little ugly (giving 401 errors), might work. ...

python - How do I make backslash (\) work in IDLE? -

i use mac , use shift + alt + / when want type \ . i'm trying learn python , can see \ works fine, not in idle. how make backslash (\) work in idle? since problem still persists on osx 10.8 python 2.7.5 , 3.3.2 , since first google hit when searching backslash idle here more practical solution instead of copy , pasting: go to: idle->preferences->keys under action-keys replace: expand-word <option-key-slash> with instance: expand-word <control-option-key-slash> this should fix it.

java - Possible to create AtomicReference that can be swapped atomically? -

is there way implement type of reference value can exchanged atomically? in java have atomicreference can swapped local variable not atomicreference . you can do: atomicreference r1 = new atomicreference("hello"); atomicreference r2 = new atomicreference("world"); and swap them combination of 2 operations: r1.set(r2.getandset(r1.get())); but leaves them in inconsistent state in between, both contain "hello" . if swap them atomically, still not read them (as pair) atomically. what able is: pairableatomicreference r1 = new pairableatomicreference("hello"); pairableatomicreference r2 = new pairableatomicreference("world"); atomicrefpair rp = new atomicrefpair(r1, r2); then object[] oldval, newval; { oldval = rp.get(); newval = new object[] {oldval[1], oldval[0]}; } while (! rp.compareandset(oldval, newval)); to swap values, , in thread: atomicrefpair otherrp = new atomicrefpair(r1, r2); system.out....

c# - Pass Type as a parameter to a function -

i have dictionary object dictionary<string, type> dict = new dictionary<string, type>(); i have baseclass , number of child-classes, say: childclass1 , childclass2 , etc. dictionary has values: dict.add("type1", typeof(childclass1)); dict.add("type2", typeof(childclass2)); my question - there way this: baseclass c = new <<get type dict: dict[type1]>>()? i want make solution more flexible, i'm not sure if that's possible @ all. thanks! var c = (baseclass)activator.createinstance(dict["type1"]);

iphone - Clipping a CGGradient to a CGPath -

i've been banging head against wall long while trying figure out why not working. basically, trying plot graph (chart) cgpath , use clip gradient. end effect should stocks app comes iphone. the gradient , path draw fine separately 2 layered (unclipped) elements. if comment out cgcontextdrawpath, neither line nor gradient draw screen. here's drawrect code: cgcontextref context = uigraphicsgetcurrentcontext(); [[uicolor whitecolor] set]; cgcontextsetlinewidth(context, 2.0f); cgpoint lastdrawnpt = [[points objectatindex:0] cgpointvalue]; cgpoint firstdrawnpt = lastdrawnpt; //create path gradient cgmutablepathref thepath = cgpathcreatemutable(); cgpathmovetopoint(thepath, null, lastdrawnpt.x, self.bounds.size.height); // bottom left cgpathaddlinetopoint(thepath, null, lastdrawnpt.x, lastdrawnpt.y); (int i=0; i<(points.count-1); i++) { //cgpoint pt1 = [[points objectatindex:i] cgpointvalue]; cgpoint pt2 = [[points objectatindex:i+1] cgpointvalue]; if (p...

c# - Dangerous to store a well hashed password and the method used to hash it in plain sight? -

i developing client-side application in c# communicate server (php page) credentials , critical services. wondering if it's dangerous store hashed password on client's machine? "well hashed", mean random seed using well-known secure hashing function. purposes of discussion, assume source freely available (as binaries can reverse engineered). my thought store username , hashed password on user's computer , username , hash sent in plain text on unencrypted http connection server validation. of course not prevent hacker using else's username , password hash own without knowing source password (with code tweaks). would malevolent individual able hashed password , code used produce hash? (other log in other user if obtained information) what other client-side applications prevent 1 user logging in other user, if hacker not have access source password? (for example steam) is there easy, cheap (both cost , time), more secure way handle this? example of ...

flex - How do I get a bounding box for the current selection? -

i'd fancy things selection indicator. how bounding box selected characters? this non-trivial. first, selection may require more 1 rectangle. next, there's no convenient way it. here's had do: var start:int = op.activeposition < op.anchorposition ? op.activeposition : op.anchorposition; var end:int = op.activeposition > op.anchorposition ? op.activeposition : op.anchorposition; var textflow:textflow = this.textflow; var rectangles:dictionary = new dictionary(); // each selected character, make box for( var i:int=start; < end; i++) { var flowline:textflowline = textflow.flowcomposer.findlineatposition( i, true ); if( rectangles[ flowline.absolutestart ] == null ) { rectangles[ flowline.absolutestart ] = new rectangle(); (rectangles[ flowline.absolutestart ] rectangle).x = 0xffffff; (rectangles[ flowline.absolutestart ] rectangle...

jar - Processbuilder-opening java script in linux -

back again, time java question. told how processbuilder run nonnative scripts (calling program run script), i've been trying run java script , have run couple problems. first off, should use .class or .jar? both of these can run i'm not sure 1 of them work better. , how execute them correctly? i've tried calling java (/usr/lib/jvm/java-6-openjdk/jre/bin/java) , giving filepath class file, doesn't seem work. any ideas? i agree sarnold in terms of .jar question. in terms of executing code using processbuilder, can execute .jar file long file contains main() method, , has main-class manifest header, can generated when .jar created. once have .jar created, you'd use command run .jar: java -jar jar_file_name_here.jar if have multiple main classes , want run specific one, use command this: java -jar jar_name.jar com.main.class.package.path.here.someclassname are trying execute elses .jar, or 1 of own want executed inside script? why using scrip...

windows - Implementing Django Grappelli Dashboard -

i've happily implemented grappelli first time. trying implement dashboard doesn't seem activating. trouble is, i'm not sure looks like. the grappelli dashboard.py applied (generated createdashboard) settings.py (interesting parts) media_root = 'i:/xampp/htdocs/project/media' media_url = 'http://cdn.pd/' admin_media_prefix = 'http://cdn.project/' grappelli_admin_headline = 'admin headline' grappelli_index_dashboard = 'pd.dashboard.customindexdashboard' grappelli_admin_url = '/admin/' template_dirs = ( 'i:/xampp/htdocs/pd/src/templates' ) installed_apps = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'grappelli.dashboard', 'grappelli', 'django.contrib.admin', 'south', ) does have pointers? heres format of proje...

Cannot post to twitter via Twitter-OAuth-iPhone in a NSThread -

i started using ben gottlieb's twitter-oauth-iphone class post status updates in app. have done so, when executed on application's main thread. but, when throw in "nsthread detachnewthreadselector" post never makes twitter. processes fine , proper [connection identifier], results never make on twitter. idea how can run in thread without bringing main thread? code added tweet method -(void)tweet{ if([_engine isauthorized]){ [_engine sendupdate:@"tweeting"]; } } doesn't work: [nsthread detachnewthreadselector:@selector(tweet) totarget:self withobject:nil]; does work (from main app): [self tweet]; does work (from within thread): [self performselectoronmainthread:@selector(tweet) withobject:nil waituntildone:no];

django filebrowser not allowing folders to be created and does not upload files -

i'm trying implement django-filebrowser latest app. have grappelli installed also. urls work fine getting filebrowser /admin/filebrowser/browse have set at. the problem having when comes trying either add folder or upload file. new folder: when i'm adding folder error thrown stating: please correct following errors. permission denied. now permissions folder fine. don't understand why won't allow me upload files here. drwxr-xr-x 2 naytive naytive 4096 jan 18 08:32 uploads/ upload file: normally when uploading file, filebrowser upload screen appears timer upload success, when try upload file refreshes page url ending ?_save=upload it getting point remove module because isn't doing set be. any ideas? edit: think uploading files side of things caused original file permissions also. if fix error perhaps upload work too. if use on server apache, must give apache right write in folder ( chown ).

c# - HttpWebRequest doesn't work except when fiddler is running -

this weirdest problem have run into. have piece of code submit post url. code doesn't work neither throws exceptions when fiddler isn't running, however, when fiddler running, code posts data successfuly. have access post page know if data has been posted or not. non-sense, it's situation running , confused. byte[] postbytes = new asciiencoding().getbytes(postdata); httpwebrequest req = (httpwebrequest)webrequest.create("http://myurl); req.useragent = "mozilla/5.0 (windows; u; windows nt 6.1; en-us) applewebkit/534.10 (khtml, gecko) chrome/8.0.552.224 safari/534.10"; req.accept = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; req.headers.add("accept-charset", "iso-8859-1,utf-8;q=0.7,*;q=0.3"); req.headers.add("accept-language", "en-us,en;q=0.8"); req.method = "post"; req.contenttype = "application/x-www-form-urlencoded"; req.contentlength...

OS X Apache *.php execute when domain is localhost but downloads file otherwise. -

the setup: on mac os x 10.5.8 , original apache 2.2 , change uncomment loadmodule php5_module in _documentroot_ dir, /library/webserver/documents/ , in file named info.php , write: <? php phpinfo(); ?> the problem: request http://localhost/info.php , response output function (i.e. php executed file). however, request domain 127.0.0.1 or 192.168.1.x , response content of file, w/ header of content-type application/x-httpd-php . the file found via request, it's not hosts mapping problem. however, it's treated executable when request domain localhost. there no virtual hosts set in apache conf, figure behaviour should same regardless of domain. any idea how remedy use server on lan? thanks. not sure if problem, have allow/deny settings on mod_php module's configuration? i'm not sure if allows or not. the reason ask because today wound tracking down issue preconfigured apache instance mod_proxy set allow on requests localhost. ...

XML on windows phone 7 -

Image
i newbie in windows phone 7. want demo within xml can't find xmldocument class (like on windows form). can't find namespace linq, xpath... in system.xml (see below picture). there separate assembly need reference (system.xml.linq). once have able use linq 2 xml stuff (xdocument, etc). xmldocument isn't available in silverlight (and therefore not available in wp7). jay

winapi - Does QueryDosDevice and IOCTL_STORAGE_GET_DEVICE_NUM treat LUNs as separate devices? -

can confirm whether querydosdevice() , ioctl_storage_get_device_number considers lun s on same physical usb storage device single device, or each lun considered separate device? for example, if have usb thumb drive has multiple lun s, , each lun has been allocated logical dos "letter", such c :, d: , etc, if call querydosdevice() return same devicename lun s? or each lun have different devicename ? similarly, if use ioctl_storage_get_device_number each of lun s, returned devicenumber same lun s? thanks help!

iphone - Can I remove the arrow in the popover view? -

i asked removed arrow of popover view. is violating human interface guidelines ? is wise show popover inside popover ? if not violating human interface guidelines how ? hiding popover arrow or showing 1 popover inside not sound wise. i’m not sure if explicitly forbidden hig, it’s usability drawback anyway. if insisted draw own arrowless popover or try mask arrow using view composed on top of it. i think better rethink ui.

c# - programmatically creating a .pfx file -

is there way programmatically creating .pfx file certificate? use sign pdf. data of client database construct file when click sign pdf, go out , pfx file has been constructed , stored in database , sign pdf file. goal how create file? using c# 4.0. you can use chilkat library. need pem file though, here link: http://www.example-code.com/csharp/pfx_frompem.asp

java - find item in list of static final Strings -

i have list of static strings: static final string foo = "foo"; static final string bar = "bar"; static final string duh = "duh"; static final string goo = "goo"; static final string zut = "zut"; i want check if given string part of list, want keep possibility reference each item individually. want check implementation unaware of individual items. not this: boolean isvalid(string item) { return (item.equalsignorecase(foo) || item.equalsignorecase(bar) || ......) } thnx! bas hendriks create array containing strings , use loop check if 1 of them matches input string.

Android - Downloading data from the internet >> catch connection errors -

in app connect server, responds xml. parse sax parser, , data. the question is: what best way handle connection issues? (at moment if there no internet connection available app continues showing progressdialog implemented) as following suggestion of heiko rupp, can check availability of network connection prior performing download. see my post on subject .

sql on mysql about join -

the code below provide result infact want list customer never buy somethink how can fix code below select webboard.listweb.id, webboard.listweb.iditempro, webboard.listweb.url, webboard.listweb.useradddate, webboard.listweb.expiredate, webboard.prorecord.urlpostonweb webboard.prorecord.urlpostonweb webboard.listweb , webboard.prorecord listweb.id not in (select webboard.prorecord.idlist webboard.prorecord ) using syntax from webboard.listweb , webboard.prorecord will perform cartesian, or cross, join on tables involved. every row in table listweb rows in prorecord displayed. you need use inner join select rows in listweb have related rows in prorecord table. fields identify rows (your primary keys) , name of foreign key field in prorecord table? edit: re-read question , comments , see want rows in listweb do not have entry in prorecord your select like: select webboard.listweb.id, webboard.listweb.iditempro, webboard.listweb.url...

oauth - How to map a third-party property in Hibernate -

i have class (activity) field (signaturesecret) defined interface (signaturesecret), implementation of (sharedconsumersecret) comes spring security oauth package. when persisting instances of class hibernate, want use specific property of sharedconsumersecret value should saved/loaded database. can't annotate sharedconsumersecret, it's part of spring framework. is there way this? @entity public class activity implements consumerdetails { @transient private list<grantedauthority> authorities = new arraylist<grantedauthority>(); private string consumerkey; private string consumername; @id @generatedvalue(strategy = generationtype.auto) private integer id; @manytoone private activityowner activityowner; //this tricky 1 private signaturesecret signaturesecret; @size(min = 1, max = 36) private string uuid; ... the way around can think of have one-to-one relationship of signaturesecrets activities, seems ...

python - Is it possible to reduce the amount of arguments this on the boilerplate function? -

i'm trying create automagic django model instantiator. function take couple of arguments, instantiate few django models, link foreign keys together, save lot , return main model me. fine , in end, function takes 4 normal arguments , 2 tuples (filled contenttype name , array of arguments different function call). this leads following function def: def create_rule(profile, lifestyles, bool, title, input, output): rule = rule.objects.create( user_profile=profile, lifestyles=lifestyles, bool=bool, title=title, ) models = contenttype.objects.filter(app_label="rules") input_cls = models.get(model=input[0]).model_class() input_cls.objects.create(*input[1], rule=rule) output_cls = models.get(model=output[0]).model_class() output_cls.objects.create(*output[1], rule=rule) return rule an average function call might little this: create_rule(profile, '1,3,6,7', 1, "switch off when 5:00", ...

alternative to profileprovider in asp.net mvc -

i'm developing asp.net mvc site use custom profileprovider retrieve info (like last page visited, max number of record view in grid, notification via mail etc) related single user stored in custom database. don't technique because profileprovider not easely injectable, there alternative way obtains same functionality exposed profile provider? think possible use asp.net module i'm not expert. i think tartafe means providers (also custom profileprovider) instantiated , controlled external code (system.web.configuration.providershelper). the dependency injection pattern says objects custom provider relies on, should passed in controller (or container). cfr. dependency injection loose coupling ). typically controller initialize repository, datacontext, or other object , pass in through constructor or property. not possible custom provider since 'controller' sealed in system.web.configuration. i think question becomes: there way influence how providershe...

How to display most used file extensions (pdf, doc, docx, xls, ...) into a browser using PHP? -

currently developping mobile webmail school, encountering iphone problem : iphone users enable download files, allow them, @ least, consult files common extensions : doc, docx, xls, xlsx, pdf, ppt, pptx, xml, open office files, on. does exist using php or html/javascript ? you use google doc's viewer: http://docs.google.com/viewer this allow display of these formats directly in browser. basically have display document: <iframe src="http://docs.google.com/viewer?url=<?=urlencode($document_url)?>&embedded=true" width="600" height="780" style="border: none;"></iframe> (note google docs must have access these documents, may or may not make solution unsuitable.)

iphone - Problem when changing between Subviews (iOS Developement) -

i developing ios 5 6 months now. right trying implement face detection algorithm marks faces on uiimage take avfoundation framework. well, works (almost) fine. during programming stages had simple buttons steps 1 @ time. worked great. now packed 1 button click, after 2-3 minutes nothing showed up. played around little nslog outputs mark time when every step completed , algorithm , successful, view still not change show image packed uiimageview subview of other view. funny thing is, when nslog message can click on place on screen other buttons (as placed them in interface builder) , buttons react interaction though nothing shown!? i transit between uiviews setting alpha value 0.0 , 1.0. tried transit [[viewcontroller view] bringsubviewtofront:subview]; didn't help! anyone knows problem might be? best regards! it making changes views on background thread. try performing changes on main thread.

java - What libraries exist for creating raw multipart emails? -

i ideally set user interface designing emails include text, html, , images, , interface output raw encoded email can pipe mail application, save in database, etc.. are there libraries @ generating raw emails, and/or necessary html? for example: can create document in ms word (interface) , merge outlook send. ideally i'd jquery based library let me visually create mail, , output result long string. however, server-based libraries in languages helpful: javascript, ruby, python, java, etc.. i think i'm looking mail generation library (or mentioned in answer below, mime-generation framework edit: know question pretty general.. if can rephrased better let me know. if asking "facebook", , naive , unrealizable, let me know. useless comments don't add not needed though python has modules both creating , sending emails in standard library. don't know java or ruby. generating html i'd use html template language. there tons of them py...

emulation - Mobile Phone emulator -

is there in 1 emulator testing mobile websites. using 'media queries , need test on predominantly iphone, blackberry, android, , windows 7 phones. many thanks, c there no 1 solution work on these platforms sdks include simulators/emulators , best part iphone free. blackberry simulators android emulator windows phone 7 emulator iphone sdk includes simulator (mac only) if need test on pc, can pretty job using http://iphone4simulator.com/ running in safari windows. as simulator/emulator usage, these initial testing need use actual device true results. also note different blackberry devices use different default browsers. android devices use varying versions of webkit may see variation between actual devices isn't shown in emulator.

php - retrieve data from 4 tables -

Image
i have these 4 table assume ring table consist of 5 fields(jewelry_id,ring_id,image,type,brand_id) note brand table have foreign key in ring table , ring , style both have foreign keys in ring_style table. want retrieve following data these 4 table (ring_id, image,type, brand,style) did't query appreciated. select ring_id, image, type, brand, style ring left join brand on ring.brand_id = brand.brand_id left join ring_style on ring.jewelry_id = ring_style.jewelry_id left join style on ring_style.style_id = style.style_id note each ring appear 1 or more times. appear more 1 time when there more 1 ring_style record ring.

c++ - Driver Backup using setupapi -

i'm stuck. cut long story short, task enumerate driver files backup. drivers display adapter driver, use setupscanfilequeue(queuehandle, spq_scan_use_callbackex,null, dumpdevicedriverscallback,&count,&scanresult) from setupapi , that's working fine in dumpdevicedriverscallback can source of device driver file , copy backup location 1 one. however, same function ignore callback system drivers. example "direct memory access controller" can not list of files. funny thing, windows device manager can not find files of system devices. some special software drivermax , doubledriver can backup driver. so, problem may solved. anyone can explain me going on here? there lots of devices installed using what's called "no driver" inf. these infs provide enough information such device manager have info show device (thus avoiding them appear in "unknown devices" category) don't install drivers. the...

Speech enabled asp.net application -

we working on asp.net web application requires data entered speech. the user can enter data using normal user interface however, want additional feature can enter data speaking. can fix voice commands enter "value1" "data1", user speak "data1" followed "value1" (or else, can fixed later). i searched on internet , found using microsoft speech sdk solution. started initial implementation , found works ie , requires plugin (we not able use plugin in windows 7, xp). is there other solution or can sasdk used other browsers ? suggestions helpful. thanks, gaurav yes, can done: use html5's getusermedia capture audio stream save .wav, there libraries that send .wav server through ajax feed .wav speechrecognitionengine, through setinputtowavefile method get result , return in ajax call an example: http://weblogs.asp.net/ricardoperes/speech-recognition-in-asp-net

c# - Date format problem in new lotus domino document -

i have problem data format. when create document in lotus database (in lotus client) date inserted without time field name: data_fim data type: time/date data length: 8 bytes seq num: 1 dup item id: 0 field flags: summary '2011-01-26` when create/change c# contains time: field name: data_inicio data type: time/date data length: 8 bytes seq num: 12 dup item id: 0 field flags: summary 2010-12-15 00:00:00 cet command used change doc doc.replaceitemvalue("data_inicio", convert.todatetime( "2010-12-15")); thank in advance use datetime formatting

.net - List of KeyValuePair -

why .net not provide class list<keyvaluepair<t, u>> ? i think there lot of situations when need keep array of pairs. example, 1; 2 "a"; "array" 5; 8 "b"; "browser" 1; 9 "f"; "firefox" 8; 10 "f"; "frequency" À la: pairs<int, int> mypairs; mypairs.add(10, 8); mypairs.add(5, 8); mypairs.add(10, 5); mypairs.add(1, 4); mypairs[0].value1 = 5; mypairs[5].value2 = 8; this seems unnecessary me - , because have pair of values doesn't mean it's key/value relation either. .net 4 introduced tuple family of types... unless was key/value pair, i'd use list<tuple<t1, t2>> instead - , see no reason single type exist in order encapsulate construct. edit: put context, here's how "difficult" use tuple here, converting sample code: var mypairs = new list<tuple<int, int>> { tuple.create(10, 8), tuple.cr...