Posts

Showing posts from May, 2011

bash - set -e makes function stop running early? -

i have function seems break when turn on errors set -e . suspect working intended can't see i'm doing wrong. here function: #!/usr/bin/env bash set -e my_function() { base_dir="/tmp/test" if [ ! -d $base_dir ]; echo "creating $base_dir" mkdir -p $base_dir touch $base_dir/some-file.txt fi is_edited=$(grep "foo" $base_dir/some-file.txt) if [ ! -z $is_edited ]; cd $base_dir echo "doing stuff" docker run --rm debian ls fi echo echo "done" echo } my_function with set -e flipped on, function returns seemingly without hit echo statements. set -e turned off, echo statements hit. happening , how fix this? try using: is_edited=$(grep "foo" $base_dir/some-file.txt || test $? -eq 1) the exit status of grep 0 if found match, 1 if didn't find match, , 2 if got actual error. if there's no match foo in fi...

lisp - ZIP contents as a Gray stream? -

i'm writing cl library read ms excel(tm) spreadsheets called "xlmanip" (not ready prime time yet -- reads "xlsx" spreadsheets, works 80% use case of "i want operate on cell contents"... digress.) one thing worries me when reading "xlsx" (zip archives in xml format) current zip handling library, common lisp zip, unpacks compressed contents (vector (unsigned-byte 8)) . large spreadsheet, that'll cause issue end user. one alternative i've thought delayed loading -- let-over-lambda closure demand-loads worksheet when needed. however, that's delaying inevitable. are there zip file cl libraries out there return gray stream zip component's contents opposed (potentially large) (vector (unsigned-byte 8)) ? edit: clarification i'm looking zip component function returns stream , not 1 takes stream . functions take stream write zip component's contents directly file associated stream. i'd rather xlmanip reads st...

javascript - Script works inline but when i move to external doesnt work? -

i made script navigation. becomes sticky navigation once scrolled top. it works great when have @ bottom of index file via <script> tags when try place in external js file doesnt seam fire @ all. full fiddle heres script: var windw = this; $.fn.followto = function ( pos ) { var $this = this, $window = $(windw); $window.scroll(function(e){ if ($window.scrolltop() > pos) { $this.css({ position: 'fixed', top: "20px" }); } else { $this.css({ position: 'absolute', bottom: '0', left: '0', right:'0', top: 'inherit' }); } }); }; $('#mainnav').followto( $(window).height() - ( $('#mainnav').innerheight() + $('.globalheader').innerheight() )); the jquery library missing must add above external scr...

javascript - Browserify working with grunt ReacjJS and yii2 vendor path -

background i'm trying setup yii2 project browserify manage js dependancies. yii2 places js , css dependancies in vendor/bower directory, i'm trying configure browserify use include path vendor dependancies. i have grunt task setup run js build. problem when try compile js files using grunt task getting error trying find react (the first include in js project). error: cannot find module 'react' '{my-working-directory}/modules/contact/asset/js' code i have react installed (bower install) , available in vendor/bower directory. project js src files i'm trying build located in modules/contact/asset/js/ . in js files i'm including react @ top of file. modules/contact/asset/js/main.jsa var react = require('react'); var component = react.createclass({ render: function() { ... } }); ... i have setup grunt browserify task include paths browserify knows how find includes, have additionally added react transform j...

java - How to override injection by another instance -

i have class cannot change: class somebean { @inject private dep1 dep1; @inject private dep2 dep2; ... @inject private depn depn; } i have class: class mybean { @inject@named("bean1") private somebean bean1; @inject@named("bean2") private somebean bean2; } how make module configuration bean1 , bean2 injected different instances have different dep2 instances, other dependencies same? if using spring, create bean in context file such as: <bean class="mybean"> <property name="bean1"> <bean class="somebean"> <property name="dep2" ref="dep2instancea"/> </bean> </property> <property name="bean2"> <bean class="somebean"> <property name="dep2" ref="dep2instanceb"/> </bean> </property> </bean> so explicitly ...

c# - WinForms DataGridView Checkbox -

i trying figure out how set cell in datagridview readonly. checkbox being added boolean property. therefore, looking tips how accomplished task of setting cell readonly based on column boolean property. below snippet of code. [displayname("lock")] public bool revenuelock { get; set; } revenue = new domesticcostrevenue() { revenuelock = convert.toboolean(values[10]), revenue = convert.todouble(values[11]) }; domestic.add(revenue); } costrevenuegridview.datasource = domestic; this i've done no success far. foreach (datagridviewrow row in costrevenuegridview.rows) { if ((bool)row.cells["revenuelock"].value == true) { row.cells["revenue"].readonly = true; //messagebox.show("lock"); } } you can set whole column or whole row or specific cell read only: column: this.datagridview1.columns[1].readonly = true; row: this.datagridview1.rows[0].readonly = true; cell: this.datagridview1.rows[0].cells[1].readonly = true; ...

JavaScript Object.observe on prototype -

consider code below : function createfoo() { var val; function foo() {} object.defineproperty(foo.prototype, 'foo', { get: function () { return val; }, set: function (value) { val = value; document.write('foo value set : ', value); } }); return new foo(); } var foo = createfoo(); object.observe(foo, function (changes) { document.write(changes); }); foo.foo = 'bar'; why object.observe 's handler never fired? can object prototype "observed"? (please, answers must not suggest use kind of third party library.) update please, read comments more information , resolution problem. this foo.foo = 'bar'; does not modify neither foo object nor prototype observe not report anything. here version triggers observer on this.val = value; : function createfoo() { function foo() {} object.defineproperty(foo.prototype, 'foo...

couchDB reduce: does rereduce preserve the order of results from map? -

with couchdb view, results ordered key. have been using values associated highest number. example, take result (in key: value form): {1:'sam'} {2:'jim'} {4:'joan'} {5:'jill'} couchdb sort according key. (it helpful think of key "score".) want find out has highest or lowest score. i have written reduce function so: function(keys, values) { var len = values.length; return values[len - 1]; } i know there's _stat , like, these not possible in application (this slimmed down, hypothetical example). usually when run reduce, either 'sam' or 'jill' depending on whether descending set. want. however, in large data-sets, middle of list. i suspect happening on rereduce. had assumed when rereduce has been run, order of results preserved. however, can find no assurances case. know on rereduce, key null, normal sorting rules not sorted. case? if so, advice on how highest scorer? yeah, don't think sorting ...

python - Is this an efficient / appropriate use of a bloom filter? -

i have api data comes in, lot of redundant (can determined id). have bloom filter built few million entries start. i using this library handle implementation. reading online: bloom filter compact data structure probabilistic representation of set of variables ensure whether elements in set present or definitely not present in set. source if have pseudocode this newdata #some dataset row in newdata: #filter.add() returns true if in set, want not in set if not filter.add(row.id): #do stuff fresh data this function called every time set of data comes in, 200 new entries/sec. is efficient way use bloom filter? a bloom filter can, given element, give 2 answers. can "i sure have never seen element before" or "i believe have seen element before". in latter case, may bloom filter incorrect (that is, it's saying "i think i've seen before" when, in fact, hasn't). that is, question answers isn't ...

c# - Using .Net Library in Unity5 -

i have huge project written in c# using .net 3.5 need use unity3d project. tried import unity project found out not possible. so, want import code have written in c# unity. created library using code have, import unity , use it. when try import receive following error: unhandled exception: system.typeloadexception: not load type 'speechtools.clsspeechsynthesis' assembly 'myspeechsynthesizer, version=1.0.0.0, culture=neutral, publickeytoken=null'. not load file or assembly 'system.speech, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. i using system.speech in library. not supported in unity (mono). guess problem caused dependency. can me? there way write wrapper around system.speech.speechsynthesizer , use in unity? i searched online , found lot of tutorials on writing wrappers c++ codes nothing c# , .net libraries. system.speech not supported unity's version of mono, you're out of ...

git: How can I merge my working file with the latest one -

i'm new git, , still having lot of trouble. say i'm working on a.cpp . modified code in a.cpp . and, change not ready commit or push. then, other people made change in a.cpp . in svn/cvs, checking out either merge or conflict. i thought git pull same thing. but, seems git pull doesn't merge/conflict. correct behavior? also, git checkout rewrites a.cpp , losing changes. is there easy way pull latest version , perform merge/conflict? before pull, stash changes . after pull, can pop stashed changes , rebase them on newest commit. first stash changes git stash you can view stashes running stash show . if haven't stashed before should see 1 stash. can pull without overwriting changes: git pull now remove changes stash , apply them checked out version: git stash pop

javascript - Do JS event listeners cost more than an additional HTTP request? -

i have heard best condense javascript 1 file reduce number of http requests application makes. however, hold true if make use of event listeners each specific 1 page of site? for example, have 3 different pages make ajax requests load random picture server. first page listens button click, second page listens mouseover, , third page listens change in value of select field. make sense have 1 giant js file contains dom-manipulation logic, event listeners? or better define necessary dom-manipulation logic in 1 file , have 1 small js file each page page-specific event listeners page. tl;dr: event listeners elements not exist on page cost more in performance http requests additional js file? reduction of number of requests 1 reason consolidating javascript files one. the other reason this: javascript file can, after browser has downloaded once, retrieved browser cache when subsequent pages use it. fewer files means more streamlined caching. the cost of little javascript...

email - Using PHP with IMAP to check POP3 "syntax error" -

i trying connect pop3 email account hosted website host. website shared host. email host check emails windows live mail.mysite.com port 110 , works fine. using php , imap have not had luck. did check , host have imap installed. after fought few hours , learned when imap_open fails tries 3 more times fun. started imap_last_error() error checker telling me cannot connect mail: many login failures once figured out happening did not take long figure out how rest of errors , how turn off not retry. now getting syntax error have tried dozens , dozens different variations of hostname. below include 4 people can see of saner things have tried , results. as new missing obvious more experience. open other ways go this. want able use php script open , read emails on particular account. not picky or kind of interface. have been trying imap 1 have found. //$hostname = '{mail.mysite.com:110}inbox'; //array(1) { [0]=> string(49) "[closed] imap connection broken (serve...

How do you setup static paths in javascript? -

this may silly question, can't seem find simple answer via google lets have react component library, full of display component, , want included of smart/container components. because used on place, i'd rather not use relative paths every different component in app import component '../../library/component' , ../library/component , ../../../library/component etc... how set had import component 'library/component' wherever in app wanted be? asked way, prescribed way setup static paths in javascript? with webpack using way of "several root directories". builder find modules several paths. , can write this: "./lodash" instead "../../../../lodash". this more info.

ios - Cutting MPEG-TS file via ffmpegwrapper? -

i have mpeg-ts files on device. cut fairly-exact time off start of files on-device. using ffmpegwrapper base, i'm hoping achieve this. i'm little lost on c api of ffmpeg, however. start? i tried dropping packets prior start pts looking for, broke video stream. packet->pts = av_rescale_q(packet->pts, inputstream.stream->time_base, outputstream.stream->time_base); packet->dts = av_rescale_q(packet->dts, inputstream.stream->time_base, outputstream.stream->time_base); if(startpts == 0){ startpts = packet->pts; } if(packet->pts < cuttimestartpts + startpts){ av_free_packet(packet); continue; } how cut off part of start of input file without destroying video stream? when played back, want 2 cut segments run seamlessly together. ffmpeg -i time.ts -c:v libx264 -c:a copy -ss $cut_point -map 0 -y after.ts ffmpeg -i time.ts -c:v libx264 -c:a copy -to $cut_point -map 0 -y before.ts seems n...

python - How do you fix kivy.graphics DLL issue? -

sigh...here's question python's never ending module issues. have python 3.4 , windows 8. can import kivy fine, if try import kivy.graphics, ran dll issue: file "c:\users\young\anaconda3\lib\site-packages\kivy\graphics\__init__.py", line 89, in <module> kivy.graphics.instructions import callback, canvas, canvasbase, \ importerror: dll load failed: specified module not found. does have clue? i had same error, , fixed re-installing kivy administrator. right-click on cmd.exe , select "run administrator." follow install instructions here .

json - Android/Java - JSONException, java.util.HashMap cannot be converted to JSONObject API < 21 -

i running strange problem on devices running api < 21. i have following jsonobject { "saturday":"{notes=walk-ins only, open=2016-01-16t08:00:00-05:00, close=2016-01-16t15:00:00-05:00}", "wednesday":"{notes=walk-ins only, open=2016-01-20t09:00:00-05:00, close=2016-01-20t18:45:00-05:00}", "tuesday":"{notes=walk-ins only, open=2016-01-19t09:00:00-05:00, close=2016-01-19t18:45:00-05:00}", "friday":"{notes=walk-ins only, open=2016-01-22t09:00:00-05:00, close=2016-01-22t18:45:00-05:00}", "thursday":"{notes=appointments & walk-ins, open=2016-01-21t09:00:00-05:00, close=2016-01-21t18:45:00-05:00}", "monday":"{notes=null, open=null, close=null}", "sunday":"{notes=null, open=null, close=null}" } when attempting jsonobject given day, on devices running api >= 21 use following example code jsonobject.getjsonobject(...

javascript - jQuery notify plugin not working in another JS file -

i using jquery notify plugin. include js files in header. calling $.notify function in js file using ajax, there cannot access $.notify function. my ajax file here including in header also: $.ajax({ url:'index.php?page=ajax_insertdimension.php', type:'post', data:'code='+dcode+'&des='+ddesc, success:function(msg){ $.notify({ title: 'email notification', text: 'you received e-mail boss. should read right now!', image: "<img src='images/mail.png'/>" }, { style: 'metro', classname: 'info', autohide: false, clicktohide: true }); addcols(); } }) sometimes success method work, have specify data type "msg" argument there in parameter success function. can done adding datatype parameter post method specified in documentation here jquery.post() $.ajax({ url:'index.p...

lua - ROBLOX sandboxing -

i new sandboxing in lua, , learn how filter stuff :getchildren() or :kick(). this have far: function safegetchildren(obj) local objs = {} _,v in pairs(obj) if not v.name:match("^^") table.insert(objs, v.name) end end return objs end function safeclearallchildren(obj) if obj:isa("player") or obj:isa("players") or obj:isa("workspace") or obj:isa("serverscriptservice") or obj:isa("lighting") or obj:isa("replicatedstorage") or obj:isa("startergui") return error("cannot clear object!"); else obj:clearallchildren(); end end function saferemoveobject(obj) local name = obj.name:lower(); if obj:isa("player") or name == "remoteevents" or obj.parent == "remoteevents" or obj.parent == "replicatedstorage" or obj.parent == "startergui" or obj.parent == "serverscript...

java - Testing an Android application failed in Eclipse using Appium -

Image
i wanted learn tool test android application. after bit of googling came around wonderful tool called appium used test android application , open source. wanted learn it. went ahead , created simple android application having few button clicks start testing. i have done following: plugged in necessary jar's eclipse ide. downloaded , installed appium server. plugged in maven , testng eclipse . successfullly installed sampleapp.apk emulator . i next created testng class test sampleapp.apk . code pasted below. on running application received java.lang.nullpointerexception . it's been 2 days. tried doing everything, building, cleaning, restarting eclipse, creating new application, re installing dependencies. still receive same exception. had referred video execute automation , have done exact same minus application different in case. package com.example.appium; import java.net.malformedurlexception; import java.net.url; import io.appium.java_client.appiumdr...

twitter - Remove Non-english word from Corpus Using R tm package -

i trying run n-gram on tweets extracted twitter. in case, want remove non-english in corpus while using packages below: my code below: # install , activate packages install.packages("twitter", "rcurl", "rjsonio", "stringr") library(twitter) library(rcurl) library(rjsonio) library(stringr) library("rweka") library("tm") # declare twitter api credentials api_key <- "xxxx" # dev.twitter.com api_secret <- "xxxx" # dev.twitter.com token <- "xxxx" # dev.twitter.com token_secret <- "xxxx" # dev.twitter.com # create twitter connection setup_twitter_oauth(api_key, api_secret, token, token_secret) # run twitter search. format searchtwitter("search terms", n=100, lang="en", geocode="lat,lng", accepts since , until). tweets <- searchtwitter("'chinese' or 'chinese goverment' or 'china goverment' or 'china e...

ios - How can I get the date in 24 hours format -

nsdate *localdate = [nsdate date]; nstimeinterval timezoneoffset = [[nstimezone systemtimezone] secondsfromgmtfordate:localdate]; nsdate *gmtdate = [localdate datebyaddingtimeinterval:-timezoneoffset]; this gives me time in 12 hours format. so, example is 2.15 pm. gives me 2016-01-16 02:15:00 +0000. however, want in 24 hours format 14:15:00. want time. how can that. if need string represents time in format need, try use nsdateformatter setting gmt timezone , desired dateformat ( hh:mm:ss in case) nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"hh:mm:ss"]; [formatter settimezone:[nstimezone timezonewithabbreviation:@"gmt"]]; nslog(@"current time in gmt = %@", [formatter stringfromdate:[nsdate date]]); this print time in format 12:34:56 in gmt timezone for more info on date formats see this fine article

Add search icon on action bar android -

Image
good days guys. i have search icon in action bar image below when clicked, want action bar change edittext , has search icon beside edittext i know how make edittext image, how put edittext on action bar image below ? , want make data display value once edittext has filled value. should use intent ? this i've tried far. activity a getdata(devicename, month); // retrieve data `mysql` , load listview @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.create_menu, menu); return true; } @override public boolean onprepareoptionsmenu(menu menu) { msearchaction = menu.finditem(r.id.search); return super.onprepareoptionsmenu(menu); } @override public boolean onoptionsitemselected(menuitem item) { ...

joomla1.5 - Joomla 1.5.23: Sitewide Component - runs on all instances -

i have project need able show html item on page depending on domain is. what want able call component site wide (front end) hooking in on every page load. sounds little complicated need run essentially have 2 domains both linking same install of joomla. when user visits domain x don't want see particular on lay, when user visits domain y want component kick in, put in html , insert parameter url. just test server name against juri::base(false) , set new var jrequest::setvar('newparam','newvalue'); need var? may not available depending on set it: i.e. if set in module won't available component

javascript - document.getElementById("id") in onchange parameter -

i working on erp program needto write data to , from database. here send data input field, therefore call specific javascript function on onchange event. add value of element onchange parameter onchange="myfunction(document.getelementbyid("myid"))" i tried not work: onchange="myfunction(document.getelementbyid(\"myid\"))" how do this? use onchange="myfunction(document.getelementbyid('myid'))"

User roles with devise Modular Rails 4 -

i've been struggling issue weeks. goal create 3 different types of users. regular, page , venue. upon registration user able select role [regular,page or venue]. depending on role user chooses they're redirected edit profile page have fill in additional information. depending on user role, user provided specific layout , separate root. example : user chooses role via registration form once signed user redirected edit form fill in additional info name, location. ( trying find way make required, before user can interact platform have fill in additional information not required on registration form. ideas on amazing.) so root user role specific view. also application being built within engines, using modular wa what have : by following tutorial able set user roles simply. , wrapping head around using cancan. http://www.mashpy.me/rails/role-based-registration-with-devise-and-cancan-using-ruby-on-rails/ . user.rb module m0ve class user < activerecord::base #...

javascript - How can I modify my directive's templateURL based on values within its controller? -

i have following angularjs directive , controller. instead of entering html right directive's template field, set templateurl based on values of integers ab , ac in associated controller. if ab + ac >= 10 , want use foo.html otherwise want use bar.html . how can that? myapp.directive('mydirective',function(){ return { restrict:'e', scope: { myobject: '=' }, controller: 'mydirectivectrl', controlleras: 'mydrctrl', bindtocontroller: true, template: 'ab={{mydrctrl.myobject.ab}} ac={{mydrctrl.myobject.ac}}' }; } ); myapp.controller('mydirectivectrl', function($scope){ var self = this; $scope.$watch(function() {return self.myobject}, function (objval) { console.log("watch fired"); console.log('objval.ab = ', objval.ab); console.log('objval.ac = ', objval.ac); },true); }); you use ng...

Liferay: how to delete uploaded files in liferay document library folder programmatically? -

i need help. know how clear uploaded files data/document_library folder. example develop foto upload portlet. , when user upload new foto, previous should deleted. here example of abs example image url. http://localhost:8080/image/journal/article?img_id=30634 how can programatically remove files mapped such urls? update after analyzing liferay database tables (image , etc.) have come desicion: if (stringutils.isnotempty(portraiturl)) { pattern pattern = pattern.compile("([0-9]+)$"); matcher matcher = pattern.matcher(portraiturl); if (matcher.find()) { imagelocalserviceutil.deleteimage(long.valueof(matcher.group(0))); } } regex search image id in portrait url http://localhost:8080/image/journal/article?img_id=30634

java - Strategies to change Logback appender level at production -

i package applications jars , wars. after deployment in production, see on logs if ok, , once is, decrease level of these logs @ runtime, without deploying new jar/war again. what strategies available logback? found put logback configuration outside jar/war, change level anytime without deploying again. problem create new arguments application, avoid this, want keep simple. is there better way accomplish same? from experience, there no cleaner way providing external logback.xml . other options include using jmx adjust logger level or implementing endpoint change logger configuration programmatically.

javascript - How to create a callback priority queue with the help of jQuery? -

when doing $(element).on('customevent',function(){}); , every element binds customevent trigger. works pub/sub, , appears there no order or priority. want is, implement own callback queue, but, ajustable priority (like wordpress has, can set hooks priorities). higher number have bigger priority, , number 0 common , executed last. given example $(element).on_priority(10, 'customevent', function(){}); , $(element).on_priority(0, 'customevent', function(){}); , 10 priority execute same customevent first, , might or not cancel execution of 0 priority event. how can implement that? i'm having trouble trying visualize flow of callbacks so far, thought this: keep "global" (inside closure) object callback names set. inside each member of callback, object containing priorities. var callbacks = { 'customevent': {}, 'customevent2': { 0: [{element: $element, fn: function(), data:{}}, {element: $element, fn: functi...

how can I create a debian package to distribute python modules without using distutils? -

i'm getting myself thoroughly confused how correctly package python3 based application . my application uses makefile install stuff correct file locations e.g. /usr/lib/rhythmbox/plugins/foo/myfoo.plugin /usr/lib/rhythmbox/plugins/foo/myfoo/po/translation.mo /usr/lib/rhythmbox/plugins/foo/myfoo_module.py /usr/lib/rhythmbox/plugins/foo/myfoo_module2.py i'm not using python distutils setup.py type installation - straightforward sudo make install based method. when try debian package rules straightforward: #!/usr/bin/make -f %: dh $@ --parallel --with autoreconf,python3 override_dh_autoreconf: dh_autoreconf -- ./autogen.sh override_dh_auto_configure: dh_auto_configure -- --libdir="\$${exec_prefix}/lib" my debian/control file "build-depends" again straightword: build-depends: debhelper (>= 9), dh-autoreconf, dh-python (>= 1.20130903), gir1.2-glib-2.0, gir1.2-gst...

java - Android: Reporting drop result: false -

i wanted programm drag , drop button wich can move want. tryed ondrag(), if want drop button message: " reporting drop result: false " dont know why. other problem shadowbuilder disappear if drop button. want convert shadow normal button if drop it. i'll grateful, if me. @override public boolean onlongclick(view v) { clipdata clipdata = clipdata.newplaintext("", ""); view parent = (view) v.getparent(); parent.setvisibility(view.invisible); view.dragshadowbuilder shadowbuilder = new view.dragshadowbuilder((view) v.getparent()); v.startdrag(clipdata, shadowbuilder,parent, 0); return true; } @override public boolean ondrag(view v, dragevent event) { int dragaction = event.getaction(); if (dragaction == dragevent.action_drag_started) { if (event.getclipdescription().hasmimetype(clipdescription.mimetype_text_plain)) { //returns true, when view can view of onlongclick log.e(...

sql server - Is it possible to use autoscaler for google SQL as it is possible for compute engine -

let me explain problem. have magento project 3 million products , more 6 million urls. problem ist database because of products. autoscale google cloud sql database. respond adequate. know possible google compute engine , includes database. possible google or cloud sql provider? you cannot scale databases same way autoscaler doing compute engine managed instances. autoscaling capabilities of compute engine works stateless vms. databases stateful . can use read replications scale cloud sql. read replica instances allow data master instance replicated 1 or more slaves. setup can provide increased read throughput. visit this artcile different read replica scenarios.

bash - Convert string in variable lower case -

this question has answer here: converting string lower case in bash 17 answers using bash version 3.2.57(1)-release (x86_64-apple-darwin14) how can 're-assign' or 'change' existing value read variable. if user inputs string iamstring , i'd propinput store value iamstring . i'm printing console example sake. read userinput echo ${userinput} | tr '[:upper:]' '[:lower:]' you should store output of echo : read userinput userinput=$(echo "$userinput" | tr '[:upper:]' '[:lower:]')

javascript - addEventListener firing automatically within loop - or only last element works -

i have loop, , creating button within each iteration. attaching event listener each newly created button, , need pass unique parameters through. please see code below (in case, passing index loop through event listener) for (i = 0; <= worklog.worklogs.length; i++) { if (worklog.total > 0) { var thebutton = document.createelement("button"); thebutton.addeventlistener("click", alertbutton(i)); thebutton.innerhtml = "add"; myspan.appendchild(thebutton); } } function alertbutton(arg) { return function () { alert(arg); }; } currently, event listener fires on button implemented on last iteration. if remove "return function(){}" within alertbutton function, event listener fired on each iteration without user clicking on button. if have ideas extremely appreciative. finding other people have had problem, yet solutions provided don't seem work me. overlooking simple. thanks! ...

r - Inclusion/Exclusion of rows in a DataFrame, based on specific criteria -

i have large set of data contains pathology test data number of individuals. present scaled down data set describing types of cases. library(plyr) library(tidyr) library(dplyr) library(lubridate) options(stringsasfactors = false) dat <- structure(list(persid = c("am1", "am2", "am2", "am3", "am3", "am4", "am4", "am4", "am4", "am4", "am4"), sex = c("m", "f","f", "m", "m", "f", "f", "f", "f", "f", "f"), datetested = c("21/10/2015", "9/07/2010", "24/09/2010", "23/10/2013", "25/10/2013", "28/04/2010", "23/06/2010", "21/07/2010", "20/10/2010", "4/03/2011", "2/12/2011"), res = c("nr", "r", "r", "nr", "r", ...

java - CompletableFuture.acceptEither -

i experimenting completablefuture api jdk8, trying out accepteither() method it. please have @ code below (and put forth concern): public class accepteither { public static void main(string[] args) { completablefuture<double> completablefuture2 = completablefuture.supplyasync(tasksupplier::getsomearbitrarydouble); completablefuture<double> completablefuture3 = completablefuture.supplyasync(tasksupplier::getanotherarbitrarydouble); completablefuture<void>completablefutureforacpteither = completablefuture2.accepteither(completablefuture3, (val)-> { system.out.println("val: "+val); }); /*while(true){ if(completablefutureforacpteither.isdone()) break; system.out.println("task did not complete"); } system.out.println("task completed");*/ system.out.println(...

android - how to create correct -journal file after editing sqlite database -

i have .db file , want edit using sqlite editor or other applications ready editing databases.... inserting new row in tables successful , there no problem, ....but after inserting, -journal file attached databases removed.... know -journal roll database... don't know how should edit database creating -journal file correctly?!!... also inserting new row in tables in .db file cannot successful , after exiting application removed... it's problem -journal file or not??...thanks! the -journal file automatically handled database. don't need care it. it might deleted or not depending on some connection setting , merely optimization.