Skip to content

Instantly share code, notes, and snippets.

Peter Cooper peterc

View GitHub Profile
@peterc
peterc / playmod.rb
Last active Apr 5, 2019
CLI-based module music player that uses VLC
View playmod.rb
#!/usr/bin/env ruby
# playmod: plays module and other audio files in a directory using vlc
#
# on macOS: brew cask install vlc
require 'open3'
require 'io/console'
# Keep a copy of the child VLC process's PID around to terminate it nicely
@peterc
peterc / itemrss.rb
Created Mar 29, 2019
Cooperpress issues to item-based RSS
View itemrss.rb
require 'open-uri'
require 'json'
require 'nokogiri'
require 'rss'
URL = "https://javascriptweekly.com/issues/latest.json"
issue_data = JSON.parse(open(URL).read)
issue = Nokogiri::HTML(issue_data['xml_body'])
@peterc
peterc / subdocuments.md
Last active Mar 2, 2019
Can HTML work as a format for sub-documents?
View subdocuments.md

Let's say I want to create and share a document, such as a blog post that has various components:

  • meta information (author, categories, tags..)
  • a title
  • body content
  • some custom styling
  • some custom scripting

An HTML document seems like a great way to portably and easily package all of these things into one place:

@peterc
peterc / s4d.rb
Last active Feb 27, 2019
Turns a11y-style text back into English. Or tries to, anyway.
View s4d.rb
# ruby s4d.rb "h3o w3d" 5
text = ARGV.first || "y1u a5t p1l? j2t w4d to s1y hi"
times = (ARGV[1] || 1).to_i
words = File.readlines('/usr/share/dict/words')
.map(&:downcase)
.map(&:chomp)
times.times do
@peterc
peterc / get_sizes.sql
Last active Mar 5, 2019
Get the size of different tables and other relations in a PostgreSQL database
View get_sizes.sql
SELECT
schema_name, rel_name, table_size,
pg_size_pretty(table_size) AS size
FROM (
SELECT
nspname AS schema_name,
relname AS rel_name,
pg_table_size(pg_class.oid) AS table_size
FROM pg_class, pg_namespace
WHERE pg_class.relnamespace = pg_namespace.oid
@peterc
peterc / pg_available_extensions.txt
Created Feb 14, 2019
Which Postgres extensions are available on DigitalOcean's new managed PostgreSQL service?
View pg_available_extensions.txt
defaultdb=> SELECT * FROM pg_available_extensions;
name | default_version | installed_version | comment
------------------------------+-----------------+-------------------+---------------------------------------------------------------------------------------------------------------------
aiven_extras | 1.0.2 | | aiven_extras
plpgsql | 1.0 | 1.0 | PL/pgSQL procedural language
btree_gist | 1.5 | | support for indexing common datatypes in GiST
tcn | 1.0 | | Triggered change notifications
seg | 1.3 | | data type for representing line segments or floating-point intervals
pgrowlocks | 1.2 |
@peterc
peterc / IDEHISTORY.TXT
Last active Feb 9, 2019
A list of seminal or otherwise notable IDEs or "development environments" by year.
View IDEHISTORY.TXT
1963 - JOSS (JOHNNIAC Open Shop System)
1964 - Dartmouth BASIC
1966 - CAL for Project Genie Time Sharing System
1974 - OLIVER by Kenneth Dakin
1975 - Maestro I
1980 - dBase
1980 - Smalltalk
1981 - IBM Advanced BASIC (BASICA)
1983 - IBM Logo
1983 - GW-BASIC
@peterc
peterc / serverless_rss_validity.js
Last active Aug 28, 2018
An ES6 variant of a serverless function written in Python..
View serverless_rss_validity.js
const fetch = require('node-fetch');
const parseString = require('xml2js').parseString;
const util = require('util');
const hostnames = ["react.statuscode.com", "javascriptweekly.com", "nodeweekly.com"];
function checkValidity(url) {
return fetch(url)
.then(res => res.text())
.then(resultText => promisify(parseString)(resultText))
@peterc
peterc / serverless_rss_validity.py
Created Aug 28, 2018
AWS Lambda function to check RSS feed validity using W3C's API
View serverless_rss_validity.py
import json
import requests
import os
import sys
from xml.dom.minidom import parse, parseString
hostnames = ["react.statuscode.com", "javascriptweekly.com", "nodeweekly.com"]
def checkValidity(url):
response = requests.get(url)
@peterc
peterc / notes.txt
Created Jun 7, 2018
peterc-devxcon-talk-notes.txt
View notes.txt
INTRO
- royal wedding, michael curry
- move fast, take notes
- i am..
- send newsletters 410k
- spammer?
- 2 letters (un)solicited vs solicited
- things in common to get emails delivered
- ton of data of what devs engage with
- experience of what doesn't matter
You can’t perform that action at this time.