Posts

Showing posts from May, 2014

javascript - How to prevent linefeed when hit enter on Firefox OS mobile phone -

i want use return key submit something. how prevent linefeed. don't want produce '\r' or '\n'. i used code like: if(e.keycode == 13){ if(textcontent != ""){submit();} //e.preventdefault(); //e.stoppropation(); e.returnvalue = false; return false; } i don't want make new row. your code (you don't need e.returnvalue), have use on keydown event, not keyup.

settimeout - Stopping Nested Timeouts in Javascript -

i want execute piece of arbitrary code , able stop whenever want. figured settimeout , use cleartimeout stop it. if code in timeout creates it's own timeouts, keep executing after clear original. example: var timeoutid = settimeout( function(){ console.log("first event can stopped cleartimout(timeoutid)"); settimeout(function(){console.log("but not one")}, 5000) }, 5000) now 1 way control code being executed , make store value of additional timeouts global variable , clear them @ once. there better way this? , there way on arbitrary code? to clarify, i'm trying able execute function want, stop whenever want, if function contains timeouts you can put inner timeout variable too: var innertimeout, timeoutid = settimeout( function(){ console.log("first event can stopped cleartimout(timeoutid)"); innertimeout = settimeout(function(){console.log("but not one")}, 5000); ...

uiview - Draw swipe with UIBezierPath in UIImageView -

Image
i trying draw in uiimageview..i able draw without problems in uiview using following code: @implementation drawview { uibezierpath *path; } - (id)initwithcoder:(nscoder *)adecoder { if (self = [super initwithcoder:adecoder]) { [self setmultipletouchenabled:no]; [self setbackgroundcolor:[uicolor whitecolor]]; path = [uibezierpath bezierpath]; [path setlinewidth:2.0]; } return self; } - (void)drawrect:(cgrect)rect { [[uicolor blackcolor] setstroke]; [path stroke]; } - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint p = [touch locationinview:self]; [path movetopoint:p]; } - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint p = [touch locationinview:self]; [path addlinetopoint:p]; // (4) [self setneedsdisplay]; } - (void)touchesended:(nsset *)touches withevent:(uie...

unit testing - Get parameters of a mocked method in python -

i using python's unittest.mock framework. i want achieve following goal mock: the original method like: def mymethod(para1, para2, para3): return para1 + para2 + para3 i want mock return first para1 - discard rest: def mymethod(para1, para2, para3): return para1 i saw can set return_value of mocked object, seems hardcoded one. saw can parameters of mocked call, after called. - there way parameter , return dynamically? using side_effect of mock class: import mock def mymethod(para1, para2, para3): return para1 + para2 + para3 m = mock.mock(side_effect=lambda *args: args[0]) mock.patch('__main__.mymethod', m): assert mymethod(1, 2, 3) == 1

codeigniter - ci-merchant purchase() not working -

im using ci-merchant library in pyrocms module locally on development wamp server. (all working fine) when upload linux test server purchase() function being called not seem work. when executes pools 5 minutes response " could not connect host ". php $params = array( 'amount' => 20, 'currency' => 'usd', 'return_url' => 'http://someurl.com/return/' 'cancel_url' => 'http://someurl.com/cancel/' ); $settings = array( 'test_mode' => true, 'username' => 'paypal_test_username' 'password' => 'my_papal_test_pass' 'signature' => 'my_paypal_test_sig' ); $this->load->library('merchant'); $this->merchant->load('paypal_express'); $this->merchant->initialize($settings); //this im having issue $re...

powerpoint - How to load an Office add-in already installed from an external program in c#? -

i'm developing add-in power point vsto in c#, it's installed not loaded on startup of power point. whant external program lounch power point (already solved), , when lounched make power point load add-in. i have found addins inside microsoft.office.interop.powerpoint.application, don't know if thats way it. i don't whant add-in load every time open power point. any ideas?

Correct way to define a Gradle plugin property extension with Java? -

i'm trying create gradle plugin in java has property extensions (not conventions, apparently old , wrong way). record, i'm working gradle 1.6 on linux machine (ubuntu 12.04). i've gotten far figuring out should done in plugin class definition. here way of adding extension. create extension class contains properties: public class mypluginextensions { file sourcedir; file outputdir; public mypluginextensions(project project) { this.project = project; sourcedir = new file(project.getprojectdir(), "src"); outputdir = new file(project.getbuilddir(), "out"); } } now add these extensions project in main plugin class: public class myplugin implements plugin<project> { @override public void apply(project project) { map<string,object> taskinfo = new hashmap<string,object>(); taskinfo.put("type", myplugintask.class); taskinfo.put("description...

How to get Google map in ios 6.0 and above versions -

apple has taken out google map ios 6.0 version onwards.apple using mkmapview not clear google map..i used googlemapoverlay displayed google map inside mkmapview..googlemapoverlay displays worldmap want move specific loaction using latitude , longitude...if specify latitude , longitude position in googlemapoverlay example getting particular position alone in rectangle shape overlay @ can see mkmapview...can 1 please guide me resolve this..thank you you can use google maps on ios 6 adding uiwebview , adding map on it.

ios - How to force UIWebView to load before transition -

ios 6.1 when button tapped, want perform transition imageview webview. problem first time webview loads, page white , html page loads after transition: nepcontainerview *containerinframe = (nepcontainerview *)[self view]; uiwebview *webview = [[uiwebview alloc] initwithframe:self.view.frame]; [webview loadhtmlstring:html baseurl:nil]; [uiview transitionwithview:containerinframe duration:duration_trans_photo_desc options:uiviewanimationoptiontransitionflipfromleft animations:^{ [containerinframe addsubview:webview]; [sender settitle:@" photo "]; } completion:null]; how can force html page loaded before transition? you can use webcontentview library. this library have 1 method named + (void)preloadcontent:(nsstring *)content; you can use method preload content render fast. hope helps. here use...

perl programming to store column value based on another column value -

i have input in text file : time(1ps) *_sysclock *hy_dvdd_0 *y_vdd18_0 *s_enabled *lpi_clk_0 ========== ========== ========== ========== ========== ========== 1000000000 1 1 1 11 1 1000000045 1 1 1 11 0 1000008365 1 1 1 11 1 1000009824 0 1 1 11 1 1000016685 0 1 1 11 0 1000025005 0 1 1 11 1 1000033325 0 1 1 11 0 1000035828 1 1 1 11 0 1000041645 1 1 1 11 1 1000049965 1 1 1 11 0 1000058285 1 1 1 11 1 1000061832 0 1 1 11 1 1000066605 0 1 1 ...

smtp - Export django settings to my python file -

i trying make logparser.py in django project parses data coming different servers. and on running command on terminal : $ python logparser.py this error coming : traceback (most recent call last): file "logparser.py", line 13, in <module> smtp_conf = settings.smtp_conf file "/home/arya/.virtualenv/devel/.virtualenvs/hu/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__ self._setup(name) file "/home/arya/.virtualenv/devel/.virtualenvs/hu/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup self._wrapped = settings(settings_module) file "/home/arya/.virtualenv/devel/.virtualenvs/hu/local/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__ raise importerror("could not import settings '%s' (is on sys.path?): %s" % (self.settings_module, e)) importerror: not import settings 'hma.settings' (is on sy...

Is it possible to create a batch file that will call another batch file at some point and also supply it with a sequence of inputs -

i have batch file (lets "test.bat"). when run test.bat asks user inputs during it's execution, ex. user credentials , shows menu. user can choose option menu entering value after script ask him lot more product specific details. question: need call test.bat inside batch file , whenever test.bat requires user inputs batch script should able provide inputs (a known sequence of menu options , inputs). is there anyway can achieve this? to call batch file, refer link: several ways call windows batch file 1 or prompt. 1 in case? to user inputs: echo off set /p x=path name: echo path %x% pause

mono - How to receive sms only with my app in monodroid? -

sorry, can't speak eng. want make application xamarin (monodroid) , receive sms that. how can disable other apps sms notifications? in eclipse can use of "abortbroadcast()",but mono dosent have function. plz me realy important me. use broadcastreceiver.invokeabortbroadcast() method.

objective c - How to Persist Application State in cocoa -

i need store state of application @ application termination time, when user re-run app, app run state in closed last time. kind of restoring app restore methods called when app close unexpectedly. need restore app each time when close unexpectedly of user close manually. need store app ui not data of application. idea helpful me. thanks - (nsapplicationterminatereply)applicationshouldterminate:(nsapplication *)sender { //savedata return nsterminatenow; } if want save nswindow position , can use [window saveframeusingname:@"mywindow"]; , use [window setframeautosavename:@"mywindow"]; @ app launch.

ios - UICollectionView insert items transitions not working as expected -

in uicollectionview i'm inserting items retrieve data server. have custom layout file , i'm using initiallayoutattributesforappearingitematindexpath method define how cells must appear they're inserted. problem have transition defined in initiallayoutattributesforappearingitematindexpath not working cells not in first screen space. for example lets have 20 items in collection view. 10 of them can fit first screen , other 10 below have scroll , view (typical scenario). transitions first 10 works fine* scroll down can see items 11-20 wont animate , still remain @ initial position. as simple example lets offset frame 50px left. items 11-20 scroll down remain @ -50 offset frame , wont return normal place. can guide me on how fix ? here how insert data nsmutablearray *indexarr = [nsmutablearray array]; (int i=0; i<weakself.data.count; i++) { [indexarr addobject:[nsindexpath indexpathforitem:i insection:0]]; ...

javascript - When the last part of expression will be returned -

i have following expression taken jquery native code: handlers = ( jquery._data( this, "events" ) || {} )[ event.type ] || [] i'm curios under conditions last part of expression - [] - assigned handlers variable? here speculation: 1) part executed first ( jquery._data( this, "events" ) || {} ) . if there no attached events jquery._data( this, "events" ) === undefined , empty object returned. 2) part {}[event.type] || [] processed. if event.type undefined, array returned , assigned handlers variable. means array returned enough event.type undefined? am right? so means array returned enough event.type undefined ? yes, array returned if event.type has value not exist property name in object. is, if first expression evaluates to empty object, any value of event.type result in array being returned. example: ({}['click'] || [])

android - Is it better to pass data via intent or query the database when needed? -

i wondering better way handle data in several activities in android. say had 2 activities, , b, hold views. first load data sql database , inflate views in a. now, want start activity b, uses same set of data did. is better pass data via intent ( putextra() ) , inflate views or better query database again , inflate. i not sure that, because both approaches seem have disadvantages: querying database takes more time /more resources putting data intent makes more complex, because of putting , getting data (especially when working more activities) can give me advice on best practice? as compare db query use intent. and way is, use 1 common class holds data temporary.

Calling global function inside a CUDA Kernel -

i'm trying write cuda kernel function contains matrix multiplication, like: __device__ matrix_multi(matrix a,matrix b,matrix c); __global__ void foo(type para){ .... matrix_multi(matrix a,matrix b,matrix c); .... } i want accelerate matrix multiplication operation. have 2 choices: first, using cublas library. second, write kernel matrix multiplication , call inside foo() . i failed in both cases. can help? i suggest not write own mat-mul kernel @ time. try cublas way. cublas lib can called in kernel devices compute capability @ least equal 3.5. otherwise can called host side. check cc version before using cublas lib.

c# - Add new row at bottom of datagridview in Winform -

i have datagridview in winform application. when click on add button want blank row inserted @ bottom of datagridview. i tried one: datagridview1.rows.add(row); but blank row inserted @ top not @ bottom. there way insert @ bottom? you can use insert method: datagridview1.rows.insert(datagridview1.rows.count-1, row);

How to post XML data via HTTP POST method in windows store apps? -

any samples on consuming rest service post method in windows 8 apps.please let me know possible links on that. try this using system.io; using system.net.http; using system.text; var objhttpclient = new httpclient(); var formparameters = "<details><id>1</id><name>test</name></details>"); var objhttprequestmessage = new httprequestmessage(httpmethod.post, "http://example.com/page"); objhttprequestmessage.content = new streamcontent(new memorystream(encoding.utf8.getbytes(formparameters))); objhttprequestmessage.content.headers.add("content-type", "text/xml"); var result = await objhttpclient.sendasync(objhttprequestmessage); also check httpclient sample on msdn

Changing the language of the web application in java -

can 1 tell me how change language of web application in java without using properties file. for instance if browser's language in french web application text has change french. the standard way use accept-language header . instance: accept-language:en-us,en;q=0.8,fr-fr;q=0.6,fr; usually build application on top of framework (e.g. spring) and/or technology (e.g. jsf) takes care of problem , gives correct locale of user. based on locale , retrieve correct version of given message. typically, have multiple properties file (one each language). managed framework or technologie using. actually, definitively have tell more application if want precise answer.

mysql - About sphinx segment rules -

when use sphinx, found results not quite accurate. for example, in mysql table, there records 'test1', 'test2', 'test.zip', 'test_zip', 'test-zip' when search 'test', got 'test.zip' , 'test-zip'. , if want 'test1' in result, have search 'test1' explicitly so question is, why sphinx not consider test1 'test' , '1', , if want search results including part of full word, how that? the default charset_table, sets letters, numbers , underscore word charactors, else seperator. so test1 indexed "test1" test-zip indexed "test zip" there infix/prefix indexing http://sphinxsearch.com/docs/current.html#conf-min-infix-len can match part words. (sphinx default matches whole words) if want change charset_table, numbers not considered word charactors (but wouldnt able search numbers!) - @ same time want not include underscore - taht test_zip considered 2 words....

javascript - KnockoutJS newly added element does not have any styling from the stylesheet -

i'm trying use knockout, similar page: http://knockoutjs.com/examples/carteditor.html however, when used jquery mobile theme - when select item category drop down, adds drop down list under product heading - second dropdown added, doesn't have mobile styling applied. i've added fiddle here: http://jsfiddle.net/mtait/adnur/1927/ - demonstrate. can add add styling new drop down list? function formatcurrency(value) { return "$" + value.tofixed(2); } var cartline = function() { var self = this; self.category = ko.observable(); self.product = ko.observable(); self.quantity = ko.observable(1); self.subtotal = ko.computed(function() { return self.product() ? self.product().price * parseint("0" + self.quantity(), 10) : 0; }); // whenever category changes, reset product selection self.category.subscribe(function() { self.product(undefined); }); }; var cart = function() { // stores array of lines, , these, can work out grandtotal var self = t...

Nested popup in jquery -

my requirement is. i have 1 document button in page . when clicks on document button new pop open documents in table format edit , delete button. when user clicks o edit again needs show document in new pop i'm using simple modal pop http://www.ericmmartin.com/projects/simplemodal/ not support multiple popup . please suggest jquery popup supports multiple popups i think more useful take approach. popup inside popup not user friendly. i suggest following: when clicking on edit or delete button, replace content inside pop up.

android - Can't logout from facebook session -

i have created facebook integrate application. can login , logout correctly no problems, , when login , close app re-open can logout correctly. problem when login run application eclipse can't logout. shows errors. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); facebook = new facebook(app_id); masyncrunner = new asyncfacebookrunner(facebook); sharepref = getpreferences(mode_private); facebook.setaccesstoken(sharepref.getstring(access_token, null)); facebook.setaccessexpires(sharepref.getlong(expire_session, 0)); buttonlogin.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { logintofacebook(); } }); buttonlogout.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { logoutfacebook(); } ...

select - C# copy function richtextbox with formatting -

how make button allows me copy ctrl+c function. want select part of rich text box , when button clicked copies selected part. formatting! on button click event should like: if (richtextbox1.selectionlength > 0) // copy selected text clipboard clipboard.settext(richtextbox1.selectedtext, textdataformat.text);

python - QGridLayout, expand widget on the line -

i have qgridlayout handle widgets. fact stay in column put them, without expanding on whole width. there option tell rows expand ? goal mimic behavior of qhboxlayout, without using one. example: self.label_player = qtgui.qlabel("chemin du lecteur :") self.line_path = qtgui.qlineedit() self.button_select_player = qtgui.qpushbutton("sélectionner") ...some code self.grid_settings.addwidget(self.label_player, 3, 0, 2, 1) self.grid_settings.addwidget(self.line_path, 3, 1, 1, 1) self.grid_settings.addwidget(self.button_select_player, 3, 2, 1, 1) edit: here image of want, obtained result qhboxlayout in qgridlayout, line in red (what try without): http://i.imgur.com/hnnhjlp.png and here 1 default behavior of qgridlayout. it's have: http://i.imgur.com/xvqy5ai.png import sys pyside import qtgui, qtcore class window(qtgui.qwidget): def __init__(self): super(window, self).__init__() self.grid = qtgui.qgridlayout() bi...

computer vision - train Cascade ObjectDetector matlab -

i'm asking how can'i use traincascadeobjectdetector while create positive smples structre composed of filename , bonding boxes cordinates. hase negative exemple images file. when lnche function flow traincascadeobjectdetector('newdetector.xml', str, negativefolder, 'falsealarmrate', 0.2, 'numcascadestages', 5); i have error: error using traincascadeobjectdetector>parseinputs (line 306) argument 'positive_instances' failed validation error: cannot find struct field 'imagefilename' in positive_instances. error in traincascadeobjectdetector (line 161) parser = parseinputs(varargin{:}); as error says, str not contain field called imagefilename , should field image files are. quoting matlab documentation: positive_instances array of structs information positive instances. struct fields are: imagefilename - string specifies image name. image can true color, ...

active directory - PHP LDAP Distinguish user from computer -

is there way query ldap , leave out computers in result? there users , computers inside ou, , want display users cn, title,address etc... thanks! you need add following ldap filter (!(objectclass=computer)) . exclude computer objects. you can read more on ldap filters in ldap filter syntax article.

php - Adding a second form from Ajax output -

i working on admin module db-project. user chooses table dropdown , jquery submits name of table php selects fields, composes , echoes it. works charm. function ajax_search(){ $("#table_list").show(); var search_val=$("#tables").val(); $.post("./ajax/xxxxx.php", {searched_table : search_val}, function(data){ if (data.length>0){ $('#spinner_div').hide(); $("#table_list").html(data); } }) } now add form under table adding 1 row. if hard code form on html-page , uses jquery like function ajax_add(){ $("#table_list").show(); var add_val=$("#manufacturer").val(); $.post("./ajax/xxxxxx.php", $("#addform").serialize(), function(data){ if (data.length>0){ $('#spinner_div').hide(); $("#table_list").html(data); } }) } i can catch...

c# - CancellationTokenSource, When to dispose? -

this question has answer here: when dispose cancellationtokensource? 6 answers when supposed dispose of cancellationtokensource? if example make 1 , put in threads everytime click button: private void button_click(object sender, eventargs e) { if (clicked == false) { clicked = true; ctssend = new cancellationtokensource(); thread1 = new thread(() => method1(ctssend.token)); thread1.start(); thread2 = new thread(() => method2(ctssend.token)); thread2.start(); } else { ctssend.cancel(); ctssend.dispose(); clicked = false; } } am supposed dispose of that? cause if so, bit problematic need put in disposer dispose when application closes, there isn´t guarantee won´t disposed if not waiting it, ...

python - IndentationError: unexpected indent on def parse_item(self, response) for scrapy,spider -

i using scrapy information pages of website. here dmoz_spider.py file.when execute indentationerror. please me out. from scrapy.spider import basespider scrapy.selector import htmlxpathselector scrapy.item import item, field import string scrapy.contrib.spiders import crawlspider, rule scrapy.contrib.linkextractors.sgml import sgmllinkextractor class eypitem(item): title = field() link = field() price = field() review = field() class eypspider(crawlspider): name = "dmoz" allowed_domains =["http://www.walgreens.com"] start_urls =["http://www.walgreens.com/search/results.jsp?ntt=allergy%20medicine"] rules = (rule(sgmllinkextractor(allow=('/search/results\.jsp', )), callback='parse_item', follow= true),) def parse_item(self, response): self.log('hi, item page! %s' % response.url) hxs = htmlxpathselector(response) sites = hxs.select('//div[@id="productgrid"]') ...

Launching a new Android activity via Javascript in a Webview -

i have android test app , trying call function javacriptinterface class. webview plays video , when ends calls js method should call android method launch new activity. that doesn't seem happening @ all, when video done it's webview reloads , plays video again. is possible launch activity this? can provideo sample code in 45 minutes. the videoactivity.java public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().requestfeature(window.feature_action_bar); getactionbar().hide(); this.setrequestedorientation(activityinfo.screen_orientation_landscape); setcontentview(r.layout.activity_main); try { webview mywebview = (webview) findviewbyid(r.id.webview); mywebview.setwebchromeclient(new webchromeclient() { }); websettings websettings = mywebview.getsettings(); websettings.setjavascriptenabled(true); ...

java - Unexpected exception while filling JasperReports report - Could not initialize net.sf.jasperreports.engine.util.JRStyledTextParser (GWT) -

i building website gwt , want incorporate report generator in site using jasperreports . data report draws store in database in cloud, use instance , cloud sql connect database , retrieve/store data (basically user table). user supposed login credentials , pressing button "download" should able generated report in pdf form. have implemented rpc process. the problem when jasperfillmanager.fillreport method called fill report, following exception severe: javax.servlet.servletcontext log: exception while dispatching incoming rpc call com.google.gwt.user.server.rpc.unexpectedexception: service method 'public abstract java.lang.string com.myproject.website.client.reportservice.createreport(java.lang.string,java.lang.string)' threw unexpected exception: java.lang.noclassdeffounderror: java.awt.font restricted class. please see google app engine developer's guide more details. @ com.google.gwt.user.server.rpc.rpc.encoderesponseforfailure(rpc.java:389) ...

Sencha Touch ListView IndexBar + selectfield -

i new sencha , have indexbar option listview launched selectfield. tried defaulttabletpickerconfig: { listeners: { painted: function(panel) { var list = panel.down('list'); list.setindexbar(true); } } } but code doesn't work, please help. if new sencha please not use defaulttabletpickerconfig setting. please describe more want get, share more code have written.

magento - Limit the number of google recaptcha characters -

i'm using google recaptcha, , feel can little difficult. 2 words user has type in, , of words can 7+ characters. so there way limit numbers of google recaptcha characters ?? thanks there no way limit number of characters of google recaptcha. if user can't find captacha because it's messy, long, can ask captcha, , that's how works. moreover, reducing number of character reduce effectiveness of recaptcha. if want easier, have else or create own captcha system.

android - to implement code which can receive continuous data from bluetooth health device and I'm getting runtime error on eclipse. -

* this problem related method "ondestroy()" i've used in activity class.please * bluetoothhdpactivity.java package com.example.bluetoothhdp; public class bluetoothhdpactivity extends activity { private static final string tag = "bluetoothhealthactivity"; private static final int health_profile_source_data_type = 0x1007; private static final int request_enable_bt = 1; private textview mconnectindicator; private imageview mdataindicator; private textview mstatusmessage; private bluetoothadapter mbluetoothadapter; private bluetoothdevice[] mallbondeddevices; private bluetoothdevice mdevice; private int mdeviceindex = 0; private resources mres; private messenger mhealthservice; private boolean mhealthservicebound; private handler mincominghandler = new handler() { @override public void handlemessage(message msg) { switch (msg.what) { case bluetoothhdpservice.status_health_app_reg:mstatusmessage.settext( ...