Posts

How to measure distance covered across patches in NetLogo -

i have model setup in netlogo simulation space gis map 20 km radius constructed. the max xcor , ycor set 20 , min xcor , ycor -20. gives torus of 41 x 41. i have agents @ centre of map @ patch 0 0 , want maximum distance can cover 20 km i.e. extent of gis map. ask turtles [ set heading 360 fd 1 ] am right in saying if iterate code 20 times they'll @ centre of last patch (xcor 0 ycor 20) isn't quite 20 km? if that's right, how code agents move appropriate distance. feel i'm trying square circle here. i should can add following line patch scale comes out @ 975.6 set patch-scale (item 1 gis:world-envelope - item 0 gis:world-envelope ) / world-width if multiply patch scale world width 40000 looks right given radius of circle 20 km. thanks globals [km] test ca let extent 40 ;desired world-width, in kilometers set km (world-width / extent) crt 1 [set heading 360] ask turtle 0 [fd (20 * km)] end

Extract Columns from html using Python (Beautifulsoup) -

i need extract info page - http://www.investing.com/currencies/usd-brl-historical-data . need date, price, open, high, low,change %. i`m new python got stuck @ step: import requests bs4 import beautifulsoup datetime import datetime url='http://www.investing.com/currencies/usd-brl-historical-data' r = requests.get(url) soup=beautifulsoup(r.content,'lxml') g_data = soup.find_all('table', {'class':'gentbl closedtbl historicaltbl'}) d=[] item in g_data: table_values = item.find_all('tr') n=len(table_values)-1 n in range(n): k = (item.find_all('td', {'class':'first left bold nowrap'})[n].text) print(item.find_all('td', {'class':'first left bold nowrap'})[n].text) here have several problems: column price can de tagged or . how can specify want items tagged class = 'redfont' or/and 'greenfont'? . change % can have class redfont , greenfont. other columns ta...

javascript - How does the spread operator in ES6 JS work as a function argument? -

ok, i'm trying understand how new spread works function parameter. imagine function unknown number of parameters , adds them together. let addnums = ...a => a.reduce ((a,b) => a+b); this function works. so, what's problem? here's observations, followed problem: the spread operator function parameter / argument seems designed 'spread' array of values separate arguments: based on research i've done, spread operator can used pass arrays functions not accept arrays arguments standard, e.g. array.prototype.push(), without having use apply : var x = []; var y = [1,2,3]; // array.push(arg1,arg2,...) requires separate arguments possible: x.push(...y); // 'spreads' 'y' separate arguments: x.push (arg1,arg2,...) but array passed push in case needs declared/defined beforehand (in case y ) this confirmed looking @ length of arguments object inside function if use addnums(1,2,3,4) , arguments.length still == 4. so, seems funct...

regex - Python regular expression to replace everything but specific words -

i trying following with regular expression : import re x = re.compile('[^(going)|^(you)]') # words replace s = 'i going home now, thank you.' # string modify print re.sub(x, '_', s) the result is: '_____going__o___no______n__you_' the result want is: '_____going_________________you_' since ^ can used inside brackets [] , result makes sense, i'm not sure how else go it. i tried '([^g][^o][^i][^n][^g])|([^y][^o][^u])' yields '_g_h___y_' . not quite easy first appears, since there no "not" in res except ^ inside [ ] matches 1 character (as found). here solution: import re def subit(m): stuff, word = m.groups() return ("_" * len(stuff)) + word s = 'i going home now, thank you.' # string modify print re.sub(r'(.+?)(going|you|$)', subit, s) gives: _____going_________________you_ to explain. re (i use raw strings) matches 1 or more of character...

jquery - Execution order of if else issue -

i have function, part of works non-correct. what need - 1) if window width < 768 (do smth) 2) if window width = 768 (do smth) 3) else (do smth) there part of function var windowwid = $(window).width(); if ($poselok.length > 0) { if (windowwid === 768) { var offset = 0.05; } if (windowwid < 768) { var offset = 0 - $el_full.offset().left - el_margin_left; } else { var offset = 0 - $el_full.offset().left + $sideleft + 15; } } else { var offset = 0 - $el_full.offset().left - el_margin_left; }; without if (windowwid < 768) condition if (windowwid === 768) works, - doesn't. i tried if (windowwid < 767) , if (windowwid <= 767) separate if nothing. i tried replace if , (windowwid === 768) works if (windowwid < 768) works incorrect. i think have mistake in execution order, don't know how fix it. help please! if (condition1) { block of code executed if condition1 true } ...

amazon web services - How to reuse a string block in swagger -

i writing swagger file aws api gateway. have use block of text integration every single endpoint. how single end-point looking currently '/products/{productid}': get: tags: - product summary: detailed information product consumes: - application/json produces: - application/json parameters: - name: productid in: path required: true type: string responses: '200': description: 200 response schema: type: array items: $ref: '#/definitions/product' '404': description: product not found schema: type: array items: $ref: '#/definitions/product' x-amazon-apigateway-integration: requesttemplates: application/json: > ## see http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html ...

SAP HANA - Activation warning: Could not found Naming Convention in table _SYS_BI.BIMC_CONFIGURATION for -

when activating procedure got following warning: could not found naming convention in table _sys_bi.bimc_configuration attributeview,analyticview,calculationview,procedure,analytic privileges,decision table . so made following inserts: insert _sys_bi.bimc_configuration values ('naming_convention_rule_analyticview', 'an_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_attributeview', 'at_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_calculationview', 'ca_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_procedure', 'sp_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_analytic_privileges', 'ap_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_decision_table', 'dt_'); after still warning: could not found naming convention in table _sys_bi.bimc_configuration . any ideas how...