Skip to content

Instantly share code, notes, and snippets.

View j-v's full-sized avatar
🙃
futzing about

Jon Volkmar j-v

🙃
futzing about
  • Seattle
View GitHub Profile
@j-v
j-v / arrOpsPerf.js
Created May 12, 2020 03:44
array operations performance
var arrsize=100000
// time cost for array constructing
var i = 0
var ar = [] // literal notation
var arr = new Array(arrsize) // new length defined
i = 0
console.time("Literal notation with assigning directly")
while(i<arrsize){
@j-v
j-v / my.test.ts
Created August 9, 2019 18:27
Mock lodash debounce with Jest in Typescript
import * as _ from 'lodash';
// Mock out lodash debounce implementation, so it calls the debounced method immediately
jest.spyOn(_, 'debounce').mockImplementation(
jest.fn((fn: any) => {
// fn.cancel = jest.fn();
// fn.flush = jest.fn();
return fn as (((...args: any[]) => any) & _.Cancelable);
}));
import controlP5.*;
ControlP5 controlP5;
void setup() {
// ....
new EndlessKnob(controlP5, "knob1").setRange(0,360)
.setPosition(70, 120)
@j-v
j-v / add_parent_dir.py
Created September 17, 2012 01:28
Add parent directory to path
# Add parent directory to path, to allow script's access to modules
abs_path = os.path.abspath(os.path.dirname(__file__))
parent_dir = os.path.join(abs_path, os.path.pardir)
sys.path.insert(0, parent_dir)
@j-v
j-v / download-file.PS1
Created September 17, 2012 00:29
Script to download a file from PowerShell
param($url, $filename)
$webclient = New-Object System.Net.WebClient
$filepath = "$pwd\$filename"
$webclient.DownloadFile($url,$filepath)
echo "Saved $filename"
@j-v
j-v / Cmd.vim
Created September 16, 2012 23:11
Vim command to run external commands asynchronously (Windows)
" Cmd command to run external commands asynchronously (Windows)
" e.g. :Cmd python -m unittests discover
command -nargs=+ Cmd :!start cmd /c <q-args> & pause
@j-v
j-v / pydoc.bat
Created September 16, 2012 18:26
Put this in a folder in the system PATH to enable pydoc from command line (Windows)
@python c:\Python27\lib\pydoc.py %*
@j-v
j-v / fixmyindent.vim
Created September 16, 2012 16:11
Fix my screwed up Python indentation in vim
" initially i was using 3-space (shiftwidth=3) indentation with noexpandtab, and tabstop=8, the default
" this switches it to proper 4-space indentation with expandtab
" convert tabs to spaces
set tabstop=8
set shiftwidth=3
set expandtab
retab
" convert spaces to tabs