Posts

Showing posts from January, 2014

javascript - Using d3 to shade area between two lines -

so have chart plotting traffic vs. date , rate vs. date. i'm trying shade area between 2 lines. however, want shade different color depending on line higher. following works without last requirement: var area = d3.svg.area() .x0(function(d) { return x(d3.time.format("%m/%d/%y").parse(d.original.date)); }) .x1(function(d) { return x(d3.time.format("%m/%d/%y").parse(d.original.date)); }) .y0(function(d) { return y(parseint(d.original.traffic)); }) .y1(function(d) { return y(parseint(d.original.rate)); }) however, adding last requirement, tried use defined(): .defined(function(d){ return parseint(d.original.traffic) >= parseint(d.original.rate); }) now works, except when lines cross. how shade area under 1 line between points? it's shading based on points , want shade based on line. if don't have 2 consecutive points on 1 side of line, don't shading @ all. since don't have datapoints @ intersections, sim

linux - How to execute shell command and stream output with Python and Flask upon HTTP request? -

following this post , able tail -f log file webpage: from gevent import sleep gevent.wsgi import wsgiserver import flask import subprocess app = flask.flask(__name__) @app.route('/yield') def index(): def inner(): proc = subprocess.popen( ['tail -f ./log'], shell=true, stdout=subprocess.pipe ) line in iter(proc.stdout.readline,''): sleep(0.1) yield line.rstrip() + '<br/>\n' return flask.response(inner(), mimetype='text/html') http_server = wsgiserver(('', 5000), app) http_server.serve_forever() there 2 issues in approach. the tail -f log process linger after closing webpage. there n tail process after visiting http://localhost:5000/yield n time there can 1 client accessing http://localhost:5000/yield @ single time my question(s) is, possible make flask execute shell command when visit page , terminat

php - Opencart error while uploading on server -

i have installed opencart on localhost it's working when have uploading on server it's give me error: cannot find template file 'default/template/module/magikslider.tpl' in /home/xyz/public_html/xyz/system/engine/factory.php on line 614 it seems have set default theme, need apply custom template admin panel. to apply template use below procedure if using opencart version 2.1.x, go opencart admin panel > system > settings > edit . click store tab , choose theme "template" option. action activate new theme. if using opencart version 2.2.0.0, go opencart admin panel > extensions > themes > edit , choose theme "theme directory" option. action activate new theme.

How to write a LoadRunner script to measure queue depth for JMS? -

i need write loadrunner script measure queue depth per second jms. can give tips on achieving using lr v12.5? many thanks! anuradha first, ask yourself, how manually examine queue depth queue provider? instance, if queue queue table on oracle, query number of rows in queue table. if queue on rabbitmq, perhaps use management plug in issue http request appropriate parameters queue depth. mq might have command line option system prompt. once understand manual method can @ how automate either @ gui layer or @ protocol layer queue provider. manual process plus communications architecture end queue provider key here.

makefile - Variable assignment in recursive make call -

i have simple makefile below: var += 4 5 6 default: @echo "$(var)" a: var="1 2 3" make b: make var="1 2 3" make a works expected , print 1 2 3 4 5 6 , make b print 1 2 3 . thought 2 variants identical. the question is: why so? to quote gnu make manual: if variable has been set command argument, ordinary assignments in makefile ignored. you can change override directive: override var += 4 5 6

How to delete Firebase users -

i have upgraded firebase app new version, see firebase @ console.firebase.google.com . the console shows me message wow, have lot of users! because have on 500 users, aren't automatically displayed. way see user details @ seems to search complete email address , works users password. i don't know how came have many users, it's development system , not aware of more dozen userids. regardless, delete them all . i same message in production system has less 500 known users, must have not real - want able view details , delete them 1 one . the docs don't provide solution either requirement. suggestions please?

android: How to set margin/padding between EditText custom background and InputTextLayout Label? -

well want set margin/padding between edittext , inputtextlayout label on pressed state. here's image of - desired design main xml code - ` <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="56dp" android:gravity="center_horizontal" android:orientation="vertical" android:paddingleft="24dp" android:paddingright="24dp"> <imageview android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="24dp" android:src="@drawable/headphones_3" /> <android.support.design.widget.textinputlayout android:id="@+id/textlabel" android:layout_width="match_parent" android:layout_height="wrap_content"

powershell - Get-ADDomain | Select Name -

i making script supposed go server, grabbing domain name , users in specific group, go out , continue on next server. well, got connection phase done , need users , domain name. here snippet of code: foreach ($user in (get-adgroupmember fjärrskrivbordsanvändare | select name)) { $userarray += $user.name $domainarray = get-addomain | select name $domainarray $userarray } as can see add names of users in array, want save name of domain in array , print them both see if ok. when print domains, name show along ip server , code dont know comes from. looks this cstein (ip) 82ddgfhdghjdfw-sdfgsbbc-42sfdsdf4-a8dfgd-734ddeee345817 does know fix this? want "cstein" when select name. i scrambled numbers , letters in long "code" or whatever is. don't know if it's sensitive information. keep in mind talkig swedish 15 year old when write answer. i create pscustomobject containing user , domain property: $result = get-adg

javascript - Searching a table row for specific text in a COLUMN and HIGHLIGHT -

i retrieve information database , create table. have column name status , of values equal 'a'. there values though equal 'c'. want rows column of status equal 'c' background color red. my code doesn't seem work , think javascript part. any welcome. my code this: <thead> <tr> <th>dongle</th> <th>actdate</th> <th>moddate</th> <th>client</th> <th>company</th> <th>activation</th> <th>comments</th> <th>status</th> </tr> </thead> <script type="text/javascript"> $(document).ready(function(){ $('table tr').each(function(){ if($(this).find('td').eq(3).text() == 'c'){ $(this).css('background','red'); } }); }); </script> <?php $querystring = $_session['clientid

Android: Check if bitmap has aspect ratio 4:3 -

i retrieving images gallery using content resolver final string[] columns = {mediastore.images.media.data, mediastore.images.media._id}; final string orderby = mediastore.images.media._id; cursor imagecursor = context.getcontentresolver().query( mediastore.images.media.external_content_uri, columns, null, null, orderby); int image_column_index = imagecursor .getcolumnindex(mediastore.images.media._id); count = imagecursor.getcount(); imagelist = new arraylist<bitmap>(); (int = 0; < count; i++) { imagecursor.movetoposition(i); int id = imagecursor.getint(image_column_index); bitmap b = mediastore.images.thumbnails.getthumbnail( context.getcontentresolver(), id, mediastore.images.thumbnails.micro_kind, null); imagelist.add(b); } how check if bitmaps aspect ratio 4:3 ,

STR_TO_DATE in MySQL in INSERT query returns null -

the following select returns null. select str_to_date('27/09/2016 17.51.55','%d/%m/%y %h%i%s'); i tried adding dots between '%h%i%s', same result. can show me wrong here? try this select str_to_date('27/09/2016 17.51.55','%d/%m/%y %h.%i.%s');

javascript - protractor js, repeater not iterating through the 'result' -

in protractor.test.js it('should make sure there listings on page', function() { var count = element.all(by.repeater('res in result')); count.then(function(result){ expect(result.length).tobegreaterthan(0); }, 5000); }) and in index.html <div class="item item-text-wrap" ng-click="post($event,res)" ng-repeat="res in result" ng-controller="recommendedjobsctrl" ui-sref="menu.jobdetails" > the issue says expected 0 greater 0. when change res in tests or other word still gives me same answer. don't think it's reading result i agree part of igniteram's answer should use count() , cannot use expected conditions on elementarrayfinder (which element.all returns). instead, try using helper function, taken alecxe's answer on question . // in helper file util.js // wait x number of elements util.prototype.presenceofall = function (elem, num) { console.log(&

qt - QML: MessageDialog , the ordering of standardButtons and setting default button -

i have in main.qml following code messagedialog { id: exitdialog title: "quit" text: "save before quitting?" icon: standardicon.question standardbuttons: standardbutton.save| standardbutton.discard | standardbutton.cancel onaccepted: { ... } ondiscard: qt.quit() } the problem buttons me appear close without saving cancel , last save! default button set close without saving. i want order of buttons in code maintained , default set save. face such problems? suggestions ? i have seen answer how set default button of messagedialog in qml? how do standardbuttons? just give idea. http://doc.qt.io/qt-5/qmessagebox.html the display order buttons platform-dependent. example, on windows, save displayed left of cancel, whereas on mac os, order reversed. mark 1 of standard buttons default button. qmessagebox msgbox; msgbox.settext("the document has been modified."); msgbox.setinformativetext("do w

mysql - INSERT EPOCH AND Unix TimeStamp between 2 dates -

i have small issue, have insert sql statement follows: insert table (`col`, `col`, `col`) values '1', '2', floor(950000+rand()*(550000-950000)); one of columns epoch unix timestamp, want able randomize inserts between 2 dates: example: randomized insert value between: 1469696000 , 1479996000 how can achieve using rand set condition must between values when converter between epoch dates? you can give try: insert table (`col`, `col`, `col`) values '1', '2', (floor( 1469696000 + rand( ) *(1479996000-1469696000 ))) note: (floor( + rand( ) * b)) return random number between , a+b (inclusive) edit: in order random unix timestamp between now , end of year: (floor( unix_timestamp() + rand( ) *(unix_timestamp((curdate() - interval dayofyear(curdate()) day) + interval 1 year) - unix_timestamp()))) so here's full query: insert table ( `col`, `col`, `col` ) values '1', '2', (

windows - How to remove virtual CD/DVD-ROM -

on win10 have possibility mount iso files. each mounted iso system creates virtual cd/dvd-rom drive. see these drives can use powershell: ps c:\> gwmi win32_cdromdrive caption drive manufacturer volumename ------- ----- ------------ ---------- microsoft virtual dvd-rom volume{b62e0d58-541d-11e6-a1f7-005056873534} (standard cd-rom drives) microsoft virtual dvd-rom volume{d2c8b686-5410-11e6-a1f6-005056873534} (standard cd-rom drives) microsoft virtual dvd-rom cdrom13 (standard cd-rom drives) microsoft virtual dvd-rom cdrom14 (standard cd-rom drives) microsoft virtual dvd-rom cdrom15 (standard cd-rom drives) microsoft virtual dvd-rom cdrom16 (standard cd-rom drives) microsoft virtual dvd-rom cdrom19 (standard cd-rom drives) microsoft virtual dvd-rom volume{b62e1bc8-541d-11e6-a1f7-005056873534} (standard cd-rom drives) necvmwar vmware ide cdr10 ata device d: (standard cd-rom drives) now question how delete these devices using winapi/powershell whatever ? i know deleted when u

sql server - sql. syntax select Perform Arithmetic Operations -

i want perform arithmetic operations in select syntac sql 10 minus 5 = 5 select not work. select datediff(minute,on_duty, clock_in ) late, datediff(minute ,off_duty, clock_out ) early, late - jajalan kkpsurabaya look image pls you cannot use result of function in same select because you cannot refer alias outside of select , order because of way query parsed. call same function multiple times: select datediff(minute,on_duty, clock_in ) late, datediff(minute ,off_duty, clock_out ) early, datediff(minute,on_duty, clock_in )- datediff(minute ,off_duty, clock_out ) jajalan kkpsurabaya or common-table-expreession: with cte ( select datediff(minute,on_duty, clock_in ) late, datediff(minute ,off_duty, clock_out ) early, t.* kkpsurabaya t ) select late, early, late - jajalan cte

android - how to use toolbar(humburger icon) as backstack navigation -

Image
i have navigate fragment mainactivity , if have more 1 fragment in activity, need navigate 1 one using toolbar(humburger icon). in fragment hosting toolbar, call activity backpress: @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: getactivity().onbackpressed(); break; } return true; } to change icon arrow, in fragment: actionbar actionbar = getactivity().getsupportactionbar(); if (actionbar != null) { // loading arrow drawable. final drawable uparrow = getresources().getdrawable(r.drawable.abc_ic_ab_back_mtrl_am_alpha); // should work actionbar.sethomeasupindicator(uparrow); actionbar.setdisplayhomeasupenabled(true); actionbar.sethomebuttonenabled(true); }

javascript - getImageURI() not work from orgchart by google -

fiddle i created fiddle when try getimageuri() chart (orgchart google charts) 1 error generated. error: "uncaught typeerror: chart.getimageuri not function" i need generate image or pdf orgchart created. possible? google.charts.load('current', {packages:["corechart","orgchart"]}); google.charts.setonloadcallback(drawchart); function drawchart() { var data = new google.visualization.datatable(); data.addcolumn('string', 'name'); data.addcolumn('string', 'manager'); data.addcolumn('string', 'tooltip'); // each orgchart box, provide name, manager, , tooltip show. data.addrows([ [{v:'mike', f:'mike<div style="color:red; font-style:italic">president</div>'}, '', 'the president'], [{v:'jim', f:'jim<div style="color:red; font-style:italic">vice president</div>&

Encode IP address using all printable characters in Python 2.7.x -

i encode ip address in short string possible using printable characters. according https://en.wikipedia.org/wiki/ascii#printable_characters these codes 20hex 7ehex. for example: shorten("172.45.1.33") --> "^.1 9" maybe. in order make decoding easy need length of encoding same. avoid using space character in order make parsing easier in future. how can 1 this? i looking solution works in python 2.7.x. my attempt far modify eloims's answer work in python 2: first installed ipaddress backport python 2 ( https://pypi.python.org/pypi/ipaddress ) . #this needed because ipaddress expects character strings , not byte strings textual ip address representations __future__ import unicode_literals import ipaddress import base64 #taken http://stackoverflow.com/a/20793663/2179021 def to_bytes(n, length, endianess='big'): h = '%x' % n s = ('0'*(len(h) % 2) + h).zfill(length*2).decode('hex') return s i

android - aidl oneway keyword error -

i implementing aidl interface, , reason, following code gives me error: // iapkinsoncallback.aidl package com.applications.philipp.apkinson.interfaces; /** interface implemented apkinson plugins can give feedback */ oneway interface iapkinsoncallback { /** called plugin after registration setup data result viewing usage of data: intent intent = new intent(intentactionname); intent.putextra(bundleresultkey, result); startactivity(intent); */ void onregistered(string intentactionname, string bundleresultkey); /** called plugin when result ready after stopdata() called apkinson */ void onresult(string result); /** called if error occured in plugin , call won't handled */ void onerror(string errormsg); } error: <interface declaration>, <parcelable declaration>, aidltokentype.import or aidltokentype.package expected, got 'oneway' when remove oneway keyword, works fine. cannot solution problem.

c# - MvvmCross ShowViewModel loading sequence -

i have sequencing problem in viewmodel, seems thread-related can't quite figure our what's going wrong or how "fix" fixing it. i have viewmodel needs call async method load initial data. calling async method init method mvvmcross calls automatically. if loading fails reason want show error screen, calling showviewmodel inside method called init not produce expected result. showviewmodel called correctly, following in debugger appears errorviewmodel shows before original viewmodel / view has finished loading - loads doesn't appear, over-written original viewmodel. here's simplified version of loading code: public async task init() { await loadinitialdataasync(); } protected async task loadinitialdataasync() { var loadresult = await loadsomestuffasync(); if (loadresult.isbadnews) { showviewmodel<errorviewmodel>(); return; } } the mvxtrace logs tell me showviewmodel called on errorviewmodel after called on in

python - Use base class's property/attribute as a table column? -

a game engine provides me player class steamid property (coming c++, basic example on in python): # game_engine.py class player: def __init__(self, steamid): self.__steamid = steamid @property def steamid(self): return self.__steamid i proceed subclass class while adding gold attribute: # my_plugin.py class myplayer(game_engine.player, base): gold = column(integer) now need store player's gold database player's steamid primary key identify player. how tell sqlalchemy use base class's steamid property primary key? here's silly tried: from sqlalchemy.ext.declarative import declarative_base sqlalchemy.ext.hybrid import hybrid_property import game_engine base = declarative_base() class player(game_engine.player, base): __tablename__ = 'player' _steamid = game_engine.player.steamid @hybrid_property def steamid(self): return type(self)._steamid.__get__(self) but yeah, long shot...

html - Is there performance difference in image source file than base64? -

i wondering if there performance difference between using pictures base64, compared using actual files, user has download on fly. an image http url of own: requires separate http request (which slow on http 1 fast on http 2) can loaded in parallel resource references it can cached doesn't need requested subsequence pages or reloads of initial page probably requires fewer bytes transfer base64 equivalent

angular - Angular2 forms - access value in ngIf -

i have a <select #type > . need reference value of select later on in template inside ngif, how can so? tried *ngif='type.value!="category"' , doesn't seem trick.. could bind select model , reference model element? <select [(ngmodel)]="type"> <!-- options --> </select> <div *ngif="type !== 'category'"> </div>

sql - How to get data between two dates with timespan in c#? -

Image
i want export data excel database, in excel want data timespan of minutes or hours. so taking hours , minutes 2 separate comboboxes , selecting datetime 2 datetime pickers. , data minute minute.so want data 5 minutes time span? data this: i want data 4:32:44 4:38:45 1 minutes gap means 4:32:44 4:33:44 4:34:44 so how can this: you can use between keyword search values between 2 values: the between operator used select values within range. here example snippet might help: select id, somecolumn mytable somecolumn between @date1 , @date2

javascript - JSHint in my vim marks 'yield' as a warning. -

i'm writing mocha tests , using vim jshint. unfortunately jshints gives me lot of warnings due 'yield' keyword. 'yield' available in es6 (use 'esversion: 6') or mozilla js extensions (use moz). this warning w118 , have tried disable warning in .jshintrc file { "mocha": true, "-w118": true } but far unsuccesfull in hiding warning. ideas why? have read documentation , don't want use inline configuration. thanks melchor629 finding answer. setting "esversion": 6 in .jshintrc file fixed problem.

json - How to pass value of object to new global variable in JavaScript -

i have written program run node.js server interact python script (source: https://github.com/extrabacon/python-shell ), sends data script , receieves returned value. returned (message) (in pyshell.on ) json , appears local function passed in, use data elsewhere in program outside function. being new javascript tried set ret_val = message; no avail, have tried changing type (python side) string (still no success), , converting json string , parsing ret_val (as now) ret_val = json.parse(json.stringify(message)); . unfortunately none of these methods work, ret_val remains undefined, despite message containing data need object (checked using typeof). know either correct way copy contents of message variable ret_val later returned, or possibly correct way message data if using module incorrectly. see below logs update: full script containing issue, occurs in function run_py_script when setting ret_val . var express = require('express'); var router = express.router(

Reference - What does this regex mean? -

Image
what this? this collection of common q&a. community wiki, invited participate in maintaining it. why this? regex suffering give me ze code type of questions , poor answers no explanation. reference meant provide links quality q&a. what's scope? this reference meant following languages: php , perl , javascript , python , ruby , java , .net . this might broad, these languages share same syntax. specific features there's tag of language behind it, example: what regular expression balancing groups? .net the stack overflow regular expressions faq quantifiers zero-or-more: * :greedy , *? :reluctant , *+ :possessive one-or-more: + :greedy , +? :reluctant , ++ :possessive ? :optional (zero-or-one) min/max ranges (all inclusive): {n,m} :between n & m , {n,} :n-or-more , {n} :exactly n differences between greedy, reluctant (a.k.a. "lazy", "ungreedy") , possessive quantifier: greedy vs. reluctant vs. possessive qu

css - Selector for sortable header of ng-table -

i'm using sortable ng-table display data. each column has sorting header. (which <div> inside <th class="sortable"> ) if try select first header using th.sortable > div:nth-child(1) it selects divs inside each <th> i forked existing fiddle , added block @ top of css pane. http://fiddle.jshell.net/7mom2ar0/ th.sortable:nth-child(1) > div:nth-child(1) { background-color: red; } use this, if want first selector <th> can done also. : http://fiddle.jshell.net/bxhcu50a/ th.sortable:first-child > div:first-child { background-color: red; }

php - Entity is not mapping to table name properly -

i have created entity name "inventoryvenue" table "inventory_venue". when i'm trying insert data, entity manager pointing "inventoryvenue" instead of "inventory_venue" not exists in database. this entity this code here entity not pointing actual table.

Nested forms not storing data into database in rails 4 -

i have vendor model, product model, , vendor_product model. in vendors form, have used nested form create vendor_products attributes vendor_id, product_id , copies.on creating new vendor, creates vendor_product. reason, not stores vendor_id , product_id in vendor_products table stores copies my associations follows a vendor -> has_many :vendor_products has_many :products, through: :vendor_products a product -> has_many :vendor_products has_many :vendors, through: :vendor_products a vendor_product belongs_to :vendor belongs_to :product vendor.rb class vendor < activerecord::base has_many :vendor_products has_many :products, through: :vendor_products accepts_nested_attributes_for :vendor_products, :products, :allow_destroy => true end my vendors/_form.html.erb <%= form_for(@vendor) |f| %> <% if @vendor.errors.any? %> <div id="error_explanation"> <h2><%= p

R - pbkrtest, “Error : object ‘sigma’ is not exported by 'namespace:stats'” -

i following error message when trying load pbkrtest : error : object ‘sigma’ not exported 'namespace:stats' in addition: warning messages: 1: package ‘pbkrtest’ built under r version 3.3.1 2: replacing previous import ‘stats::sigma’ when loading ‘pbkrtest’ error: package or namespace load failed ‘pbkrtest’ any suggestions? what trying this: update.packages(ask = false, repos = 'http://cran.rstudio.org') it works me.

node.js - Async table query in sequelize getter method -

i have sequelize instance method performs db query: getpropertydays() { const querystring = ` select state property_days date(day) = curdate() , property_id = :propertyid;`; const replacements = {propertyid: this.id}; return this.sequelize.query(querystring, {replacements: replacements, type: sequelize.querytypes.select}); }, that gets called getter: gettermethods: { propertystate() { var self = this; const blockedday = 'x'; const unavailableday = 'u'; this.getpropertydays().then(function(result) { var state = result[0]['state']; if (self.prospect || state == unavailableday) { return 'unavailable'; } if (state == blockedday) { return 'occupied'; } else { return 'available'; } }); } }, the problem result returned getter undefined because he's not able solve promise before retur

Delete function doesnt work in cakephp -

i working in project left other person me. the database of project has been moved 1 location another. moving database done owner. caused 1 function stop working "delete" function records. for development enviroment moved database locally, works. make me believe there wrong sending delete request server. the code looks this: if ($this->removedduty->save($duty['duty'])) { if ($this->duty->delete($duty_id)) { $this->session->setflash('this duty removed', 'default', array('class' => 'message success')); return true; } else { $this->session->setflash('this duty not removed.', 'default', array('class' => 'message error')); return false; } } else { $this->session->setflash('there wrong backing data', 'default', array('class' => 'message error')

How to serialize Forms in vb.net? -

below code serialize object. need serialize form , save in configuration of application. i have set breakpoint , noticed returns nothing or null (3rd line in code below) public function serializeobject(byval o object) string if not o.gettype().isserializable return nothing end if using stream new memorystream() dim ser new system.runtime.serialization.formatters.binary.binaryformatter ser.serialize(stream, o) messagebox.show(convert.tobase64string(stream.toarray)) return convert.tobase64string(stream.toarray) end using end function if there alternative, love know more. forms in .net not serializable, reason hold handle window. handle valid here (on session on computer) , (if close application in ten minutes handle won't valid anymore). therefore handles cannot serialized , neither can forms. the idea work around : you serialize form yourself, selecting values want save you create class serializable

php - Matching 3 last numbers in a string with regex -

problem: trying highlight last 3 numbers in string using regular expression. code: <?php show_source('regex.php'); $string = " 780155overf i000000 tranfer domestic 000114 sthlm se ab "; ?> <!doctype html> <html> <head> <title>regex match last 3 numbers</title> <meta charset="utf-8"> </head> <body> <?php echo nl2br(str_replace('/\d{3}(?=[^\d]+$)/g', '<span style="background-color:red;">$1</span>', $string)); ?> </body> </html> desired outcome: the numbers 114 should have red background color. use: print nl2br( preg_replace('/\d{3}(?=[^\d]+$)/s', '<span style="background-color:red;">$0</span>', $string) );