Posts

Showing posts from April, 2011

iphone - Whenever I use UIWebView loadHTMLString ,it's scrollView.contentOffset.y turns to 0 -

how can let webview memorize webview.scrowview.contenoffset localtion .so when download new data has animation frow down . [webview.scrollview setcontentoffset:cgpointmake(0, 0) animated:yes]; try out line javascript [webview stringbyevaluatingjavascriptfromstring:@"window.scroll(0,0)"];

getting notes from a single contact - android -

i'm trying "notes" single contact. added fine retrieving has been problem. string selection = contactscontract.commondatakinds.phone.display_name+" like'%" + sender +"%'"; string[] projection = new string[] { contactscontract.commondatakinds.note.note}; cursor c2 = getcontentresolver().query(contactscontract.data.content_uri, projection, selection, null, null); if (c2.movetofirst()) { notes = c2.getstring(0); } it works fine other values name or phone number can't seem notes retrieve correctly. retrieves random value email instead. i believe problem not rows in table represent contact types have notes. have request proper mime type. contactscontract.commondatakinds.note alias 'data1' column present on rows, when row of different mime type, represents different data. how contacts in android should give idea of how this.

hash - Is there an issue with putting a longer input string to a hashing algorithm than the algorithm outputs? -

currently i'm designing hashing system user emails, happens if user email longer hash output. use sha1 sha256 or sha512 if makes difference based on algorithm... seems @ point algorithm wouldn't able keep on producing unique outputs. hash values have fixed length 13 (des) 86 (sha2) characters. it's normal if give longer input. think of "cross sum" can arbitrary long numbers well. regarding uniqueness, using standard crypt(3) function sha-512 , characters in set a-za-z./ have 54 different characters , 86 character long string 54^86 different values. that's lot :-) (don't use 13 char long des crypt though, that's bruteforceable modern hardware , use "salt" values same input string gives different hash values , can't use "rainbow table" attack).

linux - list_for_each_entry reset cursor -

hi new in , trying use list_for_each_entry iterate on list. looks this list_for_each_entry(pos, head, member){ if (something == pos.x) //reset loop cursor starts iterating on again } how perform commented part without using goto? 1 more thing, safe use break/continue inside list_for_each_entry or there functions available achieve this? thanks. look @ definition of list_for_each_entry #define list_for_each_entry(pos, head, member) \ (pos = list_entry((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) from https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/list.h?id=refs/tags/v3.10-rc2#n418 as see defined simple loop, no black magic here, can use continue/break. for other question, guess depends how why you're trying that. simplest way do: int iterateagain = 0; list_for_each_entry(pos, head, member) { ...

Understanding Data-centric app and object composition in Clojure -

i've been impressed work of chris granger , light table. question not light table though, more "bot" architecture described using in blog post "the ide value" : http://www.chris-granger.com/2013/01/24/the-ide-as-data/ now, i'm pretty new clojure better explore way of programming: behavior, object, tag: (behavior* :read-only :triggers #{:init} :reaction (fn [this] (set-options {:readonly "nocursor"}))) (object* :notifier :triggers [:notifo.click :notifo.timeout] :behaviors [:remove-on-timeout :on-click-rem!] :init (fn [this] [:ul#notifos (map-bound (partial notifo this) notifos)])) (object/tag-behaviors :editor.markdown [:eval-on-change :set-wrap]) where can find clojure code uses style , composition principles? bot sounds light table "proprietary" flavor of entity-component-system (ecs) ar...

java - Why can you not inherit from a class whose constructor is private? -

why java disallow inheritance class constructor private? java doesn't prevent sub-classing of class private constructors. public class main { static class { private a() { system.out.println("subclassed in "+getclass().getname()); } } static class b extends { public b() { } } public static void main(string... ignored) { new b(); } } prints subclassed in main$b what prevents sub-classes cannot access constructors of super class. means private constructor cannot used in class file, , package local constructor cannot used in package. in situation, option have delegation. need call factory method create instance of "super" class , wrap it.

Silverlight Button "isWindowless" setting dynamically -

i generating silverlight button through following code. silverlight.createobjectex( { source: controlsource, parentelement: container, id: "controlid", properties: { width: w, height: h, version: "4.0", background: nusa_recordbuttonbackgroundcolor, enablehtmlaccess: "true", initparams: params}, events: { onload: oncontrolload } } here problem is, when popup placed on silverlight button, button ovveriding popup. here z-index not working properly. "iswindowless" property has set true, make functionality work properly. now, above code in js file has reference location, not our server.i using reference of js file in page. in above method have add 1 more property [iswindowless ='true'] can tell , how add property existing method in js file, through javascript in current page (or) how ovveride existing method through javascript so cannot change method in .js f...

C# Selecting XML Elements With XPathSelectElements() -

i have xml, there multiple elements of type 'vdsk', want them all. have 1 in here brevity. <?xml version="1.0" encoding="utf-8" ?> <diskstatscoll xmlns="http://ibm.com/storage/management/performance/api/2005/08/vdiskstats" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://ibm.com/storage/management/performance/api/2005 /08/vdiskstats schema/svcperfstatsv.xsd" scope="node" id="node1" cluster="v7000nd01" node_id="0x0000000000000001" cluster_id="0x00000200a0421666" sizeunits="512b" timeunits="msec" contains="virtualdiskstats" timestamp="2013-04-30 07:04:13" timezone="gmt-6:00"> <vdsk idx="0" ctr="137111307" ctrs="3553815134" ctw="580314768" ctws="12467258075" ctp="107973069" ctps="6910276416" ctrh="918...

sql - How to set a column value if unavailable -

i have table follows . table name : testnumbers id(int) number(int) name(nvarchar(50)) 1 1 test 2 1 test 3 2 test2 when insert number column need increment if unavailable , if available max id value + 1 , ensure if number has been passed argument save is.(this ensure constraint rows name same have number column same too). i have written sp there few syntax issues. create procedure test_storedproc @name nvarchar(50), @number int = 0, @id int begin set nocount on begin try declare @incrementid smallint; set @incrementid=1; declare @incrementnumber int; set @incrementnumber = 1; begin tran begin if @number = 0 begin set @number = select isnull(max(number),0)+@incrementnumber testnumbers end insert testnumbers ([id] ,[name] ...

python 2.7 - How to include multiple models in openerp report section -

i have created new module in openerp.now want create report .i have done reporting.my module concept user can create consumption chart, contain chart name ,date , project name .each chart contain muliple products , consumpion quantity.consumption chart details in 1 table , product details related consumption chart in table. want show report consumption chart name , product details.i have prepared report , when take pdf can see consumption chart details how can include product details. question how include multiple models in report section.below given current code. class order(report_sxw.rml_parse): def __init__(self, cr, uid, name, context=none): super(order, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, }) report_sxw.report_sxw('report.mat_mgmt.collection_docket', 'mat.mgmt', 'mat_magmt/report/collection_docket.rml', parser=order, header="external") ...

C# Send tweets on twitter from multiple accounts -

well workin on c# application , want able send tweets multiple twitter accounts . wanted know possible ? edit : sorry not being specific :d how can done ? the short answer question is: yes. the bit longer answer is: yes it's possible , recommend have @ linq twitter . library simple use , allows connect twitter in no-time: var auth = new applicationonlyauthorizer { credentials = new inmemorycredentials { consumerkey = "twitterconsumerkey", consumersecret = "twitterconsumersecret" } }; auth.authorize(); var twitterctx = new twittercontext(auth); var tweet = twitterctx.updatestatus("hello world"); auth part copied joe mayo here: twitter api application-only authentication (with linq2twitter)

Objective-C count for array that was/is a sub array fails? -

nslog(@"size of array: %i", ([historicdatesarray [23] count])); historicdatesarray [23] = historicdatesarray [23][1]; nslog(@"size of array: %i", ([historicdatesarray [23] count])); as second nslog tries execute: terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfstring count]: unrecognized selector sent instance 0x728c7f0' historicdatesarrray nsmutablearray. can read(nsstring) contents of historicdatesarray[23], can't count elements? i no longer need object @ historicdatesarray[23][0] , want assign object @ historicdatesarray[23][1] historicdatesarray[23], tested , works, why can't use 'count' size of array? how can convert 2d nsmutablearray 1d nsmutablearray? i think problem historicdatesarray [23] no more array .it holding string value , wont have count property.that makes issue firstline : object @ historicdatesarray index 23 array,it has values [23][1] ,[23][2]...

extjs - Ordering rownumberer after adding or deleting from the store ExtJS4.1 -

i have extjs store produces grid. in first column of grid have rownumberer xtype generate serial number. in grid can add(from other grid) or delete records through action.while adding copies row number other grid. want rownumberer sorted after every addition or removal.please help. items: [ { xtype: 'grid', id: 'allsurveygrid', store: alludfstore, border: false, width: 600, height: 250, layout: 'fit', columns: [{ xtype: 'rownumberer' }, { header: 'date', sortable: false, dataindex: 'createddt', flex: 0.3 }, { header: 'question name', sortable: false, dataindex: 'questiontext', flex: 1 } ], selmodel: { mode: 'multi...

javascript - MRAID Compliance -

i created ad publisher ios sdk , show bottom banner ad. created using native components of ios, uiview , uiimageview , uibutton , etc. make mraid compliance. if created ad using html5 , loaded uiwebview, can inject mraid.js uiwebview , trigger functions ad loaded, expanded, etc using "stringbyevaluatingjavascriptfromstring" but created banner ad using native components. how can make ad mraid compliance? please advice, thank you. you can't there here. mraid advertisements built out of html , javascript, not native ios components.

python - how to continue execution after sys.exit() command -

here i'm reading , comparing values 2 logs using 'for' loop.problem i'm not able continue next tc after sys.exit command. let me know if required more clarification f = open('/tmp/ftplog', 'r') line in f: m = re.findall("5\d+", line) #print m fd = open('/tmp/tellog', 'r') line in fd: n = re.findall(r"5\d+", line) #print n if m == n: print "passed" sys.exit() ####tc-02#### def tc02(ipadrr,login,password,ftpipaddr,ftplogin,ftppassword,ftpfilename): try: telconn2 = pexpect.spawn(ipadrr) try print "passed" return ####instead of sys.exit use return

version control - CVS synchronize/update issue -

i using cvs version control system , facing strange issue. files, not able synchronize or update (using eclipse) because of following error: "[project name]: cvs [update aborted]: cannot create .#lang_en.properties.1.1.2.3.2.7.2.2.2.3.2.1.2.1.2.3.8.1.2.4.6.12.2.3.4.1.4.3.2.6.2.13.4.4.4.1.2.9.2.2.2.1.8.1.8.1.14.1.8.3.26.1.8.1.4.4.6.17.4.2.6.6.6.3.2.2.2.2.10.2.2.2.2.2.2.9.2.7.2.1.4.10.4.2.2.3.4.4.2.2.2.1.2.1.10.2.8.1.6.1.4.1.4.2.6.1.2.1.2.2.4.5.4.1 copying: file name long" according observation happens committed files. happens in team commit such file (which works) when other person in team try sync or update, shows 'file name long' error. clarify in example above file name "lang_en.properties'. i not sure how resolve issue. have tried deleting file cvs , recreating same name (that required), same revision history appear again. appreciated. a file named .#<filename>.<revision> created when cvs update , there changes made checked...

events - What javascript objects have addEventlistener in their prototype? -

i know of following: element.prototype.addeventlistener window.prototype.addeventlistener document.prototype.addeventlistener any others? one more: xmlhttprequest and in prototype chain.

java - NullPointerException on NamespaceManager access -

what reasons namespacemanager.get() throw nullpointerexception . can me identify possible reason(s) namespacemanager null , get() throw npe? this junit test code: @contextconfiguration(locations = { "classpath:service/client-config.xml" }) @runwith(springjunit4classrunner.class) public class mydaotest { private final localservicetesthelper helper = new localservicetesthelper(new localdatastoreservicetestconfig() .setdefaulthighrepjobpolicyunappliedjobpercentage(0)); @before public void setup() { helper.setup(); } @after public void teardown() { helper.teardown(); } @test public void test() { } } basically, client-config.xml configured <mvc:annotation-driven />

How I can change canvas to svg? -

function ballitemrenderer() { this.canvas = null; this.graphics = this.canvas.getcontext("2d"); this.stroke; this.fill; this.cubedepth = 0; this.cubeangleratio = 0; this.draw = function(x, y, width, height) { var g = this.graphics; if(g) { if(this.stroke && this.stroke.color) g.strokestyle = graphicsutils.color2rgba(this.stroke.color, this.stroke.alpha); if(this.stroke && this.stroke.weight) g.linewidth = this.stroke.weight; else g.linewidth = 1; var rad = width * 0.5; var tx = this.cubeangleratio * rad * 0.5; var radgrad = g.createradialgradient(x+rad-tx, y+rad-tx, 1, x+rad, y+rad, rad); var alpha = isobject(this.fill) ? this.fill.alpha : 1; radgrad.addcolorstop(0, "rgba(255,255,255," + alpha + ")"); radgrad.addcolorstop(1, graphicsutils.adjustbrightness(t...

datepicker - Unable to set hide fututre date in Android -

i using higher api 11, here problem during hide future date: @override protected dialog oncreatedialog(int id) { calendar c = calendar.getinstance(); int cyear = c.get(calendar.year); int cmonth = c.get(calendar.month); int cday = c.get(calendar.day_of_month); switch (id) { case date_dialog_id: datepickerdialog dialog = new datepickerdialog(this, mdatesetlistener, cyear, cmonth, cday); dialog.getdatepicker().setmaxdate(new date()); return dialog; /*return new datepickerdialog(this, mdatesetlistener, cyear, cmonth, cday);*/ } return null; } i have problem: setmaxdate(new date()); i error: the method setmaxdate(long) in type datepicker not applicable arguments (date) so, please how hide future date . from doc : sets maximal date supported datepicker in milliseconds since january 1, 1970 00:00:00 in getdefault() time zon...

android - aapt.exe has stopped working -

i transferred workspace workstation error "aapt.exe has stopped working" showed. i have read answers uncheck build automatically, update sdk, or make android build output normal crash stop, didn't. deleted .metadata of workspace , set preferences of eclipse default again. copied aapt.exe other workstation , replaced mine, , log showed up: [2013-05-21 14:36:42 - example] error: unknown option '--output-text-symbols' [2013-05-21 14:36:42 - example] android asset packaging tool [2013-05-21 14:36:42 - example] [2013-05-21 14:36:42 - example] usage: [2013-05-21 14:36:42 - example] aapt l[ist] [-v] [-a] file.{zip,jar,apk} [2013-05-21 14:36:42 - example] list contents of zip-compatible archive. [2013-05-21 14:36:42 - example] [2013-05-21 14:36:42 - example] aapt d[ump] [--values] file.{apk} [asset [asset ...]] [2013-05-21 14:36:42 - example] badging print label , icon app declared in apk. [2013-05-21 14:36:42 - example] permissions ...

Clicking an applications menu bar item with AppleScript -

i use time tracker mac my, well, time tracker. has menu bar item want able access via keyboard shortcut. i found way click item gui scripting: tell application "system events" tell process "time tracker" click menu bar item of menu bar 2 end tell unfortunately script not return success unless acted on menu (i.e. pressing enter or esc key). if want trigger down arrow key... tell application "system events" tell process "time tracker" click menu bar item of menu bar 2 -- hangs here forever until menu closed tell application "system events" key code 124 end tell the script waits forever. if hit escape menu bar item closes , down arrow key triggered. it's kind weird. need menu bar item's click not block further script execution. any suggestions? the click command returns after 5 seconds me. 1 workaround use ignoring application responses , terminate system events: ignoring application r...

Spring Validation : Server side systems -

the more read more find mvc @validate intended web applications, including online samples me head around actual use. i have server side message processing project , looking implement validation cross cutting concern really, should able write validations / custom messages etc , apply methods needed , reuse them. spring validation right choice ? does 1 have samples or point me right material ? appreciate inputs. you take @ bean validation . advent of javaee 7 in june 2013 can used in every java project.

Android Studio missing src and other part of my project after reopening -

Image
currently i'm exploring on using android studio. it's been while since last developed on android , exciting me having new tool develop in android. setup android studio , tested create new sample project last week today after opened message appears saying "the folders below removed gradle..." has checkbox , don't know why it's checked default. since i'm not yet familiar environment pressed ok src , other folders missing. although can still access src folder classes created through use of navigator on top part can't run app , acts strange compared before. also when try create new project message appers saying: "failed import new gradle project: not fetch model of type 'ideaproject' using gradle distribution ' http://services.gradle.org/distributions/gradle-1.6-bin.zip '. unable start daemon process." not sure on one. know still in beta , bugs happen hope there's workaround this. anyway, here's screenshot on h...

iphone - Rate the app functionality in ios not working well -

i having app in have button "rate" app. on click of button, using following code. - (ibaction)ratepressed:(id)sender { nsstring *str = @"itms-apps://ax.itunes.apple.com/webobjects/mzstore.woa"; str = [nsstring stringwithformat:@"%@/wa/viewcontentsuserreviews?", str]; str = [nsstring stringwithformat:@"%@type=purple+software&id=", str]; // here app id itunesconnect str = [nsstring stringwithformat:@"%@appid", str]; nslog(@"str %@",str); [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:str]]; } my app not on app store when pressed rate button gives me error saying your request produced error. [new nullresponse] when put appid of of app on appstore. works fine. so can put custom message saying "app not available"? when app not on appstore. or default message apple? please me.

php - mod_rewrite domain to directory -

i want rewrite example.com url example.com/ru for example if url example.com/books want have example.com/ru/books i think can't header() function this method incorrect <meta http-equiv="refresh" content="1; url=http://www.example.com/ru"> you should edit .htaccess redirect user queries @ / level new /ru/ level. should work purpose: rewriteengine on rewritecond %{request_uri} !^/ru/ rewriterule ^(.*)$ /ru/$1 [l,r=301]

javascript - Absolute vs relative URL for CSS and JS -

need know if approach include css or js better - <link href="http://www.mysite.com/css/style.css" rel="stylesheet" type="text/css"> or <link href="./style.css" rel="stylesheet" type="text/css"> someone told me if use absolute url (including http://www.mysite.com ) css or js downloaded server on every page load. please me understand this. the short answer is: doesn't matter. use whichever style prefer, try consistent. the long answer is: people have been asking kind of question since css became thing. there kinds of answers out there argue 1 way or other, citing performance implications or maintainability. none of matters because: browsers efficient performance difference moot. worrying optimizing inclusion paths distraction, , you're better off writing code.

php - Including multi step form on external sites -

our website has multi step form , have many affiliate websites iframe our form onto site. however, i'm looking move better alternative use iframe, possible use javascript or form of api include whole form on external sites? if so, can please point me in right direction? the form uses php, css , js , has 3 different steps, therefore page must reloaded each step. external sites have different domain names. if need more info please let me know. thanks

eclipse plugin - Xtext - how to extend XtextDocument class -

i need extend xtextdocument class can add properties dsl document. how can done? tried add bind ui module there no bind xtextdocument. in advance you can add new binding ui module. methods follow convention public class<? extends ${typetobind}> bind${somename}() { return ${myspecialtype}.class } will invoked reflectively when injector created. therefore, binding public class<? extends xtextdocument> bindxtextdocument() { return mydocument.class; } will trick.

copy - Maven exporting pom.xml with jar plugin -

i adding attribute in jar plugin specify location of jar file. @ location maven not exporting pom.xml file used in generating jar. can please tell me how export pom.xml in same location other copy plugin i found goal packaging put artifact in local repository. each artifact need install in files system repository pom file. copying pom file using resource plugin not help.

c# - XNA wp7 gesture detection issue -

i have use both type of input in app (gestures , simple touch). , got problem it. example use double tap gesture , before detected have 1 detection of simple touch. in not way expect, because simple touch has own logic, brings me lot of problems. same issue drag, before detecting drag again first decetced simple touch. how can handle gestures without handling simple touch logic. here way im trying that: touchpanel.enabledgestures = gesturetype.doubletap | gesturetype.verticaldrag; while (touchpanel.isgestureavailable) { isgesture = true; gesturesample gesturesample = touchpanel.readgesture(); switch (gesturesample.gesturetype) { case gesturetype.doubletap: //some logic break; case gesturetype.horizontaldrag: //some logic break; } } if (consts.touchcollection.count == 1) ...

Python: How can I create a Python project compatible to Python 2 and Python 3? -

i want create package should compatible python 2.7 , python 3.3. logic should exist once. how represent programming logic - in python 2.7 or python 3.3? or choose different way? edit: how issue handled in core? you quite using bits of language same, , having conditions or exception handling during other parts. this harder or easier depending on software do, , versions of python need support. supporting python 2.6, 2.7 , 3.3 becomes relatively simple. exactly how not answerable in question on so, because there lot it. i recommend check out book: http://python3porting.com/ , chapter "supporting python 2 , 3 without 2to3 conversion" , appendices, has loads of examples of how solve incompatibilities. the six library may useful.

asp.net - ASPX Page <%:Page.Title %> vs. <%=Page.Title %> -

could explain difference between aspx page <%:page.title %> , <%=page.title %> when written part of asp.net aspx file? <%: same <%= , except auto-html-encodes value withing tag.

Search Tokens in java -

i trying write code searching things in project , need split string words , words search tokens . example if "how you" string split how, , you, , h, ho, how, a, ar, are, y, yo , you. can explain me how in java? string.split() ideal choice - takes regular expressions -- can used define simplest of patterns complex ones . as per java api doc - stringtokenizer legacy class retained compatibility reasons although use discouraged in new code. recommended seeking functionality use split method of string or java.util.regex package instead.

jquery - Accessing API on another domain -

there api on domain. have url , credentials. when type api url in browser, displays data in browser. data in xml format. need access api using function. how do that? there issue of cross-domain? coz accessing server, on different server. need capture xml data , show in html format. please guide me on this. in opinion, need use xmlhttprequest and/or jsonp and/or cors. kindly help. if loading xml data display values in html should able use function jquery. http://api.jquery.com/jquery.get/ it may encode xml json , use getjson, if unable modify web service may not option. http://api.jquery.com/jquery.getjson/ if need post things api such images and/or other files need use jsonp or cors. web service of course have expect json value, double check api docs.

How to listen for a change in java.awt.Window screen? Is there a way to give focus to other windows/programs whilst using setFullScreenWindow()? -

i have full screen window made this graphicsenvironment ge = graphicsenvironment.getlocalgraphicsenvironment(); graphicsdevice[] gs = ge.getscreendevices(); if (gs.length >= 1) gs[1].setfullscreenwindow(frame); else gs[0].setfullscreenwindow(frame); this puts frame on second monitor unless there no second monitor in case puts window on primary monitor now problem can't seem find way push window , force loose focus other windows, dialogs , things such google chrome go in front of window -- problem if user starts program without secondary monitor plugged in or if secondary monitor gets unplugged (in both cases fullscreen window ends on primary display) is there way give other windows, jframes or whatever needed focus above window? or there sort of listener don't know allow me dispose of fullscreen window in event gets moved primary display (i have tried implementing componentlistener in class extends window)? setfillscreen method used set program...

php - Password protected PDF creation using Ghostscript -

i need provide password pdf file using ghostscript in php. have pdf file called sample.pdf . need put protection , call output.pdf . searched lot , got following lines of codes. doesn't helped me. there error in code? suggestion appreciated.. exec("gs -dnopause -dbatch -sdevice=pswrite -soutputfile=file.ps sample.pdf"); exec("gs -dnopause -dbatch -sownerpassword=pwd1 -suserpassword=pwd2 -sdevice=pdfwrite -soutputfile=output.pdf file.ps"); running command lines have given works here me. here questions: 1) have tried command line instead of 'exec' php ? 2) why first running pswrite, pdfwrite ? give poor quality 3) version of ghostscript using ? 4) in way not work ? how testing existence of password security ?

javascript - Php copy CPU consumption -

i creating site allows users view file via javascript plugin. to this, , maintain security of file, creating 1 time unique copy of original file, each time javascript plugin accessed. the original file @ maximum 30mb, how scale multiple users of system? if 100 people create , access copy of file. you can creating htaccess rewrite refer user php script: rewriteengine on rewriterule ^download/([^/]+) /lib/download.php?file=$1 [qsa] this forward request yourdomain.com/download/anyfilehere.mp3?one_time_token=abcdefg lib/download.php , set $_get['file'] anyfilehere.mp3 . one_time_token $_get parameter forwarded, used [qsa] . the download.php this: <?php if (!empty($_get['file'])) { if (!empty($_get['one_time_token'])) { if (tokenok($_get['one_time_token'])) { //create function called tokenok download token in eg. database $filename = '/var/www/downloadfolder/' . $_get['file...

objective c - Ios CoreData with 3 MOC solution (app freezes on saving process) -

i use coredata in app, 3 contexts: __mastermanagedobjectcontext -> context has nspersistentstorecoordinator , save data disk. _mainmanagedobjectcontext -> context used app, everywhere dispatchcontext -> context used in background method, have webservice access , coredata insertion/update stuff. i'll put code realize solution: app initialisation code: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions //a app começa aqui { nspersistentstorecoordinator *coordinator = [self newpersistentstorecoordinator]; __mastermanagedobjectcontext = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype]; [__mastermanagedobjectcontext setpersistentstorecoordinator:coordinator]; _mainmanagedobjectcontext = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsmainqueueconcurrencytype]; [_mainmanagedobjectcontext setundomanager:nil]; [_mainmanagedob...

c# - Json into JArray -

i contence of json jarray. my json response.content , returns follows: {"type":"error","status":409,"code":"item_name_in_use","context_info":{"conflicts":[{"type":"file","id":"8195783794","sequence_id":"0","etag":"0","sha1":"2c483e55f677e1b45e21efda3e2d144a800f61f4","name":"df750784-1302-4dcb-8489-4d6847e91bb6.jpg"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"item same name exists","request_id":"475604999519b344223055"} here is in neat view: {"type":"error","status":409, "code":"item_name_in_use", "context_info":{"conflicts":[{"type":"file", "id":"8195783794", "seque...

c# - Select Parent XML(Entire Hierarchy) Elements based on Child element values LINQ -

i have following xml , query through id,how parent hierarchy <child> <child1 id="1"> <child2 id="2"> <child3 id="3"> <child4 id="4"> <child5 id="5"/> <child6 id="6"/> </child4> </child3> </child2> </child1> </child> in if query(id = 4) , find out parent elements using linq in particular element how following output hierarchy. <child> <child1 id="1"> <child2 id="2"> <child3 id="3"> <child4 id="4"/> </child3> </child2> </child1> </child> thanks in advance. assume want 1 node parent tree: string xml = @"<child> <child1 id="1...

Complex MySQL queries on data spread over multiple tables (PHP) -

i trying solve complex problem mysql , php. here example of tables have: list of clients: table_clients client_id | client_name | address | zip code | ----------|-------------|-----------------|----------| 1 | mark | 127 park ave | 12235 | 2 | john | 6 freeman drive | 12899 | 3 | allan | 450 clever rd | 12235 | list of services: table_services service_id | service_name | service_price | -----------|--------------|---------------| 1 | fertilizer | 100.00 | 2 | bug spray | 50.00 | 3 | seeds | 20.00 | next table stores client has services (one or more), status of service , date done, if applicable: table_jobs job_id | client_id | service_id | status | date_done | -------|-----------|------------|--------|------------| 1 | 1 | 1 | done | 2013-05-01 | 2 | 1 | 3 | active | null | 3 | 2 ...

preg replace - preg_replace whitespace also breaks my special characters -

i have string contains lot of whitespaces , line breaks clean up, use: $str = trim(preg_replace('/\s+/', ' ', $str)); however, when echo out $str notice special characters " à " turn �. when remove preg_replace � becomes " à " again, string full of whitespaces , linebreaks. i tried google (ofc) not whole lot of people seem experience problem :) my knowledge of php intermediate, (still) kinda lack insight of problem might occur :) maybe there problem charset $text = utf8_decode($text); $text = trim(preg_replace('/\s+/', ' ', $text)); $text = utf8_encode($text); are getting utf-8 input?

iphone - How to Lazy Load a static library? -

i working on project involves card swiping on different types of swipers different vendors. these swipers have own static libraries. had no issues in integrating these libraries in project i.e. fine @ compile time, @ runtime start behaving unexpectedly. due fact these libraries have common entry point, going wrong , apis getting called when should not be. all can think of resolve issue lazy loading library. possible in ios because know lazy loading dynamic libraries. if possible how? or there other way solve issue?

sql server - Entity Framework 4 inheritance issue when deployed -

i have asp.net page using ef 4, it has couple of tables linked using inheritance relationship. locally when running on asp.net development server works fine, when deploy iis (windows server 2003) i'm getting error: the resulttype of specified expression not compatible required type. expression resulttype 'transient.reference[a]' required type 'transient.reference[b]' where : b i have found https://connect.microsoft.com/visualstudio/feedback/details/544639/ef4-inheritance-defined-using-queryview-doesnt-work-properly-with-association but doesn't explain why works on development server (though have .net 4.5 installed, development server says it's running on 4.0) , why class/table has problem. i have other tables have same kind of relationships , code works fine. i can't paste code, in ef i'm doing like: var bs = repository.a.oftype<b>().include(..).tolist();

PyDev can't see class from PyTables -

i've installed pytables under windows 7 64 bit , passes tests. both python command prompt , idle can see stringcol class, , python console in eclipse can see it. however, pydev's autocomplete can't discover class, , editor keeps displaying error says undefined variable: stringcol despite error, following code runs in eclipse, using pydev from tables import * if __name__ == '__main__': = stringcol(34) print (a) i've switched workspaces, created projects scratch, deleted pyc contains class. nothing seems help. how make pydev recognize class sitting supposed to? have configured "forced builtins" in interpreter. getting-started guide: additionally, may add other libraries want treat builtins, such os, wxpython, opengl, etc. important, because pydev works on java side static information, modules don't have information when analyzed statically, so, pydev creates shell information on those.

ajax - $(document).ready doesn't work however page is loaded -

as can understand title, browser doesn't call getreleatedproducts method. put breakpoint $(document).ready(function () line doesn't enter ajax call. checked have jquery reference. have idea? $(document).ready(function () { $.ajax({ type: "post", url: "http://localhost:2782/ajaxcallpage.aspx/getreleatedproducts", data: "{productid:" + productid + "}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) {...} you've told server you're sending json: contenttype: "application/json; charset=utf-8", ...but you're sending it: data: "{productid:" + productid + "}", ...is not valid json. valid json, key productid must in double quotes: data: '{"productid":' + productid + '}', // ^ ^ (here i'm assuming productid number. if ...

Rails best practice when embedding a signup form on every page -

i have user model validations behind it. what i'd have signup form on every page of app, static ones. i figured best way through helper methods in application_helpers.rb , works fine, validations don't seem work. i can serve form through iframe, seems bit hacky. i'm using partials now, client side validation (github.com/bcardarella/client_side_validations) works on /new page, not application page. what's best practice in case? one of basic solutions use partial. benefit is: it's built in, it's simple. downside is: you'll busy feed session details proper rendering. another solution use cells kind of case. cells works lightweight controller can controller can do, , it's independent on controller. 1 use case of cells shopping cart, , login form use case in opinion.

gate - How to randomly divide a huge corpus into 3? -

i have corpus(held in jserial datastore) of thousands of documents annotations. need divide 3 smaller ones, random picking. easiest way in gate? a piece of running code or detailed guide welcomed! i use groovy console (load "groovy" plugin, start console tools menu). the following code assumes that you have opened datastore in gate developer you have loaded source corpus, , name "fullcorpus" you have created 3 (or many need) other empty corpora and saved them (empty) same datastore . these receive partitions you have no other corpora open in gate developer apart these four you have no documents open then can run following in groovy console: def rnd = new random() def fullcorpus = corpora.find { it.name == 'fullcorpus' } def parts = corpora.findall {it.name != 'fullcorpus' } fullcorpus.each { doc -> def targetcorpus = parts[rnd.nextint(parts.size())] targetcorpus.add(doc) targetcorpus.unloaddocument(doc) } ret...

php - Codeigniter 2.1 - MySQL JOIN -

i have 2 tables: menu ->id_menu ->title ->page_id ->order pages ->id_page ->title ->page ->slug this select function: public function get_all_menu() { return $this->db ->select('menu.*, pages.id_page, pages.title page_title') ->from($this->table) ->join('pages','id_page = page_id') ->order_by($this->order_by) ->get() ->result_array(); } here problem - item in menu can connected page, can solo (without connection page). means page_id in menu table can 0. if page_id 0, not getting row above query. how can items in menu (those connected , not connected page )? as requested comments: you need use "left join" retrieve partial or incomplete values tables. in case, regular join looking matches between 2 tables. since there's no id 0 in 1 of tables, match can't retrieved , row won't selected. using left j...

Javascript getting the number of elements in getElementsByClassName -

i have following javascript code: b = document.getelementsbyclassname('name1'); c = document.getelementsbyclassname('name2'); if (b.length != 0) { document.getelementbytagname('body')[0].innerhtml = b[0].innerhtml else if (c.length != 0) { document.getelementbytagname('body')[0].innerhtml = c[0].innerhtml } else document.getelementbytagname('body')[0].innerhtml = 'error'; but not getting desired rendering. whole page renders when divs class name name1 , name2 present. what doing wrong? you skipped closing } bracket in if statement; there no getelementbytagname method in native javascript; you'd better use document.body instead. here bit more correct code: var b = document.getelementsbyclassname("name1"), c = document.getelementsbyclassname("name2"); if (b.length > 0) { document.body.innerhtml = b[0].innerhtml; } else if (c.length > 0) { document.body.innerh...

Android-Thumbnail showing correct picture but Original showing different Picture -

i using camera api in app now, have 2 issues in app: i saving image folder in sdcard, problem after capturing , looking folder thumbnail showing correct image after selecting photo display previous taken photo in fullscreen. every time saving photo in same name each time overwrite previous image. second issue using params.setflashmode(camera.parameters.flash_mode_torch) when press button flash doesn't turn of still remains turn on.i have tried camera.release() in surfacedestroyed(surfaceholder holder) you can try this, rough code give direction. bitmap bmp; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //fullscreen requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); //set view setcontentview(r.layout.main); preview = new preview(this); // <3> rootlayout = ((framelayout) findvie...