Posts

Showing posts from April, 2011

android - Can't open database on 2nd user account, error EACCES (Permission denied) -

i have problems app of mine , galaxy nexus 10 multi user support. app has copy database, works fine when logged in first user of tablet, fails java.io.filenotfoundexception: /data/data/packagename/dbname.db: open failed: eacces (permission denied) when logged in second account. second account seems have no rights write /data/data... so, can done it? read of topics concerning problem, still no answer satisfies me. there folder can used share data between users?! the second account seems have no rights write /data/data... correct. so, can done it? i guessing hard-coded path. if so, not this. use getdatabasepath() find proper path database for current user . is there folder can used share data between users?! not aware of. external storage separate between users. in effect, separate user accounts on device if users on separate devices.

java - ThreadLocal and Memory usage -

threadlocal created have separate copy of objects operate on in threadsafe manner. this means number of objects in process increase number of threads. because, each thread create own copy of threadlocals. does not increase memory requirement of process ? you seem imply threadlocal s specific culprit increases memory usage, in fact question not particularly related threadlocal s per se . in situation describe, merely object have been allocated @ point , go unreacheable when thread dies @ latest.

angularjs - Initializing @attr in Angular directive -

i have directive this: can see equivalent plunker here http://plnkr.co/edit/0e2nmyatamd3m3qtctls app.directive('bptest', function() { return { restrict: 'a', templateurl: 'directivetemplate.html', scope: { bptype: '@' }, link: function($scope, $elem, $attrs) { console.log($scope, $elem, $attrs); $scope.bptype = $scope.bptype || 'text'; } // link function }; }); in directivetemplate.html: <div> {{ bptype }} </div> in index.html: <div bp-test bp-type="text"></div> <!-- results in <div>text</div> --> <div bp-test bp-type="number"></div> <!-- results in <div>number</div> --> <div bp-test></div> <!-- results in <div></div> ????? --> since initialize $scope.bptype = $scope.bptype || 'text' , expect third directive <div bp-test></div> display <

linux - MySQL 'user'@'%' is not including 'user'@'localhost' -

i've seen other questions little different. i've created mysql user '%' , granted permissions. on mac , windows: i'm able login using this. mysql -u user -p<password> on linux fails invalid password 'user'@'localhost'. any idea why? hoping 'user'@'%' hosts including localhost behaving in mac , windows different on linux. i asked question myself while back. using % host when creating mysql user localhost special mysql, it's connection on named pipes or unix socket. using % host not include localhost.

sql - "database locked" error in ios while updating query -

i using below code to update query using sqlite . getting "database locked error" . tried searching link , suggested close database, did again getting same error. have mentioned getting error in code. const char *dbpath = [databasepath utf8string]; if (sqlite3_open(dbpath, &database) == sqlite_ok) { nsstring *locationno =null; nsstring *querysql = [nsstring stringwithformat:@"select count(*) code"]; const char *query_stmt = [querysql utf8string]; if (sqlite3_prepare_v2(database,query_stmt, -1, &statement, null) == sqlite_ok) { if (sqlite3_step(statement) == sqlite_row) { locationno = [[nsstring alloc] initwithutf8string:(const char *) sqlite3_column_text(statement, 0)]; int count= [locationno intvalue]; sqlite3_close(database); nslog(@"%@",locationno); if(0==count) { nsstring *insertsql = [nsstring stringwithformat:@

hadoop - Pig Cross product reducer key -

when perform crossproduct operation (followed filtering) reducer sizes imbalanced, reducers writing 0 output , others taking several hours complete. basic example following code: crossproduct = cross tweets, clients; result = filter crossproduct text matches concat('.*', concat(keyword, '.*')); store result 'result' using pigstorage(' '); in case reducer key? this difficult question answer. cross implemented in pig join on synthetic keys. best resource understand cross programming pig - page 68 in example, cross like a = foreach tweets generate flatten(gfcross(0,2)), flatten(*); b = foreach clients generate flatten(gfcross(1,2)), flatten(*); c = cogroup ($0, $1), b ($0, $1); crossproduct = foreach c generate flatten(a), flatten(b); as explained in book, gfcross internal udf. first argument input number, , second argument total number of inputs. in example, udf generates records have schema of (int, int). field same first argument

python - How to control test case run through an excel sheet? -

my question design problem. using python + selenium automation. pyunit unit framework used. have sheet in excel have 2 columns- testcaseid , run. testcaseid have testcase id in , run have either y or n signifying whether test case should runnable or not. trying read particular test case id sheet , see have it's run value, y or n. if y, test case executed unit framework else not run. here excerpt of test case have written: `class test_id_94017(unittest.testcase): ex = excel() def setup(self): self.ex.setupasheetinexcel('select_test_cases_to_run') if self.ex.gettestcaserunstatusfromexcel("94017") == "y": self.driver = browser().createbrowserdriver() self.driver.maximize_window() self.driver.implicitly_wait(15) self.ex.setupasheetinexcel('login') else: return def test_ccpd_regression001_per_custom_check(self): //do the definition gettestcaserunstatusfromexcel(testcaseid) method is

google maps - Android SupportMapFragment did not create a view error -

im struggling figure out weird issue. in android app have fragment contains support map fragment. google maps works fine when gps turned on , fragment creates fine. when gps turned off app wont instantiate, crashes upon opening it. here stack trace: 07-31 22:35:47.905: e/androidruntime(32324): fatal exception: main 07-31 22:35:47.905: e/androidruntime(32324): android.view.inflateexception: binary xml file line #9: error inflating class fragment 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.rinflate(layoutinflater.java:746) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.inflate(layoutinflater.java:489) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.inflate(layoutinflater.java:396) 07-31 22:35:47.905: e/androidruntime(32324): @ au.net.gokart.fragments.trackinfofragm

android - how to move to new fragment at on OnItemClickListener() -

in application want put listview in first fragment , want move new fragment when clicked on item such each item has own details in code. i implemented move activity, manager says must go fragment instead of other activity. i'm new fragment world , don't know how this. manager says can use list fragment have not found useful code. this code: public class mainactivity extends fragmentactivity { sectionspageradapter msectionspageradapter; static progressdialog pd ; viewpager mviewpager; list<fragment> fragments ; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // create adapter return fragment each of 3 // primary sections of app. fragments = new vector<fragment>(); fragments.add(fragment.instantiate(this, fragmentone.class.getname())); fragments.add(fragment.instantiate(this, fragment

Remove special HTML characters from string in PHP -

Image
this question has answer here: php remove special character string 7 answers i found many results reason nothing works me! i've tried preg_replace regex , html_entity_decode , no good... i want select words has hash mark prefix e.g. #word , works fine, hash mark read &rlm;#word , misses up. example: this normal #hash_mark ‏#this_isn't as appears: the regex use select words hash mark prefix '~(?<=\s|^)#[^\s#]++~um' in question marked duplicate, answer doesn't work unicode text, seen in image: the code remove special characters including unicode text, what's required replace &rlm;# normal # function remove_special_char($sentence){ return preg_replace('/[^a-za-z0-9_ %\[\]\.\(\)%&-]/s','',$sentence); } echo remove_special_char("hello مرحبا привет שלום"); o

c# - WPF Difference Between Design View and Running -

Image
in design view have this: but when run, this: this code: <viewbox margin="95,49,399.4,246.4"> <grid width="20" height="20"> <ellipse stroke="black" horizontalalignment="left" width="20"/> <textblock horizontalalignment="center" text="i" textalignment="center" verticalalignment="center"/> </grid> </viewbox> <viewbox margin="21,43,21,243.4"> <grid height="20"> <textblock fontsize="8" horizontalalignment="center" text="lorem ipsum dolor sit amet consecutetur" textalignment="left" verticalalignment="center"/> </grid> </viewbox> is there better way me achieve in design view; and, why there difference @ between two? i'm pretty sure because window different size @ runtime, although that's

e commerce - Does PayPal calculate taxes thru express checkout? -

paypal stores billing , shipping addresses express checkout action. can paypal manually calculate taxes thru express checkout? no, express checkout requires calculate , send taxes us. express checkout won't able (the tax calculator might've seen on profile not apply express checkout transactions).

Is it possible to construct a Python date using only standard libs with a http string timestamp -

this question has answer here: how convert rfc822 python datetime object? 3 answers i have string timestamps this: "wed, 31 jul 2013 13:03:38 gmt" i couldn't see in python docs might have missed it. or if not, assume parsing of string - because has set format. pointers on how started helpful. the dates rfc 822 compliant. yes! need use strptime() import time time.strptime("30 nov 00", "%d %b %y") here link documentation: http://docs.python.org/2/library/time.html#time.strptime

php - Redirect loop in full site to mobile site using session -

i have full site has been in os-commerce , mobile site in core php (codeignitor), , full version , mobile version on sub-domain. e.g full site: www.example.com , mobile site domain m.example.com . when user open full site domain in mobile, website redirect proper mobile domain, if mobile user want view full site user can view fullsite in mobile. i have used complete redirect http://code.google.com/p/php-mobile-detect/ , not redirecting full site or mobile site using session. know have use php sessions , request in order work not sure how use them in instance, please suggest how solve redirecting issue using session? here code is: session_start(); include('includes/mobile_detect.php'); $detect = new mobile_detect; if(isset($_request['fullsite']) && $_request['fullsite'] == 'yes') {//check if fullsite view request mobile or website? $_session['fullsite']="yes"; if($detect->ismobile()) {

sql server - Populate table where columns match | TSQL -

this main table: select name, age, race, person i create temp table based on available in xml file, temp table might have of fields in table person or 1 or 2 in mix order. select * #mytemptable = mike, 44 or can be select * #mytemptable = race, mike is possible populate person table ever values have in temp table? so if #mytemptable have column age populate person table age value column age in table person i suggest turning xml query create temp table ( sql server shred xml temp table ). can have separate update statements age , race, example: update person set age = imported.age person inner join imported on imported.name = person.name imported.age not null and on.

css - Styling Links in MVC3 -

Image
i wondering how can style plain links: @html.actionlink("edit", "edit", new { id=model.id }) to submit button styles this: current submit button css: background: none repeat scroll 0 0 #438ece; border: 1px solid #004989; color: #ffffff; cursor: pointer; font-weight: bold; padding: 5px; margin-top: 15px; margin-right: 10px; try this: http://jsfiddle.net/eas8v/ a { background: none repeat scroll 0 0 #438ece; border: 1px solid #004989; color: #ffffff; cursor: pointer; font-weight: bold; padding: 5px; margin-top: 15px; margin-right: 10px; text-decoration: none; font-weight: normal; font-family: arial; helvetica, sans-seif; font-size: 0.8em; }

histogram - Counting characters in words in a C++ console application -

this problem attempting solve: ask user enter bunch of words, many want, until enter 0. after that, count how many times each letter appears across words, , print out list of each letter , how many times appears. example: enter word> hello enter word> lemon enter word> goodbye enter word> 0 letter: h appears 1 times letter: e appears 3 times ... so far have put words together, , have made comparisons. problem lies in that, after words put together, , 0 input, cannot count each invidual character within combined string. did research, , i've read perform need vectors, not understand how use them. i've been trying @ week right, no avail. c++ sort of different other language have learned (at least me). you can use std::unordered_map , characters key , counter value. each string read, iterate on , increase value corresponding character in map. this way don't need store words.

gdb - Core dump note section -

following question manually generating core dump file , decided dive , hands dirty. i able build basic core dump structure , dead program's memory core dump within big load section. when debugging in gdb, variables back, no problem that. here comes tricky part, how gdb retrieve information program when crashed. i know note section of core dump contains information (cpu registers among others). here objdump -h gives "real" core dump : core.28339: file format elf32-i386 sections: idx name size vma lma file off algn 0 note0 000001e8 00000000 00000000 000000f4 2**0 contents, readonly 1 .reg/28339 00000044 00000000 00000000 00000150 2**2 contents 2 .reg 00000044 00000000 00000000 00000150 2**2 contents 3 .auxv 000000a0 00000000 00000000 0000023c 2**2 contents 4 load1a 00001000 08010000 00000000 00001000 2**1

inheritance - WCF: not deserializing knowntype in array as derived class, unsure how to debug datacontractserializer -

i'm new wcf , hoping offer assistance. i've got non-abstract base class has [knowntype] applied derived classes in, , used in body of request service in array. when call service using xml derived class in, in code after deserialization base class, not derived class. the input xml has xml instance type ( xsi:type ) attribute appears ignored - whatever set to, system gives me base class no error. the actual code/etc i'm getting huge. so, i've knocked representative test, works properly, , interestingly, if change xsi:type invalid type, exception datacontractserializer , unlike code want work! if change name of element force exception, see mention of datacontractserializer : `start element 'itemz' not match end element 'item'. line 110, position 23. @ system.xml.xmlexceptionhelper.throwxmlexception(xmldictionaryreader reader, string res, string arg1, string arg2, string arg3) @ system.xml.xmlutf8textreader.readendelement() @ system

java - Error starting JBoss 7.1.1 on Windows 7 64bit -

i'm learning use jboss tried install it. downloaded , dezip c:. have created environment variable , ok. when launch standalone.bat have java exception: must fix it? 16:14:04,199 info [org.jboss.as.security] (serverservice thread pool -- 44) jbas013101: activating security subsystem 16:14:04,204 info [org.jboss.as.osgi] (serverservice thread pool -- 39) jbas011940: activating osgi subsystem 16:14:04,209 info [org.jboss.as.webservices] (serverservice thread pool -- 48) jbas015537: activating webservices extension 16:14:04,215 info [org.jboss.as.naming] (serverservice thread pool -- 38) jbas011800: activating naming subsystem 16:14:04,226 info [org.jboss.as.configadmin] (serverservice thread pool -- 26) jbas016200: activating configadmin subsystem 16:14:04,222 info [org.jboss.as.security] (msc service thread 1-5) jbas013100: current picketbox version=4.0.7.final 16:14:04,246 info [org.jboss.as.clustering.infinispan] (serverservice thread pool -- 31) jbas010280: activati

canvas - matplotlib and PyQt: Dynamic figure runs slow after several loads or looks messy -

edit: i decided rewrite include working example of problem. although pretty long, hope proves useful many in future. import sys matplotlib.backends.backend_qt4agg import figurecanvasqtagg figurecanvas matplotlib.figure import figure pyqt4.qtgui import * pyqt4.qtcore import * class mainwindow(qmainwindow): def __init__(self): super(mainwindow, self).__init__() self.setgeometry(100, 100, 640, 480) showbutton = qpushbutton('show') toolbarshowbutton = self.addtoolbar('show button toolbar') toolbarshowbutton.addwidget(showbutton) self.connect(showbutton, signal('clicked()'), self.showbuttonclicked) self.graphlabel = graphcanvas(self); self.setcentralwidget(self.graphlabel) def showbuttonclicked(self): self.graphlabel.drawgraph() def resizeevent(self, event): try: self.graphlabel.setfig() except attributeerror: pass class graph

python - os.chroot Operation not permitted -

i'm trying write python script generate debian package. i'm generating required folder structure in temporary folder. in order change uid , gid of /usr , subfolders root thought of using chroot. however, on line os.chroot(tmpdir) i get: oserror: [errno 1] operation not permitted: '/tmp/tmpvntqw7/myproj' i've tried mini-tutorial same results: http://www.tutorialspoint.com/python/os_chroot.htm why be? thanks chroot() can done root. do 1 of these: run script sudo make script setuid root, , setuid(geteuid()) equivalent python magic

java - How do I ignore call to void method in EasyMock -

i have anonymous inner class added in tested class. class totest{ private mymanager mymanager public void seymymanager(mymanager mymanager){ this.mymanager = mymanager; } .... public void dosomething(){ ... mymanager.addlistener(new listener(){...}); ..... } } where manager class other package used in method test body. how ignore addlistener call? p.s. ignore = not want make checks calling mymanager.addlistener(..) methods there's couple of ways this. my preferred way explicit expectations this: mymanager mymanager = easymock.createmock(mymanager.class); ... mymanager.addlistener(easymock.isa(listener.class)); ... replay(mymanager); the important bit here easymock.isa match expectation against listener passed. prefer way when there's problem elsewhere test fails. alternatively can use nice mock: mymanager mymanager = easymock.createnicemock(mymanager.class); ... replay(mymanager); however,

java - Problems running JerseyTest when dealing with HttpServletResponse -

here sample resource class: @path("/resource") public class someresource { @get @produces({mediatype.application_xml}) public string somemethod(@queryparam("param1") string param1, ..., @context httpservletrequest request) { string remoteuser = request.getremoteaddr(); // business logic here. return response; } } and jerseytest resource: public class testsomeresource extends jerseytest { @override protected application configure() { enable(testproperties.log_traffic); return new resourceconfig(someresource.class); } @test public void testxmlresponse() { string response = target("resource") .queryparam("param1", param1) // more parameters here. .request() .accept(mediatype.application_xml)

java - How to use Timer -

i have application made in netbeans , don't have idea how use timer in java. in winform there's control box of timer drag , use only. want use timer 1 seconds after about.seticon(about4); (which gif) executed. import javax.swing.imageicon; int a2 = 0, a3 = 1, a4 = 2; imageicon about2 = new imageicon(getclass().getresource("/2what-is-the-game.gif")); about2.getimage().flush(); imageicon about3 = new imageicon(getclass().getresource("/3how-to-play.gif")); about3.getimage().flush(); imageicon about4 = new imageicon(getclass().getresource("/4about-end.gif")); about4.getimage().flush(); if(a2 == 0) { a2=1; a3=1; about.seticon(about2); } else if (a3 == 1) { a3=0; a4=1; about.seticon(about3); } else if (a4 == 1) { a4=0; a2=0; about.seticon(about4); } } how can achieve this? in java, have several ways of timer implementation or rather uses, few

asp classic - How to use named parameters / named prepared statements with Postgres and ADODB -

i cleaning legacy asp-vba code talks postgres database (8.2) on adodb. @ moment it's using string building sql statements , i'd use prepared statements avoid sql injection. i cannot work out how named variable. i've succeeded in doing "?" operator , adding parameters in order defined in sql. no in situation[1]. i have been able simple simple parameter replacement using ? operator , createparameter(...): var ocmd = server.createobject("adodb.command"); ocmd.commandtext = "select * sometable somefield = ? , = ?"; ocmd.parameters.append ocmd.createparameter("", advarchar, adparaminput, 50, "val1") ocmd.parameters.append ocmd.createparameter("", advarchar, adparaminput, 50, "val2") but if attempt names does not work: var ocmd = server.createobject("adodb.command"); ocmd.commandtext = "select * sometable somefield = @a , = @b"; ocmd.parameters.append ocmd.createparameter(&quo

Errai RestEasy issue with 3.0.0-SNAPSHOT -

i getting error when running errai 3.0.0 snapshot same code works fine 3.0.0.20130604-m1. thanks host].[/airit-mobile-demo].[com.airit.mobile.server.local.rest.restapplication]] (http-/0.0.0.0:8080-2) jbweb000235: allocate exception servlet com.airit.mobile.server.local.rest.restapplication: java.lang.instantiationexception: org.jboss.resteasy.cdi.cdiinjectorfactory @ java.lang.class.newinstance0(class.java:342) [rt.jar:1.6.0_43] @ java.lang.class.newinstance(class.java:310) [rt.jar:1.6.0_43] @ org.jboss.resteasy.spi.resteasydeployment.start(resteasydeployment.ja va:146) [resteasy-jaxrs-2.3.5.final.jar:] @ org.jboss.resteasy.plugins.server.servlet.servletcontainerdispatcher. init(servletcontainerdispatcher.java:67) [resteasy-jaxrs-2.3.5.final.jar:] @ org.jboss.resteasy.plugins.server.servlet.httpservletdispatcher.init( httpservletdispatcher.java:36) [resteasy-jaxrs-2.3.5.final.jar:] @ org.apache.catalina.core.standardwrapper

c++ - sin() cos() ring formula -

this source code: #include <windows.h> #include <string> #include <iostream> #include <fstream> #include <math.h> using namespace std; #define d_open fstream::in | fstream::out | fstream::app | fstream::ate #define space " " #define d_qq "\"" struct point3d { float x; float y; float z; }; struct objectstruct { point3d t_lt; point3d t_lb; point3d t_rt; point3d t_rb; point3d b_lt; point3d b_lb; point3d b_rt; point3d b_rb; }; void createobject(objectstruct myobject) { fstream outmap; outmap.open("prefab.map", d_open); float * x = new float[6]; float * y = new float[6]; float * z = new float[6]; float * x2 = new float[6]; float * y2 = new float[6]; float * z2 = new float[6]; float * x3 = new float[6]; float * y3 = new float[6]; float * z3 = new float[6]; x[0] = myobject.t_lt.x; y[0] = myobject.t_lt.y; z[0] = myo

java - How to sort column based on null/not null values using Spring Repository? -

i using spring data mongodb. have requirement want sort on field, show rows null values @ last. in case of sql write following query select myfield mytable order case when myfield null 1 else 0 end, myfield but not able find out way sort using pagingandsortingrepository. how define sort object? want sort asc, , field type string have @ section 6.3.3 of spring data mongodb type-safe query. can implement querydslpredicateexecutor on repository interface: public interface personrepository extends mongorepository<person, string>, querydslpredicateexecutor<person> { // additional finder methods go here } and can use method: list<t> findall(predicate predicate, orderspecifier<?>... orders); the orderspecifier constructor takes nullhandling enumeration parameter can set nullsfirst / nullslast.

c# - WCF timeout issue but method successfully called -

i have issue wcf timing out. strange thing method being called on server, client call ton object returned createchannel() timing out exception. the entire error messsage: this request operation sent net.pipe://localhost/andonserver did not receive reply within configured timeout (00:01:00). time allotted operation may have been portion of longer timeout. may because service still processing operation or because service unable send reply message. please consider increasing operation timeout (by casting channel/proxy icontextchannel , setting operationtimeout property) , ensure service able connect client. i decrease timeout setting 5 seconds, say, that's bit dirty. have ideas why might happening? mark it means elapsed timeout period waiting reply server. default, calls in wcf have both request , reply, void methods. server needs complete call promptly wcf send reply. option use one-way call if client not require reply server.

symfony - Creating my first twig extension to provide global variables to base templates -

i need populate variable html code , make available base.html.twig file. to achive have made twig extension. first time using twig extentions im not sure if correct way of doing things. here have far: extension code: class globalfooterextension extends \twig_extension { public function getfilters() { return array( new \twig_filter_function('globalfooter', array($this, 'globalfooter')), ); } public function globalfooter() { $globalfooter = file_get_contents('http://mysite.co.uk/footer/footer.html.twig'); return $globalfooter; } public function getname() { return 'globalfooter_extention'; } } config.yml: services: imagine.twig.globalfooterextension: class: imagine\gdmbundle\twig\globalfooterextension tags: - { name: twig.extension } base.html.twig: {{globalfooter}} this give following error: tw