Posts

javascript - can't push object into array -

Image
this question has answer here: how return response asynchronous call? 21 answers i'm missing basic. i'm grabbing data api , trying push array of json objects. api works fine , i'm getting data, not seem pushed array. can't seem console log of data parameters. here jquery code: var jsonarr =[] var jsondata = {} $.get(apigetlist,function(r) { $(r).each(function(i) { $.get(api_checklist_start + r[i].id +api_checklist_end ,function(s){ $(s[0].checkitems).each(function(k){ jsondata = {"item": [k], "task": r[i].name, "name": s[0].checkitems[k].name, "state": s[0].checkitems[k].state } jsonarr.push(jsondata) }) }) }) ...

javascript - JSHint reports undefined global despite `globals` setting -

jshint reporting undefined variables despite globals setting. here minimal example: file.js: // jshint esversion: 6, node: true // globals intl 'use strict'; let percent = new intl.numberformat("en-us", { style: "percent" }).format; running jshint file.js index2.js: line 5, col 19, 'intl' not defined. 1 error any idea wrong configuration? note there no .jshintrc , configuration jshint comments @ beginning of file.js . to honest, never saw use of simple single-line comment // configure jshint/globals. try with multi-line comment style, /* globals my_lib: false */ per defined in: http://jshint.com/docs/

Python Selenium - How do you click on every row element for column of web table? -

this may 2 part question forgive me if isn't written: i'm trying webdriver go nba team stats page: http://stats.nba.com/teams/traditional/#!?sort=w_pct&dir=-1 table image reference and click linked fgm numbers in table. should open new tab in background. far i'm lost how should approaching this. i'm thinking: i need way count rows then need tell webdriver loop/click through elements in fgm column row count i'm sure can data beautifulsoup i'm trying practice selenium , working tables/links can vary in length. leads appreciated. thanks! python example: from selenium import webdriver selenium.webdriver import actionchains web_driver = webdriver.firefox() web_driver.get("http://stats.nba.com/teams/traditional/#!?sort=w_pct&dir=-1") actions = actionchains(driver) team_links = webdriver.find_elements_by_xpath("//body//td[contains(@class, 'first')]/a") link in team_links: actions.key_down(keys.con...

ruby on rails - Parallax.js images render locally but not in production on Heroku -

disambiguation: there 2 popular plugins called "parallax.js". i'm referring this one. in development , parallaxed , non-parallaxed images work in erb template. in production (on heroku), non-parallaxed images rendering. suspect problem rails asset pipeline, recommended fixes haven't worked (see below). the parallax.js docs suggest following usage: <div class="parallax-window" data-parallax="scroll" data-image-src="/path/to/image.jpg"></div> but in order use asset pipeline, i've changed to: <div class="parallax-window" data-parallax="scroll" data-image-src="<%= image_url('image_file.jpeg') %>"></div> (in addition image_url , i've tried image_tag , image_path .) as mentioned, works fine on local machine. but in production, chrome browser console logs errors missing images: failed load resource: server responded status of 404 (not found) so...

r - dplyr group_by and iterative loop calculation -

i trying perform iterative calculation on grouped data depend on 2 previous elements within group. toy example: set.seed(100) df = data.table(id = c(rep("a_index1",9)), year = c(2001:2005, 2001:2004), price = c(na, na, 10, na, na, 15, na, 13, na), index = sample(seq(1, 3, = 0.5), size = 9, replace = true)) id year price index r> df 1: a_index1 2001 na 1.5 2: a_index1 2002 na 1.5 3: a_index1 2003 10 2.0 4: a_index1 2004 na 1.0 5: a_index1 2005 na 2.0 6: a_index1 2006 15 2.0 7: a_index1 2007 na 3.0 8: a_index1 2008 13 1.5 9: a_index1 2009 na 2.0 the objective fill missing prices using last available price , index adjust. have loop performs these calculations, trying vectorize using dplyr . my logic defined in below loop: df$price_adj = df$price (i in 2:nrow(df)) { if (is.na(df$price[i])) { df$price_adj[i] = round(df$price_adj[i-1] * df$index[i] / df$index[i-1], 2) } } ...

flask - python importlib no module named -

i using flask , have following structure <root> manage_server.py cas <directory> --- __init__.py --- routes.py --- models.py --- templates <directory> --- static <directory> --- formmodules <directory> ------ __init__.py ------ baseformmodule.py ------ interview.py in routes.py, i'm trying create instance of interview class in interview module, so my_module = "interview" module = importlib.import_module('formmodules."+my_module) i error here says importerror: no module named formmodules.interview some info init files: /cas/formmodules/__init__.py empty /cas/__init__.py initialize flask app. let me know if helpful know contents of of these files. this 1 of classical relative vs absolute import problems. formmodules exists relative cas , import_module absolute import (as from __future__ import absolute_imports ). since formmodules cannot found via sys.path , import fails. one way fix use relative im...

csv - How can I indicate the entry id in the Logstash script? -

i have following mapping in elasticsearch: put /myindex { "mappings": { "regions": { "_all": { "enabled": false }, "properties": { "regionid": {"type": "keyword"}, "seasons": { "properties": { "season-type": { "type": "keyword" }, "period": { "properties": { "start-day": { "type": "integer" }, "start-month": { "type": "integer" }, "end-day": { "type": "integer" }, "end-month": { "type": "integer" } } } } }, "autonomous_com...