Posts

Showing posts from May, 2012

python function project, histo function that return o -

histogram(xs): given list of integers named xs, return string which, when printed, shows histogram corresponding integers. use small "o" display symbol. assume: xs list of non-negative integers; xs empty. restrictions: none stated. histogram([3,10,0,5]) → 'ooo\noooooooooo\n\nooooo' histogram([]) → '' this tried: def histogram(xs): last = len(xs) histo = '' number in xs: while number > 0: histo += 'o' number -= 1 last -= 1 if last == 0: if histo == none: return '' return histo histo += '\n' i may have had indentation wrong when edited question. had guess because pulling out of comment. also, might have had indentation problem. anyways, seems work (it's original code proper indentation): def histogram(xs): last = len(xs) histo = '' number in x

android - Fragment findviewbyid not working correctly -

i have tablet layout , phone layout , need tablet detect whether view exists determine whether execute tablet code or phone code. this code in activity fragment attached returns true, same code in fragment returns false. mtwopane = view.findviewbyid(r.id.detail_container) != null; what happening causing this? i've tried several things such mtwopane = getactivity().getrootview().findviewbyid(r.id.detail_container) != null; no luck. my activity_main.xml phone: <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/mainfragment" android:name="com.project.mainfragment" tools:context="com.project.mainfragment"/> my activity_main tablet: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"

ruby - nested namespace on form_for helper method - Rails -

hello guys have 2 namespaces, 1 nested inside of form admin (namespace) inside admin have blog (namespace) i know can put namespace below in form-for helper. <%= form_for [:blog, @post] |f| %> <%= render 'shared/error_messages', object: f.object %> <div class="large-12 columns"> <div class="field panel"> <%= f.label :title %><br> <%= f.text_field :title %> </div> <div class="field panel"> <%= f.label :body %><br> <%= f.text_field :body %> </div> <div class="actions"> <%= f.submit %> <%= link_to 'back', admin_blog_posts_path %> </div> </div> <% end %> but how can prefix :admin namespace in front of that? found it. for future reference you add comma depending on order of namespaces in case above <%= form_for [:admin,:blo

Java For Loop with Array in columns -

this question has answer here: how print columns in java txt file 4 answers i want make code output loops columns not straight , down in 1 column, each int in each of 3 loops make column starting left right. import java.util.scanner; public class project4 { public static void main(string [] args) { final int number_months = 12; int [] avgtemp = {46, 48, 49, 50, 51, 53, 54, 55, 56, 55, 51, 47}; int [] avgrain = {5, 3, 3, 1, 1, 0, 0, 0, 0, 1, 3, 4}; int [] newgrowth; newgrowth = new int[number_months]; scanner scan = new scanner(system.in); system.out.print("enter minimum temperature plant : "); int min_plant_temp = scan.nextint(); system.out.print("enter maximum temperature plant : "); int max_plant_temp = scan.nextint(); system.out.print("enter

bash - Copy binary file on Linux -

i have restricted environment, chrooted environment or vm, has following basic utilities available: bash, hostname, ls, mkdir, ping, rm, getent, id. /proc filesystem available. all others utilities cp/cat unavailable, . possible copy file these utilities ? to copy inputfile outputfile using bash : echo "$(<inputfile)" >outputfile (limitation: nuls , trailing newlines omitted.)

php - mysql check row for same values and add together -

table structure image score breakdown i have table of golf scores called scores. column headings golfer, golf_course, h1, h2, h3 , on h18. have form adds scores in each column on basis of 0 = no score, 1 = bogey, 2 = par, 3 = birdie, 4 = eagle. trying achieve statement can return number of no scores, bogeys, pars, birdies or eagles each row. grateful for. thanks subin c poonamgode, you got me on right track. tweaked solution make following code work select `golfer`,`course_name`, (case 0 when `h1` 1 else 0 end +case 0 when `h2` 1 else 0 end +case 0 when `h3` 1 else 0 end +case 0 when `h4` 1 else 0 end +case 0 when `h5` 1 else 0 end +case 0 when `h6` 1 else 0 end +case 0 when `h7` 1 else 0 end +case 0 when `h8` 1 else 0 end +case 0 when `h9` 1 else 0 end +case 0 when `h10` 1 else 0 end +case 0 when `h11` 1 else 0 end +case 0 when `h12` 1 else 0 end +case 0 when `h13` 1 else 0 end +case 0 when `h14` 1 else 0 end +case 0 when `h15` 1 else 0 end +case 0 when `h16` 1 el

Mesos cluster port opening -

i want run mesos cluster on google cloud / aws. common practice allow instances within cluster communicate each others freely without restriction (white-list firewall instance), or should allow them communicate via specific ports. got quite number of running services , it's hard know port need open. thanks. a practice have private , public security zone (in aws/ec2 translate security group, in gcp/gce network policies). within private zone nodes communicate freely , public 1 pretty locked down besides ones need. have @ dcos architecture further details. the second part of question relates list of well-known ports. we're working on putting such list , publish it, soon.

c - if else statement not giving expected answer -

the values entered not matching output grade giving 10 grade when conditions 10 not met. issue on entering hardness 50 strength 5600 , carbon 0.7 giving grade 10 while grade 10 carbon should less 0.7? #include #include #include int main() { // program grade steel on quality basis int hardness; int strength; float carbon; printf("enter hardness of steel:"); // condition 1 hardness should >= 50 scanf("%d", &hardness); printf("enter tensile strength:"); // condition 2 strength should >= 5600 scanf("%d", &strength); printf("enter carbon content:"); // condition 3 carbon less 0.7 scanf("%.2f", &carbon); if ((hardness >= 50) && (carbon < 0.7) && (strength >= 5600)) { // true printf("\ngrade = 10"); } else if ((hardness >= 50) && (carbon < 0.7) &&

javascript - Allow a child iframe (cross site) access to window.top -

i trying display web site in iframe. iframe url points internally hosted web server in corporation, although have no control on whatsoever , 'cross site' has different subdomain site. further, code maintained 3rd party company , takes long time changes this... banks , like! creators of content have stated there no intention prevent displaying/running web site in iframe. we using cisco finesse "bring together" various 3rd party , locally developed web applications. (background, finesse uses apache shindig host 'gadgets'). @ technical level, want have single url gadget displayed in finesse, uses iframe display 3rd party page. the problem far, there piece of code on 3rd party page tries access "window.top.location" , of course security exception thrown. here code: function somefunc() { var toppage = window.top; if (toppage.location.pathname.indexof("default") == -1) { return toppage; } return toppage; } the p

php - Develop a third-party bundle (or library) in local -

i want develop public , third-party bundle symfony. test bundle during development, need functional symfony installation. need mimic composer installation of bundle in symfony test application. the problem is, best way achieve ? wonderful if composer let define local repository, , without need commit on package side composer update on symfony app side each time want test bundle . solution i'm explaining here explained here : http://tech.vg.no/2014/11/25/using-local-packages-as-composer-dependencies/ this best solution have found , don't see lot of literature that. call "symfony 3rd-party bundles developers": how develop , test bundles during development? just clarify comment app/autoload.php, symfony 2 gives little hook allow customizing autoload process: // app/autoload.php $loader = require __dir__.'/../vendor/autoload.php'; $loader->add('cerad', __dir__ . '/../../cerad2/src'); annotationregistry::registerloader(arra

ios - How do I get a fail case to pass in Xcode UITests with swift? -

context: starting automation. unfortunately, practice app has changing ui. e.g., have buttons hidden users, , shown others depending on access permission levels. goal: want test when fail pass; buttons indeed absent when should be. have overlays , stuff contend too, think can extrapolate button example once i'm shown how it. before section, login tests have passed. person cannot see sometimeshiddenbutton, need pass fact can't find button, not fail it. how tell that? there special kind of assert can use, or conditionals, or what? let tablesquery = app.tables app.navigationbars["landingscreen"].buttons["hamburger"].tap() tablesquery.statictexts["alwaysshownbutton"].tap() app.navigationbars["alwaysaccessiblescreen"].buttons["hamburger"].tap() tablesquery.statictexts["sometimeshiddenbutton"].statictexts.tap() <-fails you can check .exists value. if !tablesquery.statictexts["sometimeshidden

google play - Android app cannot update from market, after shareduserid added -

i added shareduserid apps, when trying update app google play store -504 error.device log below. manifest file correct , when install android studio or adb there no problem can not update market. ideas? copying /data/data/io.crash.air/files/com.xxx.xxx_36fcadf21b0a4ef18ff35b90608b3b1c.apk base.apk d/packagemanager( 645): renaming /data/app/vmdl1037256928.tmp /data/app/com.xxx.xxx-2 i/activitymanager( 645): force stopping com.xxx.xxx appid=10271 user=-1: uninstall pkg i/packagemanager( 645): package com.xxx.xxx codepath changed /data/app/com.xxx.xxx-1 /data/app/com.xxx.xxx-2; retaining data , using new w/packagemanager( 645): package com.xxx.xxx shared user changed <nothing> com.yyy.yyy; replacing new w/packagemanager( 645): package couldn't installed in /data/app/com.xxx.xxx-2 w/packageparser( 645): unknown element under <application>: intent-filter @ /data/app/com.xxx.xxx-1/base.apk binary xml file line #334 d/activitymanager( 645): gettaskthumbnaillocked

CSS alignment on different browsers -

don't use css might simple solution. i'm trying align dynamic date value on jpg certificate in lower righthand corner. aligned on fixed image line. alignment looks great in safari browser, shifts right on chrome , firefox , shifts far left in internet explorer. example fiddle: http://jsfiddle.net/jeffbarclay/evu1y9ao/ .certdate { font-size:14pt; font-family:trebuchet ms; font-weight:normal; position: absolute; top: 480px; left: 780px; } use right , bottom instead of left , top. .certdate { font-size: 14pt; font-family: trebuchet ms; font-weight: normal; position: absolute; bottom: 0; right: 0; } make sure container has proper height , width , position relative.

android - how to change color of circle according to percentage -

Image
i want show percentage of humidity in circle.and change color of circle dynamically accroding percentage of humidity. had created following layout.created 2 drawable 2 different color also. <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/registration_bg" > <relativelayout android:id="@+id/image_layout" android:layout_width="@dimen/circleheight" android:layout_height="@dimen/circleheight" android:background="@drawable/circle1" android:layout_below="@+id/linearlayout" android:layout_centerinparent="true" > <button android:id="@+id/image_level" android:layout_width="@dimen/circleheight" android:layout_

javascript - toggle with hasClass -

i trying use hasclass on toggle , cant find example want. basically, button toggles class , forth. here code: $("#sidebar-toggle-btn").click(function() { $("#sidebar").toggle(); if($('#mapdiv').hasclass('col-lg-6')) { $('#mapdiv').removeclass('col-lg-6'); $('#mapdiv').addclass('col-lg-8'); }; if($('#mapdiv').hasclass('col-lg-8')) { $('#mapdiv').removeclass('col-lg-8'); $('#mapdiv').addclass('col-lg-6'); }); example: http://jsfiddle.net/monduiz/dzo5yg72/ hsz , tushar offered right suggestions. reason wasn't working because idiot. trying apply toggle wrong button in interface. works: $("#projects-btn").click(function() { $('#sidebar').toggle(); $("#mapdiv").toggleclass('col-lg-6 col-lg-8'); }); just try .toggleclass('col-lg-6 col-lg-8') : $("#sidebar-toggle-btn").c

css - Transform rotate not working in Quirks mode -

i'm working on website quirks mode , can't use <!doctype html> . in project css3 translate image doesn't work in ie10 , 11 work in ie9 reasons mentioned above. there solution problem except add <!doctype html> ? just clear: whole point of quirks mode emulate way ie5 worked. this includes disabling of html, css , javascript features have been added browser since then. if in quirks mode not have features. there no work around or solution this; how is, , that's how quirks mode intended work. if have use quirks mode have accept browser's capabilities 1990's. your options work out how upgrade software can use in more modern browser environment, or else ditch idea of using modern css , use whatever techniques available in '90s. custom activex control or flash animation. pretty ugly, whichever option go for. i add obvious point need start thinking how you're going upgrade away quirks mode. default browser (edge) comes window

Summarize observations in r -

this question has answer here: group multiple columns , sum other multiple columns 6 answers i have been working on following csv file http://www3.amherst.edu/~nhorton/r2/datasets/batting.csv own practice. i not sure of how following: summarize observations same team (teamid) in same year adding component values. is, should end 1 record per team per year, , record should have year, team name, total runs, total hits, total x2b ,…. total hbp . here code have far giving me 1 team per year yet need teams each year totals (e.g, 1980, need teams totalruns,totalhits,.....,for 1981, teams totalruns,totalhits,.... , on) newdat1 <- read.csv("http://www3.amherst.edu/~nhorton/r2/datasets/batting.csv") id <- split(1:nrow(newdata1), newdata1$yearid) a2 <- data.frame(yearid=sapply(id, function(i) newdata1$yearid[i[1]]), teamid=sapply(id,function

frameworks - is there a practical and simple guide to install symfony on a localhost? -

i'm supposed edit existing web application built using symfony framework. have learn use symfony framework. i'm having trouble installing framework. download button in symfony.com/download/ seems broken. when click it, doesn't download anything. it's not because javascript turned off or because can still download other things. i ended downloading file softpedia , i'm not sure if it's right file because contents different tutorial video found on youtube. can point me correct (and working) installation file? p.s.: 1. have never used nor installed php framework. i've developed websites using flat php , wordpress 2. don't have access command prompt because office admin isn't allowed give staff administrator privileges thank you direct download of symfony2 framework if haven't access command prompt directly download symfony 2.7 package from: http://get.symfony.com/symfony_standard_vendors_2.7.0.zip in case best way move first

imagebutton - Trying to measure touch duration in android -

is there way measure touch duration of immagebutton in android? i'm building app needs use data i've found ensuring minimal duration you should use setontouchlistener here go button.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { if(event.getaction() == motionevent.action_down){ //start calculate time here starttime = system.currenttimemillis(); } if(event.getaction() == motionevent.action_up){ estimatedtime = system.currenttimemillis() - starttime; } return true; } });

Will lastest websphere liberty full platform run oracle java 8? -

i looking @ latest websphere liberty 8.5.5.7 full platform ( https://developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse-environments/ ) , wonder if can run oracle java 8? see on download page ibms java 8 supports web profile don't care if run jdk oracle or ibm long version 8. historically websphere has demanded ibms jdk on linux , solaris. i have search ibms site not found answer. yes support running liberty on non-ibm jvms, including oracle. downloads ibm come bundled java 8 can use more web profile (you can use installutility download , install full java ee 7 platform onto web profile install).

C++: Memory Leak;Vector-like class -

im beginnger in c++ , try creat container class similar vector. class should works vector type of data , used in range-based loop. wrote hpp tutor says there memory leak ,i think deleted dynamic memory,where problem? #include "stdafx.h" using namespace std; template<class t> class customvector { public: customvector(); ~customvector(); int size(); int free_capacity(); void add(t& temp); int& operator[](int index); void grow(); class iterator { public: iterator(t* ptr) : ptr(ptr) {} iterator operator++() { iterator i(ptr); ++ptr; return i; } bool operator!=(const iterator & other) { return ptr != other.ptr; } const t& operator*() const { return *ptr; } private: t* ptr; }; iterator begin() const { return iterator(&_elements[0]); } iterator end() const { return iterator(&_elements[0]+_size); } private: t* _element

c# - Conflicts between different versions of the same dependent assembly that could not be resolved -

it seems solution using 2 different versions of system.web.mvc. question how resolve uses same version? error 2 assembly 'sportsstore.webui, version=1.0.0.0, culture=neutral, publickeytoken=null' uses 'system.web.mvc, version=5.2.2.0, culture=neutral, publickeytoken=31bf3856ad364e35' has higher version referenced assembly 'system.web.mvc, version=5.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' try adding in web.config (make sure not on write existing sections) <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" /> <bindingredirect oldversion="1.0.0.0-5.2.2.0" newversion="5.2.2.0" /> </dependentassembly> </assemblybinding> </runtime>

How to check out code from old version with Google docs add-on script -

Image
i made add-on worked on 05/21. at point between , broke. the old code no longer in revision history goes 05/22. i have tested version 1 , , works, means it's using right code. i can run working version, don't know how can re-open code it. how view code version 1 of add-on? edit from @bryanp's comment, i've been informed there existing request here . it's bit round houses, could: create test project include older version of library use debugger step older version of code , copy , paste somewhere safe. i use technique poke around in libraries i'm using.

java - Is an Exception's stack trace reliable to get calling method name? -

i know stacktraces can used retrieve current executing method this: thread.currentthread().getstacktrace()[what want] however not every jvm provides stack trace way of getting method's name pretty unreliable. anyway...what exceptions? need log caller method name and, in order provide code maintenance, i'd avoid write name down this: public void mymethod(){ ... }catch(anexception ex){ log.error("mymethod failed!"); } but rather like: }catch(anexception ex){ log.error("{} failed!", ex.getstacktrace()[0].getmethodname()); //0 should method, caller } is reliable? think that, @ least exceptions, jvm should expected provide said stack trace...

git - How to compare a range of revisions using TortoiseGit? -

is possible compare changes across multiple revisions using tortoisegit or tool? i have used tortoisesvn many years now. in log window, select multiple revisions. give me of files changed across revisions. @ file level, see of differences in file across of revisions. select 2 revisions want compare , select "compare revisions" on revision list context menu.

c# - Thread management when populating a cache in a .NET web app -

i have .net mvc web app data reporting. when app first loads, requests lot of data remote servers caches locally in web server memory. before cache loads, there's no way respond incoming requests. every request comes in while cache loading must wait thread loading cache. if use critical section ( lock ) on caching code, requests block. that's huge waste of resources , exhaust iis worker thread pool. if use async requests, web requests return before cache loaded. can't "callback" web request has returned contents client! how can manage threads properly? maybe there way move requests single thread asynchronously waits cache load , move them out individual threads once cache loaded? if use critical section (lock) on caching code, requests block. that true. can use semaphoreslim.waitasync asynchronously wait. behaves lock. want solution case many requests queue (like 1000s). can use second semaphore max count of 1000 , wait timeout of

css - How to loop property values in sass? -

this question has answer here: writing sass mixin 3d text depth 1 answer i've seen implementations of in classes. have text-shadow adds 1px y-coordinate each declaration. want refactor increments while other values stay same. here's code: text-shadow: 0px 1px #00b760, 0px 2px #00b760, 0px 3px #00b760, 0px 4px #00b760, 0px 5px #00b760, 0px 6px #00b760, 0px 7px #00b760, 0px 8px #00b760, 0px 9px #00b760, 0px 10px #00b760, 0px 11px #00b760, 0px 12px #00b760, 0px 13px #00b760, 0px 14px #00b760, 0px 15px #00b760, 0px 16px #00b760, 0px 17px #00b760, 0px 18px #00b760, 0px 19px #00b760, 0px 20px #00b760, 0px 21px #00b760, 0px 22px #00b760, 0px 23px #00b760, 0px 24px #00b760, 0px 25px #00b760, 0px 26px #00b760, 0px 27px #00b760, 0px 28px #00b760, 0px 29px #00b760, 0px 30px #00b760, 0px 31px #00b760, 0px 32px #00b760, 0px 33px #00b760, 0px 34px #00b760, 0px 35px #00b

rails ActiveRecord join tables cascading belongs_to -

given following simple associations, , selected_company, query correctly written documents in selected company ? class document < activerecord::base belongs_to :user end class user < activerecord::base belongs_to :company has_many :documents end class company < activerecord::base has_many :users end === query selected_company: company.first documents_in_selected_company = document.joins(:user).joins(:user => :company).where(:company_id => selected_company[:id) thanks feedback just 2 small fixes , association names should lowercase ... , should contains query string : documents_in_selected_company = document.joins(:user).joins(:user => :company).where("companies.id = ?", company.id)

css - Is there a way to have a smooth animation always happening on hover with translate3d? -

i have css layout right-side menu (in green). the main part of menu default hidden outside viewport. on mouse on over right side menu: after short delay, menu translates viewport (after little delay). on mouse out on right side menu: menu should translate initial position (no delay). see green menu on jsfiddle : try hover green menu here relevant css code: section#base-layer section#base-layer-contact-bar { position: absolute; box-sizing: border-box; top: 60px; right: -90px; width: 150px; height: calc(100% - 60px); transform: translate3d(0, 0, 0); transition: transform 0.6s ease-in; background-color: green; } section#base-layer section#base-layer-contact-bar:hover { transform: translate3d(-90px, 0, 0); transition-delay: 1s; } to reproduce : move mouse out of green colored section while animation in initial state, meaning before reaches full extension. is there way have smooth animation happening? is there problem css? i

Android NDK, Error:(165, 0) Cause: ndk-build binary cannot be found -

i'm trying run react-native reactandroid project androidstudio. ndk error. error:(165, 0) cause: ndk-build binary cannot found, check if you've set $android_ndk environment variable correctly or if ndk.dir setup in local.properties i have downloaded android ndk here http://developer.android.com/intl/pt-br/ndk/downloads/index.html echo $android_ndk gives /users/lu/dev/android/android-ndk-r10e inside local.properties have: ndk.dir=/users/username/dev/android/android-ndk-r10e i'm using android studio 1.4 i got same error when running ui explorer app react native on android. if on mac here worked me: $ brew install android-ndk $ echo 'export android_ndk_home=/usr/local/opt/android-ndk' >> ~/.bash_profile restart terminal make sure have emulator running then: cd react-native ./gradlew :examples:uiexplorer:android:app:installdebug ./packager/packager.sh the initial build take sometime

regex - Uncomment a block of text with awk or sed -

assuming have text file example: lorem ipsum dolor sit amet, nullam euismod tractatos id mel, has integre ornatus feugait ad. in eum enim putent fierent. quo melius persecuti conceptam eu, ne probo autem inciderint quo, ius et atqui diceret. causae prompta corpora ex ius. atqui aperiri in duo, ex pro reque utinam. sea ne prima falli petentium. ut has ancillae omnesque lucilius, vim ex alia audire contentiones. error possit singulis @ his. ne purto soleat ius, detracto sententiae mel ne. te eos regione detracto, eam quas accumsan detracto an. # lorem ipsum dolor sit amet, nullam euismod tractatos id mel, has integre ornatus # feugait ad. in eum enim putent fierent. quo melius persecuti conceptam eu, ne probo # autem inciderint quo, ius et atqui diceret. causae prompta corpora ex ius. atqui # aperiri in duo, ex pro reque utinam. # comment # @ debet expetenda sed, sed te case ceteros adolescens. ad sea facer minim tempor, # eam facilisi definitiones ei, vix

angularjs - How to load returned html after $http.post -

sorry if has been asked already, can't find answer! i'm posting form data using angular, , expecting backend return html page. how load page? $http.post(generate_practice_exam_url, data).then( function(data){ # data contains html of page i'd load/redirect # $window.loadashtml(data); <-- want } ); clarification: know can return url server , pull $location.path(data.data) . want return html of next page, , load immediately, avoid making request $location . actually should use server data storage. should return json , should use angular directives show data. if need html server , show should create directive that. there "link" function can access html element , insert html like directive('mydirective', function($http){ return { link:function(scope, elem){ $http.get('your url').then(function(htmlresponse){elem.html(htmlresponse)}); } }; });

sas iml - Making SAS handle very small numbers without rounding -

i have range of large (4- or 5-digit) numbers, need raise -1 power. because numbers large, going small when raised power. when in sas (using elementwise operator), numbers in output rounded(?) -1. nothing lot of minus ones output. is indeed result of rounding? can around formatting output in way? if so, syntax this? again, sorry asking such simple things, i'm utterly new sas. code: proc iml; use sasdata.have; read var {distance} d; print d; dmin = -1##d; print dmin; quit; your problem you're raising -1 power of 5000 (or whatever), opposed opposite. proc iml; use work.have; read var {distance} d; print d; dmin = d##-1; print dmin; quit;

linux - Switch forever logs without stopping forever service -

we using forever in our production environment , when trying rotate logs forever process killed though i'm using copytruncate. now, can bypass restarting forever service in postrotate scripts, wanted know whether there command change forever log file. - forever restart -l new_log.log app.js is there way this? or stopping , starting forever process absolute neccesity? thanks bunch. yes, stopping , restarting necessary. i'd recommend using pm2 instead. offers same forever , much more. it's lot easier use. , has log-rotate plugin automatically takes care of log rotation, hassle-free , configured want.

python - how to implement a multi-tenant configuration solution in ansible -

one common pattern i've seen in many applications multitenancy . basically, i'm configuring application has of configuration values different based on country. way i've managed configuration using "partners" dictionary in yaml: --- partners: us: url: 'http://company.com' uk: url: 'http://company.co.uk' fr: url: 'https://company.fr' ch: url: 'https://company.fr' and thus, when serving customers identified come 'us' we'll use 1 value url different if application identifies coming 'fr'. then, when configuring template, similar to: template: xxxx with_items: partners_list then, in template use partners[item].url access variable. thus, 1 template, i'm configuring multiple files different values according partner. bear account of values common though (most configurations not in partners dict). this less satisfactory. what have "dynamic var

java - download file instead of opening in browser using struts2 -

i have written file upload , download in struts2. while download text.pdf file opened in browser page, how download files instead of open in browsers page? <div class="block-fluid table-sorting clearfix"> <table cellpadding="0" cellspacing="0" width="100%" class="table" id="tsortable"> <thead> <tr> <th>s. no</th> <th>account no</th> <th>file </th> <th>action</th> </tr> </thead> <tbody> <s:iterator value="fileuploadlist" status="rowstatus" > <tr> <td><s:property value="#rowstatus.index+1" /></td> <td><s:property value="fileupload_temp2" /></t

Recognizing latest version for Upgraded Susy 2.2.3 to 2.2.6 -

i have manually upgraded susy 2.2.3 2.2.6 . can delete older version or automatically uses latest version. have ruby compass sass , susy brianran sass should automatically use latest version, can delete old one. gem cleanup susy you, assuming susy installed ruby gem.

ios - Disable ASL/NSLog at runtime -

it's easy "disable" nslog @ compile time replacing macro, etc. can nslog (or asl in general) disabled at runtime ? my goal silence logs not have control over. look @ lumberjack framework . there can set logging level required. hide log statements when release app, change logging level debug info using #ifdef release , #ifdef debug macros. update: in case log statements coming different framework linking, can use method swizzling swap implementation of nslog custom method.

java - hibernate h2 not generating relations -

i'm trying generate hibernate mapping h2 database. have 2 tables test, called users , users_groups. like: users table: user_id integer pk login varchar password varchar user_group_id integer fk users_groups user_group_id integer pk name varchar and problem hibernate generate entities that: @entity public class users { private int userid; private int usergroupid; @id @column(name = "user_id", nullable = false) public int getuserid() { return userid; } public void setuserid(int userid) { this.userid = userid; } @basic @column(name = "user_group_id", nullable = false) public int getusergroupid() { return usergroupid; } public void setusergroupid(int usergroupid) { this.usergroupid = usergroupid; } @entity @table(name = "users_groups", schema = "public", catalog = "database") public class usersgroups { private int use

ios - Xcode 6.2 on El capitane - Storyboard compiler error: Exception while running ibtool -

i have project build in swift 1 , thats why still using xcode 6.2 . (i cannot migrate, because there code, , after still tried fix errors, app started crashing). everything worked fine, until upgraded os x el capitane . can't compile app anymore. throws error: interface builder storyboard compiler error /users/.../main.storyboard: exception while running ibtool: -[ibuiviewcontrollerautolayoutguide shouldbearchived]: unrecognized selector sent instance 0x7ffb1609f520 i aware of xcode 6.x issues on el capitane really need working. i tried found issues xcode 6.x , os x el capitan. looks you've stick prior version of os x make work. previous versions of xcode 6.1.x , 6.2.x not compatible elcapitan.

Windows Registry: What does @="Outlook64Bridge" mean? -

in this question answer includes modifying registry following line: @="outlook64bridge" does mean need add value new subkey, name of @ , type of reg_sz , data of outlook64bridge ? does @ have special meaning registry? ask because second part of answer has instructions adding (already existing?) key. '@' "default" value. in regedit, first value listed under name "(default)" in key.

javascript - Render HTML page before Head loads -

i have <head> tag lot of scripts, converted website 7 pages 1 , 1 page doing work of 7. there 2 - 30 second load time , in no way going make optimized mobile. writing raw html doesn't seem show until page loaded, writing 'loading, please wait...' doesn't appear until after fact. how 1 display loading comment before head tag finishes loading? off bat have 3 simple options. move scripts out of head, or defer scripts , or async scripts .

android - How to order the result of SQLite query by input alphabet? -

string sql = "select * " + table_name + " " + english + " ? order " + english + " limit 100"; try { cursor = db.rawquery(sql, new string[]{"%" + englishword + "%"}); for example, in column english , there "ice", "dice", "vice" etc. when input word "ice" in englishword , result arranged firstly "dice", followed "ice" , "vice". "ice" on first order because has exact word. how can accomplish this? use length function exact matched phrase , should query string sql = "select * " + table_name + " " + english + " ? order length(" + english + ") limit 100";

github - I copied someone's files, how do I push it to git -

i'm not savvy on "git lingo" excuse me if use wrong terms. i wasn't able clone (copy project machine) working off files emailed me. project has git folder naturally have senders credentials , settings. if try commit push (put onto repository) tries original sender , asks me password. how "make mine", in other words how make being committed , pushed me , asking password? i've poked around of files under .git folder , tried make "mine" still asks password. the git remote url contains original username included. can change existing remote url or add new git remote can use push ( changing remote's url or adding remote )

Is it possible to execute a command automatically upon launch in R? -

i use r gui app (r.app). when open app, loads data (e.g. .rapp.history or .rdata ) working directory. however, possible execute commands or functions automatically upon launch? i want load libraries such ggplot2 or plyr , use on session. you can edit rprofile.site , add desired commands functions .last , .first respectively. more info rprofile.site: here at startup, r source rprofile.site file. .rprofile file source in current working directory. if doesn't find it, 1 in user's home directory. there 2 special functions can place in these files. .first( ) run @ start of r session , .last( ) run @ end of session. that said, can edit function .first() load desired libraries. .first <- function() { library("dplyr") library("ggplot2") } you can edit same file , command, used purpose: options(defaultpackages=c(getoption("defaultpackages"), "dplyr","ggplot2"))

javascript - JQuery, Ajax and PHP : Sending FormData AND String values -

i'd send php page formdata value , string values. here's code on js side: $.ajax({ url: 'upload-pic.php', type: 'post', data: { type : type, id : id, formdata : formdata }, processdata:false, success: function(data, status) { //stuff i'm doing data } }); and on php side : if(isset($_post['type']) && isset($_post['id'])){ //stuff i'm doing } then, error saying type , id not set. i'm guessing comes processdata: false ajax call. without this, inevitable illegal invocation, coming trying send formdata. is there way send formdata , string values on same call ? thanks! i assume using formdata object, in case need append string values formdata object, , pass object in data parameter in jquery's $.ajax . you can append data formdata

r - Write Multiple CSV files in a loop -

i have csv file 1.5 million rows consists of 2 columns name , email.i want write program in such way when read file in r, output segmented of 5000 data in each csv. maybe can loop: run row 1 5000 , save project1.csv , 5001 10000 , save project2.csv , 10001 till 15000 in project3.csv in working directory. suggestions? assuming 'df1' data.frame need segment every 5000 rows , save in new file, split dataset creating grouping index based on sequence of rows list ( lst ). loop through sequence of list elements ( lapply(... ), , write new file write.csv . n <- 5000 lst <- split(df1, ((seq_len(nrow(df1)))-1)%/%n+1l) invisible(lapply(seq_along(lst), function(i) write.csv(lst[[i]], file=paste0('project', i, '.csv'), row.names=false)))

linux - inotifywait running daemon mode giving error Couldn't initialize inotify -

i running inotifywait (inotify-tools-3.14-1) in daemon mode, however, gave following error , no watches established. also, since within while loop, there many inotifywait daemon processes created. i have no such problem if running --monitor instead of --daemon. can fixing it? lot. " couldn't initialize inotify. running linux 2.6.13 or later, , config_inotify option enabled when kernel compiled? if so, mysterious has gone wrong. please e-mail radu.voicilas@gmail.com , mention saw message. " below code: while true # run indefinitely inotifywait --daemon --outfile /tmp/daemon.log --event close_write --format '%w%f %e %t' --timefmt '%f %t' $folder | while read eventinfo call_another_fun $eventinfo break done done when there many inotify processes running in background, "couldn't initialize inotify..." error message. pkill inotify solved this.

ios - How to disable UIButton vibration -

Image
up until today have been testing apps in simulator. first time tested project on real iphone. unpleasantly surprised every time press button phone vibrates. wouldn't big deal except particular app has built in keyboard plays audio sound every time key ( uibutton ) pressed. the combination of vibration sound plus audio sound distracting. is there way programmatically disable button vibration? i'm not asking how disable vibration phone, buttons choose. relevant question find opposite: making iphone vibrate . i don't have leave user turn vibration off in settings, i? update 1: judging comments, maybe either device specific problem or somehow triggering vibration. this how play sound: import foundation import audiotoolbox class player { private let audiofolder = "raw" func playsoundfromfile(file: string) { var soundurl: nsurl? var soundid: systemsoundid = 0 let filepath = nsbundle.mainbundle().pathforresource(&quo

r - Plotting a graph with multiple columns -

i have data set 20 years in first column (1990,1991,etc..) , each of next 5 columns different state (ca,co,pa,ny,tx). trying create plot year along x-axis, , totals each state along y-axis, each state being represented on plot different color line. i can fine using matplot: matplot(population$year,popamount,type="l") where popamount variable containing 5 state columns. using matplot code above, can achieve looking for. i wondering how using plot() though, because whenever try same code using plot(), receive error: error in xy.coords(x, y, xlabel, ylabel, log) : 'x' , 'y' lengths differ my population$year variable 20 years, , popamount has data each of 20 years. here snippet of data: year ca co pa ny tx 1990 1234 1234 1234 1234 1234 1991 5678 5678 5678 5678 5678 1992 9876 9876 9876 9876 9876 why able in matplot not plot?

How to catch 'hide.bs.tab' event for tabs in React-Bootstrap -

due docs react-bootstrap supports onselect method tabs fires once tab switch tab. looking similar native twitter bootstrap event hide.bs.tab determine moment when tab starts closing. i found utilities onexit method , doesn't work tabs, me. how that? actually, onselect fires (if provided prop) tab selected, not after switched to. handler's job switch active tab (or not), perhaps after loading additional information through wire, , on. an excerpt react-bootstrap code: if (this.props.onselect) { this._ischanging = true; this.props.onselect(selectedkey); this._ischanging = false; return; } (taken https://github.com/react-bootstrap/react-bootstrap/blob/44182b72da816b719029355478ef2e7efef522f6/src/tabs.js#l324 ) then followed built-in tab switching if hadn't provided onselect . for example, custom onselect handler display spinner, fetch data goes in new tab, , once that's done hide spinner , switch active tab one, using activekey prop.

javascript - toggleClass based on Click Function -

i interested in changing toggleclass depending on clicked on. i want class dependent on previous click on page. so if click on letter "a" - in case make square red. upon clicking on square want .toggleclass .darkred when click on letter "b" - want .toggleclass .darkblue how can make dynamic knows class add toggleclass <script> $("li.alpha").click(function(){ $(".color").addclass("red").removeclass("blue").removeclass("orange"); }); $("li.bravo").click(function(){ $(".color").addclass("blue").removeclass("red").removeclass("orange"); }); $("li.charlie").click(function(){ $(".color").addclass("orange").removeclass("blue").removeclass("red"); }); </script> <script> $(".color").on("mousedown mouseup", function(e) { $(".color").toggleclass(&qu

How do I center a textbox inside a panel in visual studio? -

when set textbox's anchor top,bottom,left,right textbox still stays on top. don't understand, seems work labels , buttons. kinda need anchor property adapt form resize. i'm sorry if i'm missing incredibly obvious. if understand question, want single line textbox appear centered vertically , horizontally in form. still without showing more 1 line. in case set anchor left , right property have textbox centered horizontally on form, vertical position need work code adjusting iop property of textbox in resize event of form for example, after call initializecompoment of form add following code center textbox (c# convertible vb.net) textbox1.left = 10; textbox1.width = yourform.clientsize.width - 20; textbox1.top = (yourform.clientsize.height / 2) - yourform.height / 2; textbox1.anchor = anchorstyles.left | anchorstyles.right; and add event handler resize event of form call again vertical repositioning of textbox protected void yourform_resize(object se

flex - Checking through an Object and returning if the element is found -

i trying return true items found within object although arrays within object have more 1 element within it. example selectedeventtypes[9] has array of [cancelled,cancelled2,cancelled3], although whenever item.eventtype cancelled2 never realise within object , return false this. private function eventfilterfucntion(item:object):boolean { if(selectedeventtypes.indexof(item.eventtype)>-1) { return true; } return false; } it looks have defined selectedeventtypes array of array like: private var selectedeventtypes:array = [["a1", "a2"], ["b1","b2"], ["c1","c2"], ["d1","d2"], ["e1","e2"], ["f1","f2"], ["g1","g2"], ["h1","h2"], ["i1","i2"], ["cancelled", "cancelled2", "ca

node.js - ExpressJS router middleware cannot render views -

trying set routes using express router middleware. except index.jade ( @ path http:localhost:3000/ ), other template under views directory not being rendered , router fails send response set in module. below snippet of code: app.js var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieparser = require('cookie-parser'); var bodyparser = require('body-parser'); var routes = require('./routes/index'); var users = require('./routes/users'); var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(logger('dev')); app.use(bodyparser.json()); app.use(bodyparser.urlencoded({extended: false})); app.use(cookieparser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', routes); app.use('/users',

php - Create new report in magento -

how create new custom report in magento? created own, seeking wrong tempalte, continues seek grid.php aquivo core, how can tell him grid.php file? may code: <?xml version="1.0"?> <layout version="0.1.0"> <reportneworders_adminhtml_reportneworders_index> <adminhtml_report_statistics_index> <reference name="content"> <block type="adminhtml/report_refresh_statistics" template="tagon/report/refresh/statistics.phtml" name="myrefreshstatistics" /> </reference> </adminhtml_report_statistics_index> <reference name="content"> <block type="reportneworders/adminhtml_reportneworders" name="mycontainer" template="tagon/report/grid/container.phtml"> </block> </reference> </reportneworders_adminhtml_reportneworders_in

Problems with numpy importation -

i´m trying work numpy , scipy i´m unable. in begining had error, right if write import numpy np have: traceback (most recent call last): file "c:/python34/num.py", line 2, in <module> import numpy file "c:/python34\numpy.py", line 2, in <module> = np.arange(10) attributeerror: 'module' object has no attribute 'arange' i had wroten a=... before. have idea? both numpy , scipy installed lib of python 3.4 it should work if import numpy np >>> import numpy np >>> = np.arange(10) >>> print [0 1 2 3 4 5 6 7 8 9]

tortoisehg - Mercurial Update To Activate Bookmark -

i activate bookmark on revision if update revision. instance, if this hg -r "bookmark('re:fix.+2572')" this update me revision bookmark points to, won't activate bookmark. documentation says: note updating revision has bookmark without using bookmark name not activate bookmark (e.g. if feature bookmark points revision #20 , hg update --rev 20 feature bookmark not activated). but me seems nice feature/option have. more works if in tortoisehg ui, couldn't figure out how in command line version of mercurial. is there way/workaround ? you can create alias new command, let's call bupdate. add .hgrc: [alias] bupdate = !hg $($hg log $@ -t'{bookmarks}\n' | cut -d\ -f1) call hg bupdate call hg update . activate first bookmark attached specific revision. update revision if there no bookmark. updates 2nd or 3rd or further bookmarks attached revision still need done manually.

Stop/Start Azure Cloud Service -

in order automate process in cloud deployment, need stop , start cloud service (that archives data) through code. currently, stop , start cloud service manually using azure management portal. want done through cloud service processes input data. the azure cloud service trying stop , start has 1 deployment (production). there limited information available in google on how this. i tried following msdn website(azure rest api) toggle deployment status between "running" , "suspended", but, getting "bad request" error when implement described in website (msdn not allow me post website details). can 1 of point me right direction on how stop/start azure cloud service through code? is virtual machine? if yes, use rest api/powershell should trick start vm using rest api stop vm using rest api

See "Unfortunately, Google play service has stopped" when starting app from ARC Welder -

my app have google play services integrated. metadata is {"useplayservices":["gcm","maps"]} when start app inside arc welder (on chrome os 46.0.2490.71). see error "unfortunately, google play service has stopped" and app crashes. in log console, see error message "authentication error error: user not signed in." the crash happens 1st time when load apk in arc welder , test it. in subsequent launches (w/o config changes in welder), app starts without crash. although still see same auth error in log. not sure if auth error related crash. any idea?

How to set meteor ROOT_URL for mobile device deployment -

i'm trying deploy meteor app on ios device using meteor run ios-device --mobile-server myapp.meteor.com but unfortunately every time meteor goes online says => started app on ios device. => started mongodb. => started app. => app running at: http://localhost:3000/ how change point url instead? i looked around , people saying set these variables. question how , set these variables? meteor.absoluteurl.defaultoptions.rooturl process.env.root_url process.env.mobile_root_url process.env.mobile_ddp_url many thanks!

regex - Getting Index of First Non Alpha character in a string C# -

i'm trying split out string (at index) whenever find first non alpha or whitespace. my regex rusty , trying find direction on getting work. example: "payments received 08/14/2015 $0.00" string. , i'm able find first digit string alphabet = string.empty; string digit = string.empty; int digitstartindex; match regexmatch = regex.match("payments received 08/14/2015 $0.00", "\\d"); digitstartindex = regexmatch.index; alphabet = line.substring(0, digitstartindex); digit = line.substring(digitstartindex); the problem lies when string "amount period + $57.00" end "amount period + $" how using regex in c#, if want include specific non-alphanumeric characters check such $ + - ? edit: i'm looking output (variables alphabet , digit) in example above i'm struggling be. "amount period" "+ $57.00" to split string way mention, use regular expression find initial alpha/space chars

java - Half transparent screen without lights? -

i following tutorial: https://github.com/mattdesl/lwjgl-basics/wiki/shaderlesson6 want make 2d lightning whenever render black screen. code: main class public class main { private static final int width = 1280; private static final int height = 720; private static int shaderprogram; private static int vertexshader; private static int fragmentshader; private static terrain terrain; public static final float default_light_z = 0.075f; public static final vector4f light_color = new vector4f(1f, 0.8f, 0.6f, 1f); public static final vector3f light_pos = new vector3f(0, 0f, default_light_z); public static final vector4f ambient_color = new vector4f(0.6f, 0.6f, 1f, 0.2f); public static final vector3f falloff = new vector3f(.4f, 3f, 20f); public static void main(string[] args) { initdisplay(); initgl(); terrain = new terrain(); terrain.createterrain(); createshader(); gameloop();