This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll("FORM[method='post']").forEach(form => { | |
form.onsubmit = function(e) { | |
e.preventDefault(); | |
let formData = new FormData(e.target); | |
let output = e.target.querySelector('button'); | |
fetch(e.target.action, { method: 'post', body: formData }) | |
.then( res => { | |
console.log("Happy days"); | |
}) | |
.catch( err => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby '2.7.1' | |
gem 'rails', github: 'rails/rails' | |
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
# Action Text | |
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
gem 'okra', github: 'basecamp/okra' | |
# Drivers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a heads up when a new item hits the Hacker News front page | |
import requests | |
import sys | |
from time import sleep | |
from random import randint | |
def fetchItems(): | |
res = requests.get("https://hacker-news.firebaseio.com/v0/topstories.json") | |
assert(res.status_code == 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'aws-sdk-s3' | |
require 'open-uri' | |
# Ideally put these in environment variables | |
# but since this is just for us, who cares. | |
BUCKET = "RETRACTED" | |
REGION = "RETRACTED" | |
def do_newsletters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'curses' | |
include Curses | |
init_screen | |
curs_set(0) | |
users = %w{ | |
put twitter handles of people who enter here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic Countdown numbers solver | |
# Principally ported from Jake Archibald's JS solution | |
# at https://jsbin.com/yimejin/4/edit?js,console | |
def solve(nums, target) | |
bs = nil | |
nums.sort.reverse.combination(2).each do |i, j| | |
%I{+ - * /}.each do |op| | |
next if op == :* && (i == 1 || j == 1) | |
next if op == :/ && (j == 1 || i % j != 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using Zapier to check emails on Gmail and then notify us on Slack | |
const slackURL = "https://hooks.slack.com/services/XXXXXXXXXXXXX"; | |
let mb = inputData.b; | |
let folder = "Unknown"; | |
if (mb.includes('CATEGORY_FORUMS')) { | |
folder = "Inbox (Forums)"; | |
} | |
if (mb.includes('CATEGORY_PERSONAL')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
require 'open-uri' | |
require 'json' | |
require 'pg' | |
require 'dotenv' | |
Dotenv.load | |
# .env to contain: | |
# POSTGRES_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's the info packet about my speeches. This information is | |
essential for planning my visit and speech. Please forward | |
it to anyone who is interested in organizing a speech for me. | |
Please discuss with me what the topic of this speech should be. | |
We need to decide it together. | |
My talks are not technical. The topics of free software, copyright vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'open-uri' | |
URL = "https://ip-ranges.amazonaws.com/ip-ranges.json" | |
REGION = "us-east" | |
SERVICE = "EC2" | |
j = JSON.parse(open(URL).read) | |
j['prefixes'].select { |k| k['region'].start_with?(REGION) && k['service'] == SERVICE }.each do |l| |