Posts

Showing posts from February, 2013

Exporting image into excel in javascript -

i want export html page excell sheet contains svg charts , html tables. searched lot , couldn't find solution in javascript. find php solution in this . thing found node module( here ) think cannot used in web page js file. finally got solution inserting image excel in excelbuilder.js . can insert image specifying cell or offset positions using plugin. works.

python's sys.settrace won't trace builtin functions -

this question has answer here: python's sys.settrace won't create c_call events 1 answer i've been using sys.settrace function write tracer program, working great except doesn't seem called built-in functions, open('filename.txt'). behavior doesn't seem documented, i'm not sure if i'm doing wrong or if expected behavior. using doug hellmann's "trace_calls_and_returns" code here tracing function. if can't settrace, there way trace calls open()? don't want use linux's strace, it'll run whole program (not part want trace) , won't show python line numbers/file names, etc. other option considered monkey-patching open function through wrapper, like: import traceback, __builtin__ def wrapped_open(*arg,**kw): print 'open called' traceback.print_stack() f = __buil...

azure - Instantiate DeviceClient with IoT Hub -

i have console app sends commands directly raspberry pi via azure iot hub. works fine. where confused though, on 2 different ways (possibly more?) instantiate deviceclient. ex: deviceclient = deviceclient.create(iot_hub_host_name, authenticationmethodfactory .createauthenticationwithregistrysymmetrickey(iot_hub_device, iot_device_key), transporttype.http1); or deviceclient = deviceclient.createfromconnectionstring(iot_hub_conn_string); seem same thing. why use 1 on other? can receive messages either way. yes, in end of day have same result. https://github.com/azure/azure-iot-sdks/blob/master/csharp/device/microsoft.azure.devices.client/deviceclient.cs create(...) method invokes iothubconnectionstringbuilder.create(...) createfromconnectionstring(...) , has description method creates deviceclient individual parameters. so, believe, create 1 kind of wrapper gets parameters, creates connection string individual params , passes createfromconnec...

filterfunction - How to combine Filter and IF-Statements in Google Spreadsheet -

problem have 2 sheets. sheet 1: supposed contain dashboard. sheet 2: contains table 3 columns, starting @ row 16 so want type in string in 'sheet 1'!$b$2, have formular value in sheet 2, , return 3 columns. if 'sheet 1'!$b$2 empty, show columns , rows of sheet here tried: =if(isblank($b$2), 'sheet 2'!a16, filter('sheet 2'!a16:a$1000, 'sheet 2'!$c16:$c$1000=$b$1)) works trick nr. 1, not nr. 2. shows first row obviously. if pull formular down rows, nr. 2 works, nr. 1 not. error gives me ref - array result not expanded, because override data in f16 . f16 column, formular in. here sample sheet. can advice? for case formula this: =if(isblank($b$1), arrayformula(sheet2!a16:d1000), filter(sheet2!a16:a$1000, sheet2!$c16:$c$1000=$b$1))

html - transparent png not rendering as transparent? -

Image
i saved image transparent png nothing can seems fix it!?! ideas??? it should this: here copy of image in gimp showing it's indeed transparent: finally, old code: the markup: <form class="search" action="search.php"><input class="search" type="text" name="search" id="searchbox"/></form> search box css: .search, .search:active, .search:focus, .search:visited { position: absolute; color: #fff; top: 3px; width: 368px; right: 9%; font-size: 28px; z-index: 3; border-radius: 20px; /* box-shadow: inset -2px 0px 1px rgba(0,0,0,.8); */ text-indent: 10px; text-shadow: 0px -2px 3px rgba(0, 0, 0, .7); background-color: #00d4c7; } the search icon css itself: pseudo ::before element .search:before { content: ""; position: absolute; top: 7px; left: 268px; background-image: url("images/icon-search.png"); ...

arduino - ESP8266 module programming, usb port not defined -

Image
i trying connect esp8266 wi-fi module via usb ttl converter pc, device manager not showing established port given connection. thing device manager shows out "cp2102 usb uart bridge controller" , hence putty not identifying port. kindly me out. screenshot: first of need install drivers here: https://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx then need make sure power supply esp8266 has output of 3.3v.

php - How to keep source and build folders in sync during debugging? -

recently, updated php project use source folder , build folder. we're using gulp build project 'src' folder 'build' folder after pulling 'src' folder , project configuration files our git repo. project_root | ├── src | ├── build | └── {project configuration files} both frontend , backend developers running 'gulp watch' we've setup keep our 'src' , 'build' folders in sync. one of biggest annoyances we've encountered while debugging our project in browser open offending file error reported , tinker code until works in browser. however, more times i'd count, make change file in 'build' folder while debugging , have manually make change in 'src' folder (which overlooked @ first). is there way fix workflow issue? dueling watchers approach i thought making 2 file watchers detect changes in 'build' , 'src' folders respectively. when either watch detects change, turn off...

sql server - Where does Visual Studio 2013 sql schema compare tool get its view definition from -

Image
so trying compare view definition got location... select smv.definition view_definition, v.name table_name, iv.is_updatable sys.all_views v join sys.sql_modules smv on smv.object_id = v.object_id join information_schema.views iv on iv.table_name = v.name v.name = @name also compared against value @ location select * information_schema.views table_name = @name now clarity used grab second location turns out truncates definition @ 4000 characters while first query not truncate definition.. but here things both of definitions (assuming short enough not truncate) match. when go sql schema compare tool view definition shows in tool not match view definition stored in either of locations. give example. lets view simple dbo.view_test create view dbo.view_test select db.dbo.tbl_view_test.col1, db.dbo.tbl_view_test.col1 dbo.tbl_view_test go so lets that's whats showing in sql comparison output visual studio 2013 seems normal...but when go , pull...

In C++, I can access private variables of a struct, but not the private variables within the sub-struct -

struct teachers { private: int graddate; int quote; string name; string school; struct smallboard { private: vector<string> grade; vector<string> school; vector<string> emblem; vector<int> year; }; smallboard sb; public: static void retrieveinformation(vector<teachers> &_teachers); static void t_addinfo(vector<teachers> &_teachers, teachers teachers_); static void s_addinfo(vector<teachers::smallboard> &_smallboard, teachers::smallboard smallboard_); }; i can say teachers tempt; tempt.name = "bob"; but whenever attempt access variable within smallboard struct tells me private. i'm assuming method of accessing smallboard incorrect, how accomplish that? declaring smallboard nested type inside of teachers not change fact smallboar...

time complexity - Is there any algorithm whose big O and big theta are different? -

is there algorithm big o , big theta different? found them quite similar , confusing @ same time. i think part of confusion here stems fact algorithms don't have "a big-o" or "a big-theta." o , θ notation used describe long-term growth rates of functions, rather algorithms. when hear "binary search o(log n)," they're saying "the runtime of binary search o(log n)" or "the worst-case runtime of binary search on input of length n o(log n)." the other reason can confusing 1 function can big-o of number of different functions. example, function f(n) = n o(n), it's o(n 2 ), o(n 3 ), o(2 n ), etc. stems formal definition of big-o notation, says f(n) = o(g(n)) if (intuitively) in long term f(n) bounded above constant multiple of g(n). means can't speak of "the" big-o of function's runtime, since there can infinitely many functions might fit bill. what can following: if function's runtime θ(f(n...

mysql - Errcode: 13 when loading data into SQL Database -

attempting load file db. create temporary table if not exists tt_emails ( id int primary key auto_increment, util_account_id varchar(40) null, email varchar(344) not null, optout int not null ); load data infile '/shared/implementation/emails.tsv' table tt_emails (util_account_id, email, optout); the emails.tsv file has 3 columns, while temporary table made has 4. i'm not sure if correct syntax; included 4th column have id primary key column. i following error when run code: error 13 (hy000): can't stat of '/nfs/shared/implementation/ngma/co-48812_ngma_load_email/exclude_emails.tsv' (errcode: 13) it's unix/linux file system permissions problem. the operating system not allowing os user permission access specified file. the permission on every directory in path file must @ least read+execute, , permission on file must @ least read. the os user attempting access file unix/linux user account mysql server proce...

Stacking multiple columns in a stacked bar plot using matplotlib in python 3 -

Image
i trying generate stacked bar plot keep track of 3 parameters every hour on multiple days. picture of sample plot sampleplot . however, have had no success plotting in python. fact beginner in python, makes matters worse. two attempts made answer questions are: horizontal stacked bar chart in matplotlib , stack bar plot in matplotlib , add label each section (and suggestions) . however, have not been able achieve desired results following of above solutions. can please provide me guidance how generate plot or point me in direction? edit 1: code have written follows: import matplotlib.pyplot plt; plt.rcdefaults() import numpy np import matplotlib.pyplot plt status_day1 = [[0.2,0.3,0.5], [0.1,0.3,0.6], [0.4,0.4,0.2], [0.6,0.1,0.4]] status_day2 = [[0.1,0.2,0.7], [0.3,0.2,0.5], [0.1,0.5,0.4], [0.2,0.5,0.3]] day = ('day1', 'day2') fig = plt.figure(figsize=(10,8)) ax = fig.add_subplot(111) x in range(0,4): #looping through every hour y in range(0,3): #loo...

How to get all _ids from MongoDB collection in PHP? -

i want _ids mongodb collection using php. possible? yes, is: $connection = new mongoclient(); $collection = $connection->database->collectionname; $cursor = $collection->find(); foreach ( $cursor $id => $value ) { var_dump($value['_id']); //object(mongoid) } you can read more mongoid object here from comments : if need actual id string, , try usual way, php whine because starts dollar sign , thinks it's variable. instead, use notation: $mongoid->{'$id'} //get $id property of mongoid object

Scala.swing How does one scala components to current window size -

i'm trying display image in simpleswingapplication. make image change size when window changes size (i.e. manually dragging cursor adjust size). i think done listening something, reacting uielementresized. but i'm not sure how it. i've tried: listento(top) \\ or window/frame/uievent reactions += { // case uielementresized=> case class uielementresized(source: uielement); => // or without semicolon, without "source: uielement", without "class", , few other permutations. println(size) } i asked similar question yesterday, narrow. want make more broad question entire problem. i'm not familiar swing, looks reactions use partial functions callbacks. issue in pattern matching syntax, try reactions += { case uielementresized(source) => println(source.size) } you can find more detailed examples here: listeners , reactions in scala swing

xml - XPath Custom Sort Expression -

i'm sorting xsl list using xpath. i want sort chronologically, easy-- list items have duplicate titles , want grouped together, if newer. instance: list item (created 4/19) list item b (created 4/18) duplicate list item b (created 4/21) list item c (created 4/17) --the key here ensuring "duplicate list item b" appears beneath original, though it's newest. right now, expression consists of "@created" displaying items in descending order. need expression says "sort creation date unless title contains word 'duplicate' - in case, sort alphabetically" can propose custom xpath expression achieves this? thanks. edit: here window where' i'd enter xpath expression. again, 2 rows need worry @title , @created_x0020_date pic without code go on i'm going make lot of assumptions. given following xml block: <data> <block created="20160419" label="a"/> <block created=...

c# - Slowly fade in the opacity of a particle system -

i trying write code slowly fades in opacity of particles when player reaches @ position. the particle alpha value changed when player reaches postion doesn't fade, changes. i new programming wondering if missing blatantly obvious. thanks! public class increasefog : monobehaviour { renderer rend; gameobject character; float valtobelerpedfrom = 9f; float tparam = 0f; float speed = 0.01f; float characterposition; color c; void start () { rend = getcomponent<renderer>(); character = gameobject.find("character"); } void update() { characterposition = character.transform.position.x; if(characterposition >= 190f) { startcoroutine(increasefog()); } } ienumerator increasefog() { tparam = 0f; while (tparam < 1) { tparam += time.deltatime; valtobelerpedfrom = mathf.lerp(0f, 0.9f, tparam); ...

git - Re-merging after "Selective" or "Partial" Merge -

here's reproducible example of problem i've gotten myself into: setup mkdir test-git cd test-git git init echo 'hello, world.' > file1.txt git add . git commit -m 'init commit' git branch branch2 git checkout branch2 echo 'hello, universe' > file1.txt echo 'foobar' > file2.txt git add . git commit -m 'commit 2' i wanted merge branch2 master changes file1.txt , here's did: git checkout master git merge branch2 --no-commit --no-ff git reset -- file2.txt git commit -m 'partially merged branch2 master!' so here's realized might not have been idea... let's changed mind , want merge file2.txt in well. can run: git merge branch2 response: up-to-date. if run git diff branch2 --name-status returns d file2.txt , guess when unstaged file2.txt tracked deletion? still don'y understand why can't merge on , wouldn't add file (i don't understand git's merge algorithm well). unf...

html - can't use first-child css to set display -

i using wordpress , generating code: <aside class="left-hand-column"> <div class="textwidget"> <p></p> ...1 <div class="pdf-download"> <p> ... 2 <a href="http://www.kusuma.ee-web.co.uk/wp-content/uploads/2016/04/strategy2015-2018.pdf" target="_blank">download pdf</a> </p> </div> <p></p> ...3 </div> </aside> i want remove effects of <p></p> tag pairs. i thought set display:none them this: .textwidget p:first-child { display:none; } but making 1 , 2 p's disappear , leaving 3 - how need please? if familiar jquery can use this $('.textwidget p').each(function () { if ($(this).text().length === 0) { $(this).hide(); } });

ruby on rails - How to cache top N posts ordered by rating? -

i'm writing rails 5 json api. i've got action returns top n blog posts based on average rating . in order achieve low response time, denormalized database such posts has average_rating column. i'm caching every query so: # posts_controller.rb def top quantity = params[:quantity] if quantity.to_i > 0 render json: { posts: cached_top_posts(quantity) }, status: :ok else render json: '', status: :unprocessable_entity end end def cached_top_posts(quantity) rails.cache.fetch(['top', quantity], expires_in: 1.hour) post.limit(quantity).as_json(only: [:title, :content, :average_rating]) end end (order average_rating in model itself) i aware far optimal. whilst drastically improves response time when requesting same quantity of posts, better if, when cached top 1000 posts , not cache 100 posts , instead first 100 posts out of cached 1000 . what way achieve this? well, after had night's sleep,...

url - Weird issue with URLSearchParams() in Angular2 -

i have weird issue appears urlsearchparams() works when defining var search (i.e if change variable name var othername ) not work!! however, reason works when name search !! totally not logical @ all. any idea on what's happening here? constructor(http) { this.http = http; this.genre = null; this.dishes = null; //this 1 works fine var search = new urlsearchparams(); search.set('order', '-ordersno'); //here issue (to make work, need remove previous search declaration, , rename below var limit search) var limit = new urlsearchparams(); limit.set('limit', '2'); this.http.get('https://example.com/classes/mn', { limit }).subscribe(data => { this.dishes = data.json().results; }); this.http.get('https://example.com/classes/genre',{ search }).subscribe(data => { this.genre = data.json().results; }); i guess want have this: { search: search } //and { search: limit } option...

using Ionic 2 CLI with meteor backend -

is there way of using ionic 2 cli meteor's server side? ionic 1 use meteor-client-side, suggestion how use ? in advance! i've been running though rigor of researching same possibility, , i've come conclusion, 1 not want. you've seen this tutorial already. using example, had attempted modify meteor cli directly without success. i've decided instead drive build process gulp wrapping both ionic cli , meteor cli behind tasks. mobile/web apps separate meteor server (as in example). i've abstracted meteor client library behind angular/redux service give me flexibility replace meteor (with phoenix framework or rethinkdb), , moved service npm module. decoupling client(s) , server implementation , using own orchestrating build process may give added benefit support more client profiles beyond supported either cli dependently have discovered.

Add a row to a matrix inside a function (and propagate the changes outside) in Julia? -

this similar question: add row matrix in julia? but want grow matrix inside function: function f(mat) mat = vcat(mat, [1 2 3]) end now, outside function: mat = [2 3 4] f(mat) but doesn't work. changes made mat inside f aren't propagated outside, because new mat created inside f (see http://docs.julialang.org/en/release-0.4/manual/faq/#functions ). is possible want? multi-dimensional arrays cannot have size changed. there pointer hacks share data, these not modify size of original array. even if possible, aware because julia matrices column major, operation slow, , requires copy of array. in julia, operations modify data passed in (i.e., performing computations on data instead of with data) typically marked ! . denotes programmer collection being processed modified. these kinds of operations typically called "in-place" operations, because although harder use , reason about, avoid using additional memory, , can complete faster...

javascript - Why is this div not responding to innerHTML when others on the page do? -

this question has answer here: using variable “name” doesn't work js object 3 answers when using javascript set innerhtml of div have 1 div cannot figure out why not being set... i have following code in <body> on page <div style="width:50%; margin:0 auto;"> <div id="name"></div> <div id="image"></div> <div id="description"></div> </div> <script> var url = window.location.href; var captured = /name=([^&]+)/.exec(url)[1]; var result = decodeuri(captured); if (result != 'none') { var name = document.getelementbyid('name'); name.innerhtml = "<p>" + result + "</p>"; var description = document.getelementbyid('description'); description.innerhtml =...

python - BeautifulSoup search for an element returns [ ] -

the page trying work https://www.google.ca/flights/#search;f=yyc;t=cmh;d=2016-05-07;r=2016-05-11;tt=o (or other flight search). "inspect element" option tells me price associated lowest fare has html <div class="mhnsji-d-zb">$260</div> i trying find correct way identify element in beautifulsoup can put lowest fare variable lowfare. have read bs4 docs , expected either lowfare = soup.find_all('.mhnsji-d-zb') or lowfare = soup.select('.mhnsji-d-zb') to give me lowest available flight fare on given flight search, return lowfare = [] . i'm beginner, know case of me doing wrong, after reading documentation i'm still lost. am on right track? found question on site said html might hidden behind javascript in page, i'm new know that, or if applies in situation. thanks.

javascript - Issuing http get request and accessing the data I'm getting -

in app, i'm issuing request retrieve json server. $http.get('http://localhost:3000/documents/2.json') .success( function(success){ console.log("success"); }) .error( function(error){ console.log("error has occurred") }); right now, 200 response, i'm not sure how access json file i'm getting url in web app. assume there's gotta function(jsondata) not sure how implement in function above. i'm issuing in client side(written in angular) , getting data server(written in rails). front end (in angular) part of rails app now. major edit: this version (1.4.9) op using. in angularjs $http documentation v1.4.9 sample script of trying do. // simple request example: $http({ method: 'get', url: '/someurl' }).then(function successcallback(response) { //...

visual studio - Howto add and link to existing WebSite project from ASP.NET project -

i have existing website project; 1 .html , bunch of .js files (all client-side stuff). project has .sln file, no *.*proj files. it's directory structure basically: web_project_root/apps/foo/index.html web_project_root/lib/*.js now i'm working on new asp.net forms application, , need link index.html page above, i'd keep separate project (and not copy new asp.net project). it's structure basically: app_project_root/pages/*.aspx i've done add -> existing project , chosen .sln above, , shows in asp.net solution, can't figure out how link index.html because it's outside of asp.net project's ~/ directory. there way symlink somehow? or else?

How to protect/detect database restore on Android device? -

i have app android, saves data sqlite database in common way. user works application, data changed etc. far no problem... but when user use back-up software (like titanium backup or others), make backup of application, can restore data old state. need way protect application or detect restoration , handle it. the simple workflow: install app work app reach state1 of app's database back-up app (with backup/restore application, device can rooted) work app reach state2 of app's database restores app (or data) state1 - point need deny or detect on next execution of app. so far played access-time detection , comparsion, seems un-reliable through different devices , roms. thank you. to need save state off device, or @ least outside of data directory. easiest way save fingerprint of db file in 'hidden' directory on external storage (sd card). or if app has web login, etc. store fingerprint each user. in case, user has full control on device c...

html - Why bootstrap grid system is not following the column sizes -

Image
that's how want phone , extension align in form that's wrote phone , extension row : <div class="row form-group"> <label class="control-label col-md-2" for="phone">phone</label> <div class="col-md-6"> <input class="col-md-5" id="adminphone" name="adminphone" type="text" value="" placeholder="(999) 999-9999"> <div class="form-group col-md-7 pull-right"> <label class="control-label col-md-1" style="text-align: right" for="adminext">ext</label> <input class="col-md-6 pull-right" id="adminext" name="adminext" type="text" value="" placeholder="1234"> </div> ...

ios - loop specific keys in dictionary to get values -

Image
i have associative array of workouts key workout name , values of array of exercises. i have uitableview contain each workout name , exercises. problem getting exercises each workout , displaying in relating cell. this code far: var workout = [string : [string] ]() workout["chest"] = ["bench press","dumb bell incline", "dumb bell flies", "flat dumb bell press"] workout["back"] = ["deadlift","lat pulldowns", "uni lateral rows", "dumb bell row"] override func numberofsectionsintableview(tableview: uitableview) -> int { // #warning incomplete implementation, return number of sections return 1 } override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { var keys = [string]() keys = array(workout.keys) // #warning incomplete implementation, return number of rows return keys.count } override func tableview(tableview...

ruby - IRB won't read input after pasting over 1565 characters on Windows? -

though can paste size string ruby's irb prompt if it's running in unix shell (like bash on mac or linux), when try paste clipboard contents irb running on windows command/powershell prompt, if clipboard contains larger 1,565 characters irb fails receive input. not that, after paste attempt, irb not receive further input keyboard (stdin). does else have issue or know fix can paste longer strings irb? if you'd recreate it, try paste integer (1,566 characters long) irb prompt: 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567...

interpolation - AngularJS: Linking multiple scope variables inside external template -

i trying build custom directives inputs validations provided ngmessages directive. still, can't link multiple variables $scope dynamically determine form name , input name. here's code far: the directive: app.directive('textbox', ['$compile', function ($compile) { return { restrict: 'e', scope: { label: "@", fieldname: "@", bindto: "=" }, require: "^form", templateurl: '/webclient/directives/textbox/textboxtemplate.html', link: function (scope, element, attrs, ctrl) { $scope.formname = ctrl.$name; } }; }]); the template: <div> <label>{{label}}</label> <input type="text" name="{{fieldname}}" ng-model="{{field}}" required /> <div ng-messages="{{formname}}.{{fieldname}}.$error"> <div ng-message=...

artifactory vagrant repo, getting json or 404 response when trying to download the image -

Image
good time of day all, have setup pro version of artifactory , have setup vagrant repo 1 file. however, when try file artifactory following response instead of downloading file , due setting incorrect repo layout. default artifactory sets simple-default layout think causing issue {"name":"vagrant-centos-base.box","description":null,"short_description":null,"versions":[]} obviously, when try use vagrant command url repo/file specified following error: bsdtar.exe: error opening archive: unrecognized archive format which suspect due vagrant downloading response instead of actual file. what missing? thank in advance! here output vagrant: bringing machine 'webserver' 'virtualbox' provider... bringing machine 'webserver1' 'virtualbox' provider... bringing machine 'appserver' 'virtualbox' provider... ==> webserver: box 'vagrant-centos-base' not found. attempting find...

Starting and Stopping a service on windows 2008 R2 through python script -

i trying start , stop windows services through python script on machine running windows 2008 r2. small piece of code have in place stated below import subprocess import os import time,datetime p = subprocess.popen("sc.exe stop abc", stderr=subprocess.stdout,stdout=subprocess.pipe, shell = true) p.communicate()

jquery - CakePHP store parameters to the paginator settings -

i have function filters paginator this: public function indextipo() { $this->cabasiento->recursive = 0; $tipo = $this->request->data['tipo']; $fecha = $this->request->data['fecha_desde']; $this->paginator->settings=array( 'paramtype' => 'querystring', 'limit'=> 1, 'conditions' => array('cabasiento.tipo_doc' => $tipo, 'month(cabasiento.fecha)' => $fecha), 'order' => array('cabasiento.id_numero' => 'asc') ); $this->set('cabasientos', $this->paginator->paginate()); $this->layout = 'ingresos'; } it have .ctp. it works , display filter data, when try next other page gives me: undefined index: tipo [app\controller\cabasientoscontroller.php, line 35] undefined index: fecha_desde [app\controller\cabasientoscontroller.p...

extract a pattern from different string in Python -

i have few file name : xyz-1.23.35.10.2.rpm xyz-linux-version-90.12.13.689.tar.gz xyz-xyz-xyz-13.23.789.0-xyz-xyz.rpm here xyz can string of size(only alpha no numerals) here numbers with('.') version each file. can have 1 common function extract version each of filename? tried function getting big , use of hard coded constants. please suggest simple way we can use re module this. let's define pattern we're trying match. we'll need match string of digits: \d+ these digits may followed either period or hyphen: \d+[\-\.]? and pattern can repeat many times: (\d[\-\.]?)* finally, end @ least 1 digit: (\d+[\-\.]?)*\d+ this pattern can used define function returns version number filename: import re def version_from(filename, pattern=r'(\d+[\-\.]?)*\d+'): match = re.search(pattern, filename) if match: return match.group(0) else: return none now can use function extract versions data provi...

assembly - Machine Cycles for the DJNZ instruction in 8051? 2 or 3? -

so opcodes sheet provided our instructor , searches online tells me djnz instruction takes 2/3 machines cycles execute. can tell me when takes 2 , when takes 3 machine cycles? example codes helpful too!! djnz takes 2 machine cycles

php - Laravel - make json - add to variable new objects -

i have function max-offers maxoffers table: public function maxoffers($id) { $offers = maxoffer::where('article_id', $id)->latest()->get(['id', 'price', 'start', 'user_id']); return $offers; } and this: [{"id":121,"price":67,"start":"sat, 23 apr 2016 00:00:00 +0000","user_id":8},{"id":114,"price":45,"start":"sun, 08 may 2016 00:00:00 +0000","user_id":9},{"id":113,"price":53,"start":"sun, 24 apr 2016 00:00:00 +0000","user_id":8},{"id":111,"price":55,"start":"wed, 01 jun 2016 00:00:00 +0000","user_id":11},{"id":110,"price":53,"start":"fri, 03 jun 2016 00:00:00 +0000","user_id":8},{"id":107,"price":53,"start":"wed, 03 aug 2016 0...

redux - What JavaScript Syntax is this? -

here's sample redux.js reding on github. can please explain syntax used here? var currentlisteners = [] var nextlisteners = currentlisteners .... somefunc() { // this: var listeners = currentlisteners = nextlisteners (var = 0; < listeners.length; i++) { listeners[i]() } ..... } are multi-assignment , statements independent? explain it. missing semicolon @ end of assignment? practice / bad practice? the assignment operator evaluates whatever has been assigned (effectively right operand). side effect, updates value of left operand. a = b = c assigns value of c b, evaluates c, , assigns value of c a, , evaluates c. assignment right-associative -- groups right left. further, semicolons between statements [semi-]optional if each statement on own line (there detail missing here that's covered in link). finally, 1 interesting thing going on here assignment variable declared 1 scope up. functions in javascript 1 way declare new scope. note if functio...

android - React Native - passing refs into NavigationBar routeMapper -

i'm trying open drawer menu when clicking on left button in navigation bar (android). reason doesn't recognise refs when calling opendrawer i error: "undefined not object (evaluating '_this3.refs.drawer')" quite frustrating :/ how can open drawer routemapper? class navigator extends component { constructor(props){ super(props); ... } renderscene(route, nav){ ... } static routemap = drawer => ({ leftbutton(route, navigator, index, navstate){ return ( <touchablehighlight onpress={() => { this.drawer.opendrawer(); }}> <text>menu</text> </touchablehighlight> ); }, rightbutton(route, navigator, index, navstate){ return null; }, title(route, navigator, index, navstate){ return ( <view style={{flex:1}}> <text style={styles.title}>{route.name}</text> </view> ) }, }) render(){ var navigationview = ( ...

pandas - Built-in support for converting column names into values? -

does pandas have built-in support converting this foo bar baz color texture 0 845 758 421 red creamy 1 259 512 405 red crunchy 2 784 304 477 green creamy 3 584 909 505 green crunchy 4 282 756 619 blue creamy 5 251 910 983 blue crunchy to this brand color texture votes 0 foo red creamy 845 1 foo red crunchy 259 2 foo green creamy 784 3 foo green crunchy 584 4 foo blue creamy 282 5 foo blue crunchy 251 6 bar red creamy 758 7 bar red crunchy 512 8 bar green creamy 304 9 bar green crunchy 909 10 bar blue creamy 756 11 bar blue crunchy 910 12 baz red creamy 421 13 baz red crunchy 405 14 baz green creamy 477 15 baz green crunchy 505 16 baz blue creamy 619 17 baz blue crunchy 983 ? in words: some of column headers have been converted values of new column brand , , v...

show select options with jquery on demand -

i have hidden selects , want show options when clickin in previous div fakeinput class this how i'm trying: $('body').on('click','.fakeinput',function(){ console.log(true); $(this).next('select').show().click(); }); $('body').on('blur','select',function(){ $(this).hide(); }); but hide/show select item, wont show select's options what missing here? -edit- fiddle: http://jsfiddle.net/qaayd/2/ i'm not sure best solution, when had similar problem gave select size attribute made open, , gave position: absolute "float" above else. $(this).next('select').attr('size', $(this).next('select').find('option').length) .show(); demo

json - Storing values pulled from server in iOS development -

i newbie ios development. how , store values pull server @ time of authentication? developing app uses login screen. once try login, sends json post api , server responds. unique userid. how , should store unique user id can use pull data across different views? after loggin in, goes different view controller. there global variable or storage can access in view controller? thanks. you can store data in dictionary ,then can use user defaults pass values this nsdata *urldata=[nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error]; nsstring *data=[[nsstring alloc]initwithdata:urldata encoding:nsutf8stringencoding]; nsarray *dataarr=[data jsonvalue]; (int i=0; i<[dataarr count]; i++) { nsdictionary *dict=[dataarr objectatindex:i]; nsstring *codev=[dict valueforkey:@"userid"]; [nsuserdefault standasduserdefault]setobject: dict forkey :@"logindata"]; nslog(); } nslog(@"%@"...

How to reiterate an XML based on a value in the segment tag in xslt? mule? -

i trying reiterate segment based on value inside quantity tag in value of xml. again used increment value of tag. input <?xml version="1.0" encoding="utf-8"?> <stockmovementdatarequest xmlns:a="http://www.edi.com.au/enterpriseservice/" xmlns:p1="urn:ams.com.au:dynamo:3pl:am:sap_am_i_005:stockmovement"> <header> <from>awh</from> <to>sap</to> <unique_id>9abb2454-068d-11e6-8f1b-509e20524153</unique_id> <datetimestamp>2016-04-19t12:30:16.52+10:00</datetimestamp> </header> <stockmovementdata> <serialised_material>yes</serialised_material> <datetime>2016-04-19t12:30:16.52+10:00</datetime> <from_location>0030-0080</from_location> <to_location>actstrbne</to_location> <material>7cagl3g01</material> <serial>700032961 - 700033060 #4</s...

java - server tomcat v8.0 server at localhost failed to start -

i seem have problem web.xml file. every time run apache tomcat 8 server, gives error: server tomcat v8.0 server @ localhost failed start. when removed servlets of xml file, server worked!! web.xml follow: <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>ziyada00191914</display-name> <servlet> <servlet-name>registerservlet</servlet-name> <servlet-class>controllers.registerservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>registerservlet</servlet-name> <url-pattern>/registerservlet</url-pattern> </servlet-mapping> <servlet> <servlet-name>lo...

java - why does "STRING".getBytes() work different according to the Operation System -

Image
i running code below , getting different outcome "some_string".getbytes() depending if in windows or unix. issue happens string (i tried simple abc , same problem. see differences below printed in console. the code below well-tested using java 7. if copy entirely run. additionally, see difference in hexadecimal in 2 images below. first 2 images shows file created in windows. can see hexadecimal values ansi , ebcdic respectively. third image, black one, unix. can see hexadecimal (-c option) , character readable in believe ebcdic. so, straight question is: why such code work different since using java 7 in both case? should check especific property in somewhere? maybe, java in windows default format , in unix another. if so, property must check or settup? unix console: $ ./java -cp /usr/test.jar test.mainframe.read.test.testgetbytes h = 76 - l < wasn't found windows console: h = 60 - < h1 = 69 - e h2 = 79 - o h3 = 77 - m h4 = 62 - > end of me...