Skip to content

Instantly share code, notes, and snippets.

View straversi's full-sized avatar
🌚
🌝

Steven Traversi straversi

🌚
🌝
View GitHub Profile
// First, install one dependency:
// npm install lit
//
// Then, include this file on your page:
// import './path/to/change-search-bar'
//
// Then, you can use the <change-search-bar> component like any
// HTML element:
// <change-search-bar></change-search-bar>
//
@straversi
straversi / make-donation.php
Created February 7, 2022 19:41
How to make a donation in PHP
<?php
function make_donation() {
// TODO: Set these values.
// `amount` The amount of the donation in cents.
// `public_key` Get this from https://api.getchange.io/developers. Test key starts with pk_test, Prod key starts with pk_live.
// `secret_key` Get this from https://api.getchange.io/developers. Test key starts with sk_test, Prod key starts with sk_live.
// `nonprofit_id` Get this from https://api.getchange.io/nonprofits. When you search a nonprofit, you can see its nonprofit_id.
$amount = 500;
$public_key = '';
$secret_key = '';
@straversi
straversi / variable_font_grid.py
Last active November 21, 2019 11:52
Draw a variable font grid with DrawBot.
# Draw a grid of characters, changing variable font axes along
# the X and Y.
# Set the uppercased CONSTANT values to customize the output.
# For use with DrawBot drawbot.com
CONTENT = "A"
OUT_FILE_NAME = "./result.svg"
COLUMNS = 8
ROWS = 8
@straversi
straversi / mask_drawer.py
Created October 5, 2016 06:39
Mask Drawer
import numpy as np
import cv2
import sys
# ============================================================================
base_img = cv2.imread(sys.argv[1])
CANVAS_SIZE = base_img.shape
FINAL_LINE_COLOR = (255, 255, 255)
@straversi
straversi / make_change.py
Last active October 13, 2015 07:16
Making change, recursively and iteratively.
# Use make_change_iter for the much better performing (space-wise) solution!
import collections
def make_change(amount, coins):
"""
Return the minimum number of coins that sum AMOUNT using coin values COINS.
-1 if no solution exists. Recursive with memoization.
"""
@straversi
straversi / bookmarklet.js
Created July 28, 2015 18:50
remove sidebar on reddit
javascript:(function()%7Bdocument.getElementsByClassName(%27side%27)%5B0%5D.style.display%3D%27none%27%3B%7D)()%3B