Posts

python - How do I repeatedly shift and pad elements in a list to get a list of lists? -

i have list a = [1, 2, 3, ..., n] , want repeatedly shift list list of lists. first row should a , second row [2, 3, 4, ...] , third row [3, 4, 5, ...] , until last row [n, 0, 0, ...] . missing elements in last columns should zeros. trying put them individually, n >= 100 manually padding zeros take long. how do this? edit same question numpy arrays, have. >>> = [1, 2, 3, 4] >>> [ a[i:] + i*[0] in range(len(a))] [[1, 2, 3, 4], [2, 3, 4, 0], [3, 4, 0, 0], [4, 0, 0, 0]] how works to i'th shifted list, can use: a[i:] + i*[0] . list comprehension repeatedly i's need. using numpy + means different numpy arrays normal python lists. consequently, above code needs tweaks adapt numpy: >>> import numpy np >>> = np.arange(1, 5) >>> [ np.concatenate((a[i:], np.zeros(i))) in range(len(a))] [array([1, 2, 3, 4]), array([2, 3, 4, 0]), array([3, 4, 0, 0]), array([4, 0, 0, 0])] if want final result numpy array: ...

rubymotion - How to use ProMotion-Menu? -

Image
i did new project code shown in promotion-menu's readme . have : # app_delegate.rb class appdelegate < pm::delegate def on_load(app, options) @menu = open menudrawer end def show_menu @menu.show :left end end #menu_drawer.rb class menudrawer < pm::menu::drawer def setup self.center = homescreen.new(nav_bar: true) self.left = navigationscreen self.to_show = [:pan_bezel, :pan_nav_bar] self.transition_animation = :swinging_door self.max_left_width = 250 self.shadow = false end end #navigation_screen.rb class navigationscreen < promotion::tablescreen def table_data [{ title: nil, cells: [{ title: 'overwrite method', action: :swap_center_controller, arguments: homescreen }] }] end def swap_center_controller(screen_class) app_delegate.menu.center_controller = screen_class end end my app running there no sidebar can see here : did miss ? n...

how to insert specific json into sqlite database using python 3 -

using python 3, want download api data, returned json, , want insert specific (columns or fields or whatever?) sqlite database. so, here's i've got , issues have: using python's request module: ##### import modules import sqlite3 import requests import json headers = { 'authorization' : 'ujbosdlknfsodiflksdonosb4aa=', 'accept' : 'application/json' } r = requests.get( 'https://api.lendingclub.com/api/investor/v1/accounts/94837758/detailednotes', headers=headers ) okay, first issue how requested json data (a dictionary?) python can use. that... jason.loads(r.text) then create table want insert specific data: curs.execute('''create table data( loanid integer not null, noteamount real not null, )''') no problem there...but now, though json data looks (although there hundreds of records)... { "mynotes": [ { "loanid":11111, "noteid":22222, "orde...

configuration - Adding skip-grant-tables to MySQL my.ini does not seem to be working -

i trying reset lost root@localhost password, explained in this question . adding line skip-grant-tables directly underneath [wampmysqld] / [mysqld] known way gain access in order reset passwords, in case not doing anything. after making sure mysql not running, editing file, restarting , opening mysql console, password prompt appears, stuck. what possibly overlooking? my stack wamp 2.5, mysql 5.6.17. my my.ini file looks this: # example mysql config file medium systems. # # system little memory (32m - 64m) mysql plays # important part, or systems 128m mysql used # other programs (such web server) # # can copy file # /etc/my.cnf set global options, # mysql-data-dir/my.cnf set server-specific options (in # installation directory c:\mysql\data) or # ~/.my.cnf set user-specific options. # # in file, can use long options program supports. # if want know options program supports, run program # "--help" option. # following options passed mysql clients [client] #p...

java - ByteBuddy fails when trying to redefine sun.reflect.GeneratedMethodAccessor1 -

driven curiosity, tried export bytecode of generatedmethodaccessor1 (generated jvm when using reflection). i try bytecode of class following way: public class methodextractor { public static void main(string[] args) throws exception { exampleclass example = new exampleclass(); method examplemethod = exampleclass.class .getdeclaredmethod("examplemethod"); examplemethod.setaccessible(true); int rndsum = 0; (int = 0; < 20; i++) { rndsum += (integer) examplemethod.invoke(example); } field field = method.class.getdeclaredfield("methodaccessor"); field.setaccessible(true); object methodaccessor = field.get(examplemethod); field delegate = methodaccessor.getclass().getdeclaredfield("delegate"); delegate.setaccessible(true); object gma = delegate.get(methodaccessor); bytebuddyagent.installonopenjdk(); try ...

excel - SUMIFS based on name and date range -

i'm trying formula sum values on cells based on 2 criteria, date range , name. column contains date, column b contains text, column c contains employee name, need sum on different ws values column e "qty" based on criteria column h "date" , column c "employee name", column d contains text, column e contains number (this 1 need add up), column f contains employee #, column g contains number , column h contains date. rows go 2 100. i've tried vlookup find "employee name" , sumifs date range i've been unable combine both formulas desired result. as example need sum "qty" employee "jones, mary" during month of march , come result = 5. with march 1, 2015 in a1, jones, mary in b1 , 'different ws' called sheet2, try, =sumifs('sheet2'!e:e, 'sheet2'!f:f, b1, 'sheet2'!h:h, ">="&a1, 'sheet2'!h:h, "<"&edate(a1, 1))

javascript - Angular ui-router is not instantiated, giving an inject module error -

hello have weird problem angular ui-router. renew webapp , want angular. have heard lot of things ui-router not getting work. following tutorial on how set views, error: uncaught error: [$injector:modulerr] failed instantiate module fqmapp due to: typeerror: undefined not function i using cdn's import angular , ui-router. exact code: <!doctype html> <html ng-app="fqmapp"> <head> <script src="https://code.angularjs.org/1.3.9/angular.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/angular-ui-router.min.js"></script> <script src="app.js"></script> </head> <body> <div ui-view> </div> <a ui-sref="state1">state 1</a> <a ui-sref="state2">state 2</a> </body> </html> js "use str...