Posts

Showing posts from September, 2015

bash - How do you programmatically add a bats test? -

i'd have bats test created every file in directory, i'm not sure best way done is. approach below creates single test when there many files in directory. #!/usr/bin/env bats in $(ls) @test "testing $i" { pwd } done to extract ls output not batter solution go wrong on filenames spaces. you can below shopt -s nullglob file in /dir/* //test command on $file done shopt -u nullglob you can using find command also find /some/directory -maxdepth 1 -type f -exec cmd option {} \;

clojure - 'get' replacement that throws exception on not found? -

i'd access values in maps , records, throwing exception when key isn't present. here's i've tried. there better strategy? this doesn't work because throw evaluated every time: (defn get-or-throw-1 [rec key] (get rec key (throw (exception. "no value.")))) maybe there's simple method using macro? well, isn't it; has same problem first definition, if evaluation of throw happens later: (defmacro get-or-throw-2 [rec key] `(get ~rec ~key (throw (exception. "no value.")))) this 1 works letting get return value (in theory) never generated other way: (defn get-or-throw-3 [rec key] (let [not-found-thing :i_would_never_name_some_thing_this_021138465079313 value (get rec key not-found-thing)] (if (= value not-found-thing) (throw (exception. "no value.")) value))) i don't having guess keywords or symbols never occur through other processes. (i use gensym generate special value of

rdbms - what exactly the undo information lives in oracle? -

some docs says, there "undo tablespaces" implies should create tablespace undo imformation. some docs says, there "undo segment" implies undo information lives in normal tablespaces , use of it's segment. so, undo information lives , organized? earlier releases of oracle database used rollback segments store undo. oracle9i introduced automatic undo management, simplifies undo space management eliminating complexities associated rollback segment management. oracle recommends (oracle 9i , on words) use undo tablespace (automatic undo management) manage undo rather rollback segments. when creating undo tablespace, these automatically created: n undo segments (based on sessions parameter value) named _syssmun$ owned public (usable ops configuration) not manually manageable

c# - UPnP and Port Forwarding with Lidgren fails -

Image
i'm new networking , lidgren has made easier me begin adding multiplayer capability xna pc game. i've been testing across network setting laptop right next me , has been working great. problem sent copy of game friend in netherlands , cannot connect me. have set 1 person host , other people clients connect host. the host sets server follows: config = new netpeerconfiguration("game"); config.port = 14242; config.enableupnp = true; config.maximumconnections = 3; config.enablemessagetype(netincomingmessagetype.connectionapproval); server = new netserver(config); server.start(); server.upnp.forwardport(14242, "forlorn forest"); here's exception forwardport throws fails , gives "bad request": and 2 web exceptions thrown: it says connection being closed remote host , unable read data transport connection in exception details: any thoughts might going on here? upnp enabled on router. i've taken @ network traffic wireshark

javascript - IE 10 not event not firing bind() or on() using JQuery -

$('body').unload(function () { }); $('body').on("beforeunload", function () { //if true means logged clicked else page close clicked if (istrue == 0) { btgui.webservices.connectiontoken.getlogoutclientusermethod(logoutclientusermethodsucess); } else { btgui.webservices.connectiontoken.pageclosedxmlmethod(hddclient, hddusername); } bind() or on() events not firing in ie 10,except ie working browsers fine. ie version work i'm using jquery 1.7.0 i'm tested $(window) not working. yes, event handler should bound $(window). beforeunload handler supposed return string displayed in confirmation box. seems me you're doing lot more that.

Linux vanilla kernel on QEMU and networking with eth0 -

i have downloaded , compiled vanilla linux kernel (3.7.1) used busybox ramdisk booted using qemu. qemu command line qemu-system-i386 -kernel bzimage -initrd ramdisk.img -append "root=/dev/ram rw console=ttys0 rdinit=/bin/ash" -nographic -net nic -net user everything goes well. however, can't use networking on vanilla kernel busybox. 'ifup eth0' tells me / # ifup eth0 ip: siocgifflags: no such device i googled internet can' clue... advice nice thank in advance. most there no driver (in example should e1000) loaded or device has name. in /sys/class/net/ should find listing of available net-devices. if there none (besides lo) driver not loaded. in qemu monitor type "info pci" , show pci-address of ethernet card. should this: ... bus 0, device 3, function 0: ethernet controller: pci device 8086:100e ... this device corresponds /sys/devices/pci0000:00/0000:00:03.0/. files "vendor" , "device" must c

java - Getting exception in JDBC thin driver -

i try run query using java , below mentioned program import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.statement; import javax.naming.spi.dirstatefactory.result; public class oracleconn { public static void main(string[] args) { try { class.forname("oracle.jdbc.driver.oracledriver"); connection con = drivermanager.getconnection("jdbc:oracle:thin:@localhost:1521:yglobal","user","user"); statement stmt = con.createstatement(); resultset rs = stmt.executequery("select empid empmaster"); while(rs.next()) system.out.println(rs.getint(1)); con.close(); } catch (exception e) { e.printstacktrace(); }} } but when tried run program getting exception java.sql.sqlexception: ora-01756: quoted string not terminated @ oracle.jdbc.driver.databasee

java - StringTokenizer.countTokens() returning erroneous value in for loop condition -

we have calculate numbers of "this" in given string having multiple "this" substrings. eg. "hello recruit , veteran , this" return 4. so using: stringtokenizer stringtokenizer1 = new stringtokenizer(input2); arraylist<string> arraylist1 = new arraylist<string>(); int count=0; int arrindex = stringtokenizer1.counttokens(); (int = 0; < stringtokenizer1.counttokens(); i++) { arraylist1.add(stringtokenizer1.nexttoken()); } (string string2 : arraylist1) { if (string2.equals(string)) { count++; } } output1 = count; system.out.println(output1); return 2. however, if int arrindex assigned value of stringtokenizer1.counttokens() , used in looping condition, it's giving correct result of 4. why?? note:using javase-1.6 the condition stringtokenizer1.counttokens() evaluated everytime reenter loop. per javadoc calculates n

ios - GPUImage is slow the first blurs -

i'm using excellent gpuimage blur views ( https://github.com/bradlarson/gpuimage ) however, seems first couple of times blur views, it's slow. after few blurs, it's faster. why that, , there way preload gpuimage framework fast time? thanks gpuimageiosblurfilter *blurfilter = [gpuimageiosblurfilter new]; blurfilter.blurradiusinpixels = 1; blurfilter.saturation = 1.2; blurfilter.downsampling = 4.0f; blurredimage = [blurfilter imagebyfilteringimage:blurredimage]; there slight lag on first usage of given filter, because framework has compile shaders used filter. these shaders cached later reuse. blurs in particular exhibit this, since shaders generated each blur radius use (for performance reasons when reused in video, etc.). that said, make sure absolutely need work uiimages in above code. -imagebyfilteringimage: isn't fastest approach, since has take in uiimage, generate gpuimagepicture behind scenes, upload image texture, proce

apache - RewriteRule Didn't Work for Me -

my navigation example.com/admin/?nav=home , want rewriterule show example.com/admin/ or example.com/admin/home or example.com/admin/new . i tried tutorials didn't work. answering. try this: rewriteengine on rewritebase / rewriterule ^admin/home$ admin/?nav=home this show admin/?nav=home /admin/home for dynamic urls try this: rewriteengine on rewriterule ^admin/([^/]*)$ /admin/?nav=$1 [l]

hadoop - java.io.IOException: org.apache.thrift.protocol.TProtocolException: Cannot write a TUnion with no set value -

i using thrift scheme store thrift bundles pail file in hadoop cluster. seems working correctly. thrift bundle being created without errors. although,i using kafka send bundle , while serializing,the serializer function converts bundle in byte array.i getting above mentioned error @ point. why kafka in bundle object converting in byte array. or there way can convert object byte array safely.if can please provide it.the error : java.io.ioexception: org.apache.thrift.protocol.tprotocolexception: cannot write tunion no set value! following writeobject function throwing error private void writeobject(java.io.objectoutputstream out) throws java.io.ioexception { try { write(new org.apache.thrift.protocol.tcompactprotocol( new org.apache.thrift.transport.tiostreamtransport(out))); } catch (org.apache.thrift.texception te) { throw new java.io.ioexception(te); } } the message quite clear: there somewhere union object no v

vb.net - Could not load file or assembly DevExpress version 11.1 in asp.net(vb) -

i working on project build on 2.0 framework of .net using devexpress version 7 before controls of devexpress 7 doesn't supports modern browsers. installed , included devexpress version 11 assemblies. i copy/pasted assembly files of version 2011 bin folder of project. added reference in web.config file in web.config, have <add assembly="devexpress.data.v11.1, version=11.1.4.0, culture=neutral, publickeytoken=b88d1754d700e49a"/> <add assembly="devexpress.web.aspxeditors.v11.1, version=11.1.4.0, culture=neutral, publickeytoken=b88d1754d700e49a"/> <add assembly="devexpress.web.aspxgridview.v11.1, version=11.1.4.0, culture=neutral, publickeytoken=b88d1754d700e49a"/> <add assembly="devexpress.web.v11.1, version=11.1.4.0, culture=neutral, publickeytoken=b88d1754d700e49a"/></assemblies> in asp file have : <%@ register assembly="devexpress.web.v11.1, version=11.1.4.0, culture=neutral, publickeytoken=

Creating app.tss in titanium -

how can create app.tss in titanium? i'm following link http://www.smashingmagazine.com/2014/03/10/4-ways-build-mobile-application-part4-appcelerator-titanium/ i think app.tss not alloy controller can't right click on app in project explorer , create alloy contoller. should right click , create new file , label app.tss. have negative effect on entire project? i think app.tss not alloy controller can't right click on app in project explorer , create alloy contoller. yes, right not alloy controller. files extension tss titanium style sheets. app.tss contains styles accessible globally , in folder called app/styles . should have in project default. if don't right click on folder styles -> new -> alloy style

oracle - need to insert data all together into temp table -

hi here sample code . i need insert data both procedures rather 1 after one..this code inserts data 1st first procedure , second row number 1st has ended inserting.please suggest way can insert data , not sequentially. create or replace package body procedure main_proc(param1 number,param2 number,v1 out number,v2 out number) v_resultset help.cursortype-->this defined in package spec v_name varchar2(10); v_code varchar2(40); begin v1:=param1; v2:=param2; proc1(v1,v_resultset); loop fetch v_resultset v_name; exit when v_resultset%notfound; dbms_output.put_line('error in proc1'); insert temp_table(name) values(v_name) ; end loop; proc2(v1,v2,v_resultset); loop fetch v_resultset v_code; exit when v_resultset%notfound; dbms_output.put_line('error in proc2'); insert temp_table(code) values(v_code) ; end loop; end main_proc; proc1(v_name varchar2,r_resultset out help.cursortype) begin open r_resultset select name emp dept_id=2; end; proc2(v_name varchar2,v_

In Meteor, using an object (defined in one file) in another file without global scoping? -

i've got prices.js file shoppingcartcontents object defined in file. i'd access shoppingcartcontents object inside helpers.js file, using create global helper. i can setting shoppingcartcontents global, don't want that. there better way? according docs there's package scope , file scope . these 2 scopes don't seem granular enough me (there's package export feature i'm doing inside 1 package) things can scoped to: one , 1 file the entire package shouldn't there file export feature maybe? if you're working inside package, make variable global. way can access in files, package. if want global variable, have explicitly export it, there's no problem in using globals.

R: edit column values by using if condition -

i have data frame several columns. 1 of contains plotids aeg1, aeg2,..., aeg50, heg1, heg2,..., heg50, seg1, seg2,..., seg50. so, data frame has 150 rows. want change of these plotids, there aeg01, aeg02,... instead of aeg1, aeg2, ... so, want add "0" of column entries. tried using lapply, loop, writing function,... nothing did job. there error message: in if (nchar(as.character(dat_merge$ep_plotid)) == 4) paste(substr(dat_merge$ep_plotid, ... : condition has length > 1 , first element used so, last try: plotid_func <- function(x) { if(nchar(as.character(dat_merge$ep_plotid))==4) paste(substr(dat_merge$ep_plotid, 1, 3), "0", substr(dat_merge$ep_plotid, 4, 4), sep="") } dat_merge$plotid <- sapply(dat_merge$ep_plotid, plotid_func) therewith, wanted select column entries 4 digits. , selected entries, wanted add 0 . can me? dat_merge name of data frame , ep_plotid column want edit. in advance just extract "string" po

php - Apache Webserver : What happens to requests already sent in loop after The connection has timed out -

i have written script create images in loop , loop size 10k. happens after period of time browser shows "the connection has timed out". can still see images being created in specific folder i.e apache still processing request. the point of concern happens http aapche server requests sent in loop after connection has timed out. i curious know apache queue system in detail. you may looking ignore_user_abort directive. there more timeouts in place. apache request timeout (the time apache lets user wait first data). may different max_execution_time in php. if ignore user abort enabled, both timers start. after time apache times out , sends reponse. script in background still runs until either finishes or max_execution_time reached. if disable ignore user abort, script stopped when apache sends timeout user.

php - Why this form in html is not submitting? -

i don't understand why, when open html file form fill gaps , click on submit button, happens. <form method="post" action="php file"> <label>name*</label> <input type="text" name="name" placeholder="your name"> <label>email*</label> <input type="text" name="email" placeholder="your email”> <label>category*</label> <select name="category"> <option value="1">first</option> <option value="2">second</option> </select> <label>phone*</label> <input type="text" name="phone" placeholder="your phone"> <label>website</label> <input type="text" name="web" placeholder="your website”> <label>message</label> <textarea name="message" placeholder="your message"></textarea

c++ - Can't delete dynamic object created in WxApp from OnExit() -

i'm trying understand how wxwidgets (3.0.1) app should designed, i'm missing i'm trying doesn't work. at basic level, have wxapp, creates wxframe, gets displayed , works fine. decided add in logger object.... i made object member of wxapp: class inilogwx : public wxapp { public: virtual bool oninit( ); virtual int onexit( ); private: clogstore * cl_logstore; }; and initialised in wxapp::oninit() bool inilogwx::oninit( ) { mainframe * frame = new mainframe(_("log demo"), wxpoint(250, 250), wxsize(450, 340)); frame->show(true); settopwindow(frame); // create logger class clogstore * cl_logstore = new clogstore( ); return true; } when application closed (closing mainframe) wxapp::onexit() fires, , thought i'd able clean memory here int inilogwx::onexit( ) { delete cl_logstore; // unhandled exception here due invalid pointer return w

java - CXF BusException No DestinationFactory for namespace http://cxf.apache.org/transports/http -

i'm trying stand [basic cxf rs example][1], own service impl simpler , methods return strings. when try run server exception i built clean project i'm starting fresh.. master pom http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <name>tests</name> <groupid>com.crush</groupid> <artifactid>tests</artifactid> <version>1.0</version> <packaging>pom</packaging> <properties> <cxf.version>2.7.11</cxf.version> <httpclient.version>3.1</httpclient.version> <rs-api.version>2.0</rs-api.version> <disclaimer/> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <slf4j.version>1.6.2</slf4j.version> <guava.version>13.0-rc2</guava.version> <jgroups.version>3.1.0.final</jgroups.version> <infinispan.version>5.1.4.cr1</in

php - Call function inside class -

i'm trying create simple class in php, i've got trouble method call. <?php include('mysql.php'); class user { var $sql; function _construct(){ // sql connection $this->sql = new mysql(<<hidden>>, <<hidden>>, <<hidden>>); } public function login($username, $password){ // todo } } ?> at //todo section, want call $this->sql->select('users') , won't let me it. gives error , says sql non-object. your "_construct" missing _ (you must have two), won't called. change : public function __construct(){ it should work. remember make public. if it's not called, $sql variable isn't initialized , non-object php. also, may precise visibility of variable when declaring it, rather using deprecated var keyword : private $sql;

java - Classloader issues: Exception not caught even if explicitly caught in test -

this test scenario: plugin a has utility class a.xyz() provides method throws java.util.nosuchtelementexception plugin b provides "functionality". fragment f uses b host , provides tests b . now, junit test looks this: try { a.xyz(paramtriggeringnosuchmethodexception); fail('a.xyz did not throw nosuchelementexception'); } catch (nosuchelementexception e) { // expected } so, expect a.xyz() throw nosuchelementexception , catch exception excplicitly, still test fails telling me there nosuchtelementexception (which caught myself). if catch throwable instead of nosuchelementexception , test pass. how possible given plugins/fragments run in same environment? seems a.xyz() throws nosuchelementexception loaded using different classloader test itself. btw: test runs within eclipse when started plugin test, fails when run maven using mvn install i've seen similar things happen when maven in m2e gets behind. try followin

office365 - Automate OneDrive for Business local setup for use with Folder Redirection -

after enabling automatic sign in , mapping drive onedrive business, want take 1 step further in replacing on-premise fileshares: i want use folder redirection make sure user data stored on onedrive, make sure user data stored on fileserver @ moment. a direct redirection cloud not possible. possible redirect local onedrive folder data synced cloud. there challenges in regard: the user has start 'onedrive business' app setup sync , local folder. it possible user change default location. for use folder redirection need make sure: sync enabled , there is local folder... this folder needs in same location every user. i thought quite simple this: onedrive.exe -sync c:\users\%username%\onedrive but no way )-: turns out executable called 'groove.exe' , resides in office directory. documentation virtually non-existent, have managed determine following command-line switches: /clean /clean /runfoldersync /onenotestub: /takeoffline: /trayonly ru

java - Elasticsearch - do not map the fields by default -

while indexing document, elasticsearch automatically create mapping missing fields (inside document) is possible configure (or) there configuration can instruct elasticsearch not create missing fields, instead ignore. basically, use java pojo, use instance of same pojo index document (by converting instance json using gson library) , use of fields in pojo external purpose. so when set fields used external purpose, send document elasticsearch, these additional fields saved. want avoid that. yes, possible disable dynamic mapping feature within elasticsearch mappings not created dynamically when new fields ingested. documentation: dynamic mapping when elasticsearch encounters unknown field in document, uses dynamic mapping determine datatype field , automatically adds new field type mapping. sometimes desired behaviour , isn’t. perhaps don’t know fields added documents later on, want them indexed automatically. perhaps want ignore them. or — e

java - Android Shared Preferences using getter/setter methods fail to display -

my android app fails display shared preferences set in different class. missing in code? save them fine don't display in main activity. see default text when run app. have tried can no avail. can't figure out problem is. below code files: 1. mnseditor.java public class mnseditor extends activity { private msitem mnses; private button savebtn; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mns_editor); intent intent = this.getintent(); mnses = new msitem(); mnses.setstartkey(intent.getstringextra("startkey")); mnses.setstartdate(intent.getstringextra("startdate")); mnses.setshiftkey(intent.getstringextra("shiftkey")); mnses.setshift(intent.getstringextra("shift")); mnses.setbkey(intent.getstringextra("bkey")); mnses.setb(intent.getstringextra

model view controller - Uncaught TypeError: undefined is not a function JQUERY in MVC 4 -

Image
i've got problem in jquery, first render view check using developer tools , got error, button click doesn't work. need solve problem i render jquery in views with: <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> but i've got error uncaught typeerror: undefined not function searchemployee:39 (anonymous function) searchemployee:39 l jquery.js:2842 c.firewith jquery.js:2954 x.extend.ready jquery.js:387 s can me solve problem? check not loading jquery.js twice.

Fail to publish my first Azure App -

i followed tutorial in http://msdn.microsoft.com/library/azure/hh690944.aspx create first app deployed azure cloud. however, when tried "publish azure cloud", consumes more time no luck; following message appears: [parallel] ...still uploading (elapsed time: 1585 sec.)... [parallel] ...still uploading (elapsed time: 1590 sec.)... [parallel] ...still uploading (elapsed time: 1595 sec.)... null [windowsazurepackage] warning: failed upload blob http://testwa.blob.core.windows.net/eclipsedeploy/apache-tomcat-7.0.42.zip. deployment might not work correctly in cloud so, please me in publishing first app unzip apache-tomcat-7.0.42.zip file same directory , re-run.

image processing - How to design and implement an adaptive filter for impulse noise removal? -

i should design , implement adaptive filter remove impulse noise medical images! , new in image processing . , don't know how design filter! have checked predefined filters... not want! please b.s. project! impulse noise dealt using median filter. build adaptive filter i'd use statistics figure if there smooth within window. i work on image using windows. in each window i'd check median , mean. if far away each other i'd apply median filter, otherwise, apply local lpf filter of nothing. it simple...

c# - ENtity framework 6 code first: what is the best implementation for a baseobject with 10 childobjects -

we have baseobject 10 childobjects , ef6 code first. of 10 childobjects, 5 have few (extra) properties, , 5 have multiple properties (5 20). implemented table-per-type, have 1 table base , 1 per child (total 10). this, however, creates huge select queries select case , unions on place, takes ef 6 seconds generate (the first time). i read issue, , same issue holds in table-per-concrete type scenario. so left table-per-hierachy, creates table large number of properties, doesn't sound great either. is there solution this? i thought maybe skip inheritance , create union view when want items child objects/records. any other thoughts? thanks in advance. another solution implement kind of cqrs pattern have separate databases writing (command) , reading (query). de-normalize data in read database fast. assuming need @ least 1 normalized model referential integrity, think decision comes down table per hierarchy , table per type. tph reported alex james ef t

python - Why do functions from a dynamically loaded module depend on where the module is stored? -

following this answer , using imp.new_module , exec dynamically load module , extract functions it. however, when store module in local variable, functions broken. here example: import imp mod = none func = none code = """ = 42 def func(): print """ def main(): #global mod global func mod = imp.new_module("modulename") exec code in mod.__dict__ func = mod.func main() func() executing python 2.7.3 yields none : codepad . after uncommenting global mod line, making mod global, function works expected , prints 42: codepad . what missing? why behaviour change when module stored in local variable? the mod module local, , not referenced anywhere else. other objects in python, means cleaned when main exits. making global instead, reference module object kept. when module cleaned up, globals set none (this done break reference cycles early, setting none optimisation prevent excessive rehashing due

php - How do I use $_GET["id"] securely with PDO query? -

i'm trying id of page url , use retrieve information database. want ensure id integer length less 4 , redirect parent page if not. if(isset($_get["id"])) { $id = (int) $_get["id"]; // if id longer 4 redirect if(strlen($id) > 4) { header("location: /parent.php"); exit; } try { $sth = $dbh -> prepare("select id, title, etc, table id = :id"); $sth -> bindparam(':id', $id, pdo::param_int); $sth -> execute(); } catch(pdoexception $e) { // print $e -> getmessage(); echo "error"; exit; } $feature = $sth -> fetch(pdo::fetch_assoc); // if query result empty redirect if($feature == false) { header("location: /parent.php"); exit; } $sth = null; } else { // if id isn't set redirect header("location: /parent.php"); exit; } is way i'm doing secure/corr

javascript - JQuery Mobile Menu static on page change -

i'm trying fix top menu on page change. example: <div data-role="page" id="page1"> //page 1 contents </div> <div data-role="page" id="page2"> //page 2 contents </div> and top menu <div id="top-menu"> </div> is there way not make menù code reappear on each page? want menu div collective pages. any ideas? thanks, andrea no, concept of "pages" not allow static content shared among them. but see @ least 2 solutions: use 1 page containing menu, , many hidden div encapsulate content (like <div data-role="content" id="page1" class="hidden"> ). using menu navigation, have show/hide content need use javascript trickery: $(document).on("pagebeforeshow", "[id^=page]", function(event) { // "move" menu content of current page // (you have add ids each page 'page1content') $

SPSS equivalent of Python Dictionary -

i trying google above, knowing absolutely nothing spss wasn't sure search phrase should using. from initial search (tried using words: "dictionary" , "scripting dictionary") seems there called data dictionary in spss, description suggest not same python dictionaries. would kind enough confirm spss has similar functionality , if yes, can please suggest key words used in google? many dce a python dictionary in-memory hash table lookup of individual elements requires fixed time, , there no deterministic order. spss data files disk-based , sequential , designed fast, in-order access arbitrarily large amounts of data. so these intended quite different purposes, there nothing stopping using python dictionary within statistics using apis in python essentials complement statistics casewise data.

python multithreading and file locking issues -

i have implemented multithreaded code in 2 ways, in both ways got error. explain causes problem? in version 1, got exception saying 2 arguments passed writekey function instead of one. in version 2, 1 of threads reads empty line, therefore exception raised while processing empty string. i using locks, shouldn't prevent multiple threads accessing function or file @ same time? version 1: class somethread(threading.thread): def __init__(self, somequeue, lockfile): threading.thread.__init__(self) self.myqueue = somequeue self.myfilelock = lockfile def writekey(key): if os.path.exists(os.path.join('.', outfile)): open(outfile, 'r') fc: readkey = int(fc.readline().rstrip()) os.remove(os.path.join('.', outfile)) open(outfile, 'w') fw: if readkey > key: fw.write(str(readkey)) else: fw.write(str(key)

caching - PHP APC keeps clearing itself -

i'm using apc (alternative php cache) , after store entries whole cache clears after bit, few minutes. when store entries i'm not defining ttl , ttl in config 0, i'm not sure why entries keep getting deleted. uptime seems 0 minutes perhaps it's restarting reason? apc settings (godaddy shared hosting linux server) apc.cache_by_default 1 apc.canonicalize 1 apc.coredump_unmap 0 apc.enable_cli 0 apc.enabled 1 apc.file_md5 0 apc.file_update_protection 2 apc.filters apc.gc_ttl 3600 apc.include_once_override 0 apc.lazy_classes 0 apc.lazy_functions 0 apc.max_file_size 1m apc.mmap_file_mask apc.num_files_hint 1000 apc.preload_path apc.report_autofilter 0 apc.rfc1867 0 apc.rfc1867_freq 0 apc.rfc1867_name apc_upload_progress apc.rfc1867_prefix upload_ apc.rfc1867_ttl 3600 apc.serializer default apc.shm_segments 1 apc.shm_size 32m apc.shm_strings_buffer 4m apc.slam_defense 1 apc.stat 1 apc.stat_ctime 0 apc.ttl 0 apc.use_r

I'm trying to relate C++ reference to pointer -

before saying duplicate question , downvote (as happened before), searched , found nothing alike. i, many others, trying learn uses of c++ reference variables , relate them pointers. found easier make table , need know whether needs amended. int *n int n int &n caller/local void foo(int *n) n &n &n caller void foo(int n) *n n n local void foo(int &n) *n n n caller the table wants reflect legal passed parameters. [1,1]: passing reference (trivial) [1,2]: passing reference [1,3(1)]: passing reference, an address(?) [1,3(2)]: passing reference, n used alias(?) [2,1]: passing value, dereferencing [2,2]: passing value (trivial) [2,3(1)]: passing value, using value of n (where n alias) [2,3(2)]: passing value (dereferencing n, address) [3,1(1)]: passing reference, foo accepts address [3,1(2)]: passing reference, reference of value @ addres

ubuntu - How can we solve this composer installation issue with php-parser -

i using ubuntu 14 , nginx. i'm getting error when trying install php-parser. composer install loading composer repositories package information installing dependencies (including require-dev) requirements not resolved installable set of packages. problem 1 - installation request h4cc/phpqatools 1.1.0 -> satisfiable h4cc/phpqatools[1.1.0]. - installation request theseer/phpdox 0.5.*@dev -> satisfiable theseer/phpdox[0.5.x-dev]. - don't install nikic/php-parser 1.0.x-dev|install nikic/php-parser dev-master - theseer/phpdox 0.5.x-dev requires nikic/php-parser >=1.0.0 -> satisfiable nikic/php-parser[dev-master, 1.0.x-dev]. - conclusion: don't install nikic/php-parser dev-master

javascript - node.js readFile memory leak -

im using node.js read image every second. idea later push web browsers, making simple stream. code looks following: var fs = require("fs"); var intervaltimerobj; function startstream() { if(!intervaltimerobj) { intervaltimerobj = setinterval( updatestream , 1000); } } function updatestream(){ fs.readfile( __dirname + "/pic.jpg", function(err, image) { }); } startstream(); when running code above seem memory leak memory fills up. larger image file load, quicker fills up. what doing wrong? there way 'release' image variable? i've tried nulling it. this better approach. setinterval() should not used here because lead simultaneous execution of same task. use settimeout() instead. ideal place inside readfile() 's callback: var fs = require("fs"); var timeouthandle = null; function starttimeout() { stoptimeout(); timeouthandle = settimeout(updatestream, 1000); } function st

php - Adding custom HTML to <head> tag in Zend Framework 2 -

i'm trying add custom html tags head script in layout via. controller. ultimate goal add following inside head tags: <noscript><meta http-equiv="refresh" content="5"></noscript> i'm able add refresh meta tag using $headmeta->appendhttpequiv() , have no idea how can wrap in <noscript></noscript> tags. needs added 1 page, don't want separate layout file this. want use whatever methods , functions zf2 have on offer (if fit bill). i've gone through documented view helpers , can't find 1 help. any ideas? you should able placeholder helper. in layout: <html> <head> <?=$this->placeholder('customhead')?> [etc.] then in view the page want on: $this->placeholder('customhead')->set('<noscript><meta http-equiv="refresh" content="5"></noscript>'); change customhead whatever name want. edit

jquery - How to tell if the navbar is collapsed in order to toggle items in the navbar list -

i want to: display image - if menu extended display text - if menu collapsed (when "3 lines button" appears) here code: <nav class="navbar navbar-idebaca navbar-fixed-bottom"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><img src="img/iebaca.png"></a> </div> <div class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li&

compression - How to do Binary Search over memory mapped compressed file in java? -

i have problem, rather close binary search in sorted (memory-mapped ?) file in java i want implement binary search string in large file java mappedbytebuffers in case, large file compressed bzip2. let's file compressed -1 option 100k block. (actually don't know exact options can repak file). how should search strings in such mappedbytebuffer? how decompress 1 block? there standart lib or should read header, deflate section , crc? , block 100k in compressed state, or 100k it's uncompressed data length? , how last block looks like? have done binarysearch on compressed file, maybe not java? you need read file index of each block starts. once have can binary search of blocks. note: if have underlying record or key, split across multiple blocks. a better solution build compressed file yourself. write known number of records block , compress individually. additionally can write index each block starts first key block. allow find right block without deco

Sorting in XSLT from two xml files -

i have these 2 xmls 1> default.xml <ui-defination> <class > <list_view > <members> <member col_span="1" name="code" displayname="code"/> <member col_span="1" name="creationts" displayname="creationts"/> <member col_span="1" name="creator" displayname="creator"/> <member col_span="1" name="displayname" displayname="displayname"/> <member col_span="1" name="emailaddress" displayname="emailaddress"/> <member col_span="1" name="id" displayname="id"/> </members> </list_view> </class> </ui-defination> 2>rules.xml <ui-defination> <class name="role"> <list_view multiselect=&

javascript - Failed to save canvas to png on Android with PhoneGap if the canvas weighs approximately 125 KB -

so, i'm french , come because have problem phonegap / cordova know (according wiki: allows create applications mobile devices using javascript, html5 , css3). in fact, develop mobile websites adapted html, css, , js, , put them in assets / www file android project, , finally, build , test on android device. here facts: created html file possibility user draw touch screen of android device. use property "canvas" of html , javascript langage. want user can save "canvas" png file in internal sd card phone. works code follows : canv = document.getelementbyid('canvas_paint'); function save_as_png() { dataurl = canv.todataurl('image/png'); var data = atob( dataurl.substring( 'data:image/png;base64,'.length ) ), asarray = new uint8array(data.length); /* espaces à laisser ! */ (var i=0; i<data.length; ++i) { asarray[i] = data.charcodeat(i); } blob = new blob( [ asarray.buffer ], {type: 'image/pn

I am unable to create a project using XTRF -

i unable create project languages. example have selected russian target language , tries create project using 'createproject' xtrf webservice api , getting following error. able create estimate using same value xtrf rest api calls. unknownentitynamefaultexception: unknown entity name, type=com.radzisz.xtrf.model.dictionary.language, name=ru please me in resolving issue. regards, vamsi grandhi the system language code in column "iso 639-1 code". language has defined in system. if language cannot found on list, cause error in given case (no language 'ru'). please check ru-ru (vide en-us , en-gb). kind regards, xtrf team

Storing client's IP address in Firebase -

as far know there no information available browser find out client's ip address without making call resource. is there way store client's ip address? mean in similar way firebase.timestamp placeholder works. although i've heard there ways clients determine , report ip address, relying on client side code report ip address opens ability run custom client side code report wrong ip address. the secure way of keeping track of clients' ip addresses either involve having server, or firebase having special function, when called client, causes firebase's server grab client's ip address , save you. my recommendation run simple server can take post request. server needs able verify user request coming from, , able accurately grab client's ip address , save on firebase.

Searching a range of dates in a Microsoft Access 2013 form query -

i trying search database using form user can enter start date , end date , return results. have been trying these forums have said, results getting except range want. data omitted. i tried switching around start/end date fields didn't work. here have right returns opposite results: like "*" & (([uut_result].[start_date_time]) between [forms]![testformresults]![startdatetime] , [forms]![testformresults]![enddatetime]) & "*" where (([uut_result].[start_date_time]) between [forms]![testformresults]![startdatetime] , iif([forms]![testformresults]![enddatetime] null, date(), [forms]![testformresults]![enddatetime]) what iif() evaluates condition, enddatetime = null . if null, aka isnull(enddatetime) = true , returns value if true piece, today's date. if isnull(enddatetime) = false , meaning there date in control, return value if false , in case [forms]![testformresults]![enddatetime] . the * wildcard in sql. used find variati