Skip to content

Instantly share code, notes, and snippets.

Adam Derewecki derwiki

Block or report user

Report or block derwiki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nextbus_predictions.py
import urllib
import re
URLS = {
'10 Inbound Wisconsin & Madera': 'http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=10&s=6966', # noqa E501
'48 Inbound Wisconsin & 25th': 'http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=48&s=3513', # noqa E501
}
SECONDS_MINUTES_RE = re.compile('seconds="(\d+)" minutes="(\d+)"')
@derwiki
derwiki / threaded_post.rb
Last active Jun 17, 2018
Threaded Net::HTTP::Post service object
View threaded_post.rb
require 'net/http'
README = <<-EOS
posts = [
{
url: 'https://localhost:3000/',
body: '{"status": "OK", "id": 1}'
},
{
url: 'https://localhost:3000/',
@derwiki
derwiki / net_http_multithreaded.rb
Created Jun 16, 2018
Simple script showing effective multithreading with vanilla Ruby
View net_http_multithreaded.rb
# API endpoint that takes ~3.8s to respond
TARGET_URI = 'http://localhost:3000/delay'
SAMPLE_BODY = {}
def post_body!
Net::HTTP.post_form(TARGET_URI, SAMPLE_BODY).body
print ?.
end
1.upto(5).each do |concurrency|
@derwiki
derwiki / backup.sh
Last active Sep 29, 2019
Simple and efficient mirroring of two hard drives using `rsync`.
View backup.sh
# These commands are to be run in different tmux panes to quickly copy the
# contents of one hard drive to another. `rsync` is used for it's robustness,
# interruptibility, and efficiency in incremental updates.
#
# After the initial clone, the same `rsync` command can be run to copy just the
# new/changed files from source to target.
# tmux pane 1
rsync --inplace --whole-file --partial --progress -a /Volumes/amsterdam/ /Volumes/stockholm/
@derwiki
derwiki / dtruss_python_example.py
Created Feb 12, 2018
Example of a decorator that inserts "logs" into `dtruss` output to better help correlate code to syscalls
View dtruss_python_example.py
"""
$ sudo dtruss -f -t open python main.py
18564/0xc29254: open("function-main-start\0", 0x1000000, 0x1B6) = -1 Err#2
18564/0xc29254: open("/anaconda3/lib/python3.6/__pycache__/random.cpython-36.pyc\0", 0x1000000, 0x1B6) = 3 0
18564/0xc29254: open("/anaconda3/lib/python3.6/lib-dynload/math.cpython-36m-darwin.so\0", 0x0, 0x0) = 3 0
18564/0xc29254: open("/anaconda3/lib/python3.6/__pycache__/hashlib.cpython-36.pyc\0", 0x1000000, 0x1B6) = 3 0
18564/0xc29254: open("/anaconda3/lib/python3.6/lib-dynload/_hashlib.cpython-36m-darwin.so\0", 0x0, 0x0) = 3 0
18564/0xc29254: open("/anaconda3/lib/libssl.1.0.0.dylib\0", 0x0, 0x0) = 3 0
18564/0xc29254: open("/anaconda3/lib/libcrypto.1.0.0.dylib\0", 0x0, 0x0) = 3 0
View timecollapse.py
import numpy as np
import cv2
filenames = ["file1.jpg", ... ]
columns = []
for i, filename in enumerate(filenames):
img: np.array = cv2.imread(f"p/{filename}")
height: int = len(img)
width: int = len(img[0])
View derwiki-resume-jan-2018.txt
A D A M D E R E W E C K I
Potrero Hill, San Francisco 740-502-3073
derewecki@gmail.com github.com/derwiki
== P R O F E S S I O N A L E X P E R I E N C E ==
Lyft - San Francisco, CA
Engineer (11/2017 - Present)
* Python/React for Passenger Growth team
Certain Lending - San Francisco, CA
View derwiki-resume-oct-2017.txt
A D A M D E R E W E C K I
Potrero Hill, San Francisco 740-502-3073
derewecki@gmail.com github.com/derwiki
== P R O F E S S I O N A L E X P E R I E N C E ==
Certain Lending - San Francisco, CA
Senior Engineering Contractor (9/2017 - Present)
* Building first version of product in node.js
Coderpad - San Francisco, CA
View fremont-vs-newark.log
Adams-MacBook-Pro:~ adam$ ping speedtest.fremont.linode.com
PING speedtest.fremont.linode.com (50.116.14.9): 56 data bytes
64 bytes from 50.116.14.9: icmp_seq=0 ttl=58 time=7.676 ms
64 bytes from 50.116.14.9: icmp_seq=1 ttl=58 time=7.538 ms
64 bytes from 50.116.14.9: icmp_seq=2 ttl=58 time=8.682 ms
64 bytes from 50.116.14.9: icmp_seq=3 ttl=58 time=7.110 ms
64 bytes from 50.116.14.9: icmp_seq=4 ttl=58 time=6.924 ms
64 bytes from 50.116.14.9: icmp_seq=5 ttl=58 time=7.911 ms
^C
--- speedtest.fremont.linode.com ping statistics ---
@derwiki
derwiki / ghostscript-resolution-comparison
Created Mar 31, 2017
OCRing PDFs using Ghostscript and Google Cloud Vision
View ghostscript-resolution-comparison
$ for x in 100 200 225 250 300 ; do echo $x; gs -sDEVICE=jpeg -DBATCH -dNOPAUSE -r$x -sOutputFile=warren.jpg -dLastPage=1 -dFirstPage=1 warren.pdf 1>/dev/null ; jpeginfo warren.jpg; done
100
warren.jpg 856 x 1400 24bit JFIF N 80332
200
warren.jpg 1712 x 2800 24bit JFIF N 240411
225
warren.jpg 1926 x 3150 24bit JFIF N 284315
250
warren.jpg 2140 x 3500 24bit JFIF N 337588
300
You can’t perform that action at this time.