Skip to content

Instantly share code, notes, and snippets.

View johnnyb's full-sized avatar

Jonathan Bartlett johnnyb

View GitHub Profile
import * as ZXing from "html5-qrcode/third_party/zxing-js.umd"
export function performMonkeyPatches() {
console.log("Monkey patching")
// Monkey-patch based on https://github.com/zxing-js/library/pull/420/commits/7644e279df9fd2e754e044c25f450576d2878e45
const oldFunc = ZXing.HTMLCanvasElementLuminanceSource.toGrayscaleBuffer;
let inverterToggle = true;
ZXing.HTMLCanvasElementLuminanceSource.toGrayscaleBuffer = function(imagebuffer, width, height) {
const grayscaleBuffer = oldFunc(imagebuffer, width, height);
@johnnyb
johnnyb / test.go
Created November 14, 2020 16:01
Go Testing
var GetDatabaseInfo = func(indata string) string {
// Do database stuff here
}
func TestRequest(t *testing.T) {
// Replace our database access function here
GetDatabaseInfo = func(indata string) {
return "testingresult"
}
@johnnyb
johnnyb / object7.scm
Last active April 23, 2018 20:53
This works with "this"
(define-syntax class
(syntax-rules (attr method this)
(
(class class-name
((attr attr-name initial-val) ...)
((method (meth-name meth-arg ...) body ...) ...))
(define class-name
(let
(
(result (quote (lambda ()
@johnnyb
johnnyb / object.scm
Created April 23, 2018 12:27
Attempt at object-oriented system
(define-syntax oo-class
(syntax-rules (attr method this)
(
(oo-class class-name
((attr attr-name initial-val) ...)
((method (meth-name meth-arg ...) body ...) ...))
(define class-name
(lambda ()
(letrec
(
let req = Stripe.paymentRequestWithMerchantIdentifier("HIDDEN")
req?.requiredBillingAddressFields = PKAddressField.PostalAddress
req?.requiredShippingAddressFields = PKAddressField.None
let summary = PKPaymentSummaryItem(label: "Total", amount: currentOrder!.total())
req?.paymentSummaryItems = [summary]
req?.supportedNetworks = [PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkDiscover]
let auth = PKPaymentAuthorizationViewController(paymentRequest: req!)
auth.delegate = self
self.presentViewController(auth, animated: true, completion: {
})