Skip to content

Instantly share code, notes, and snippets.

peterc / subreply.css
Created Jul 13, 2020
Format subreply more nicely - use with an extension like Stylish
View subreply.css
body {
font-family: "Menlo", Monaco, Consolas, monospace;
font-size: 16px;
line-height: 24px;
.container {
grid-template-columns: 2fr minmax(200px, 1fr) minmax(600px, 3fr) 3fr;
peterc / form-to-fetch.js
Created Jun 29, 2020
Basic implementation of turning a form into an Ajax form using Fetch API
View form-to-fetch.js
// this is very much for my specific use case
// but the general principles work anywhere
let forms = document.querySelectorAll('FORM.subscribe');
forms.forEach(form => {
form.onsubmit = function(e) {
let formData = new FormData(;
let output ='button');
peterc / Gemfile
Created Jun 25, 2020 — forked from dhh/Gemfile
HEY's Gemfile
View Gemfile
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
peterc /
Created Jun 15, 2020
Get a heads up when a new item hits the Hacker News front page
# 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("")
assert(res.status_code == 200)
peterc / rss-to-s3.rb
Created May 23, 2020
RSS to S3 Ruby Lambda Function
View rss-to-s3.rb
require 'json'
require 'aws-sdk-s3'
require 'open-uri'
# Ideally put these in environment variables
# but since this is just for us, who cares.
def do_newsletters
peterc / pick_a_winner.rb
Created May 2, 2020
Given a list of names, pick a winner at the terminal in a visually appealing way
View pick_a_winner.rb
require 'curses'
include Curses
users = %w{
put twitter handles of people who enter here
peterc / cdown.rb
Last active Apr 29, 2020
Basic Countdown numbers solver in Ruby
View cdown.rb
# Basic Countdown numbers solver
# Principally ported from Jake Archibald's JS solution
# at,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)
peterc / zapier-gmail.js
Created Apr 10, 2020
Using Zapier to check emails on Gmail and then notify us on Slack
View zapier-gmail.js
// Using Zapier to check emails on Gmail and then notify us on Slack
const slackURL = "";
let mb = inputData.b;
let folder = "Unknown";
if (mb.includes('CATEGORY_FORUMS')) {
folder = "Inbox (Forums)";
if (mb.includes('CATEGORY_PERSONAL')) {
peterc / hn-title-checker.rb
Created Nov 24, 2019
Monitors Hacker News for changing titles
View hn-title-checker.rb
require 'aws-sdk'
require 'open-uri'
require 'json'
require 'pg'
require 'dotenv'
# .env to contain:
peterc / stallman.txt
Created Sep 19, 2019
Stallman's "info pack"
View stallman.txt
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
You can’t perform that action at this time.