Skip to content

Instantly share code, notes, and snippets.

# usage: python srtfinder.py filename.rst your quote
# requires https://pypi.org/project/srt/
# can be memory optimized by discarding failed 'read' chars and resetting 'widx'
import srt
import sys
print(sys.argv[1])
with open(sys.argv[1], "r") as f: data = f.read()
p = list(srt.parse(data))
@rickwierenga
rickwierenga / bisec.py
Last active October 3, 2021 12:57
We had to approximate the root of x^3+3x-2 for calc1 on an interval of size 1/8, I wrote this program to find it on an interval of size 1/(2^10000). It only takes a few minutes to run.
def gcd(x: int, y: int):
while(y):
x, y = y, x % y
return x
def frac(a: int, b: int):
return '\\seqsplit{' + str(a//gcd(a, b)) + '\\div' + str(b//gcd(a,b)) + '}'
def func(a, n):
""" x=a/2**n, f(x) = x^3+3x-2 """

Keybase proof

I hereby claim:

  • I am rickwierenga on github.
  • I am rickwierenga (https://keybase.io/rickwierenga) on keybase.
  • I have a public key ASAkU1wNIrNLPYFbhssi8Vh5kkrEOrxsapKJrH9Hfh2mLAo

To claim this, I am signing this object:

:set number
set expandtab
set shiftwidth=4
set softtabstop=4
if &compatible
set nocompatible
endif
set runtimepath+=/Users/rickwierenga/.vim/bundle/neobundle.vim/
// MARK: - Vision
func processClassification(for request: VNRequest) {
// TODO: Extract payload
}
lazy var detectBarcodeRequest: VNDetectBarcodesRequest = {
return VNDetectBarcodesRequest(completionHandler: { (request, error) in
guard error == nil else {
self.showAlert(withTitle: "Barcode Error", message: error!.localizedDescription)
return
}
self.processClassification(for: request)
})
}()
import Vision
view.subviews.compactMap({ $0 as? UITextField }).forEach { textfield in
if let text = textfield.text, text.isEmpty {
textfield.backgroundColor = .yellow // highlight
} else {
textfield.backgroundColor = .white // default
}
}
import UIKit
extension UIImage {
static let home = UIImage(named: "Home")
static let bell = UIImage(named: "Bell")
}