Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
@Aupajo
Aupajo / gist:452734
Created June 25, 2010 11:25
Adrian Lamo logs.
Adrian Lamo Logs
These logs originally appeared on pastebin.ca as "The Truth About Adrian Lamo" and have been confirmed by Nadim as genuine.
The salient facts contained in these logs is that a) Lamo got "Hackers Wanted" leaked despite denying that he had anything to do with it and b) he was taken into psychiatric care for a drug problem rather than for "Aspergers" as he claimed. If you read http://www.wired.com/threatlevel/2010/05/lamo/ along with these logs the story makes a lot more sense.
Cops don't institutionalize people for acting weird, RE: the homeless.
COP #1: "Worst case of Aspergers I've ever seen!"
COP #2: "Sweet jesus... I'm calling for an ambulance now."
@Aupajo
Aupajo / jose-generate-key-export-jwk-sign-decode.js
Last active October 13, 2023 01:44
Using Jose to generate a secret, JWKS, sign a JWT, and verify (useful for testing)
import * as jose from "jose";
const ONE_HOUR_FROM_NOW = Math.floor(Date.now() / 1000) + 60 * 60;
// Mock this, for example
const jwt = {
// Standard claims
sub: "https://login.salesforce.com/id/00Dxx0000001gPLEAY/005xx000001Sw9AAAS",
iss: "urn:example:issuer",
aud: "urn:example:audience",
@Aupajo
Aupajo / 01.1.lifecycle.rb
Last active August 25, 2023 19:26
Sockets in Ruby
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
@Aupajo
Aupajo / gist:4133515
Last active June 9, 2023 02:41
A few of my favourite Git settings
# Colours
git config --global color.status auto
git config --global color.branch auto
git config --global color.diff auto
# Short-hand aliases
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
@Aupajo
Aupajo / list_of_countries.rb
Created April 19, 2010 05:30
List of countries in a handy Ruby array
COUNTRIES = [
"Afghanistan",
"Aland Islands",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
"Antarctica",
@Aupajo
Aupajo / major_languages.rb
Created April 19, 2010 05:29
Major spoken languages (over 10 million speakers), in order, in a handy Ruby array.
# Major spoken languages (over 1 million speakers), in order.
# List sourced from http://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers
LANGUAGES = [
"Mandarin Chinese",
"Spanish",
"English",
"Hindi/Urdu",
"Arabic",
"Bengali",

The Story of NPM and Yarn

In the beginning there was NPM, and for a time it was good. Packages went forth and multiplied. The New Gods proclaimed the great demon Dependency Management had been slain. But The Old Gods knew better, for they had seen much and knew that the demon can never be killed, only held at bay.

The Old Gods were ignored. In the folly of a young age grew an abundance of packages and with them grew the scourge of dependency. In the depths beneath the earth, in a place beyond memory, the great demon stirred.

The first sign something was wrong was non-deterministic package version mismatches. “This is fine!” The New Gods declared. “A temporary setback, nothing more! We can fix it.” And so they introduced shrinkwrap, a lamp to combat the growing darkness.

But it proved to be too little, too late, and dusk continued to fall. The New Gods suffered their first major defeat at the [Battle of Left-pad](https://www.theregister.co.uk/2016/03/23/npm_left_

@Aupajo
Aupajo / gist:4654510
Created January 28, 2013 10:37
List of TZInfo timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@Aupajo
Aupajo / demo.html
Created September 26, 2013 00:43
Simple jQuery multiple-choice quiz
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Quiz</title>
</head>
<body>
<form action="/success-page" class="simple-quiz">
<h3>Question 1</h3>
@Aupajo
Aupajo / georgia.js
Last active November 5, 2020 22:10
Georgia Bitbar
#!/usr/bin/env node
const fetch = require('node-fetch')
function formattedCount(number) {
return number.toLocaleString()
}
async function start() {
const url = 'https://www.huffpost.com/elections/president.json'