Skip to content

Instantly share code, notes, and snippets.

View unixpickle's full-sized avatar

Alex Nichol unixpickle

View GitHub Profile
letters = 'abcdefghijklmnopqrstuvwxyz'
with open('/usr/share/dict/words', 'rt') as in_file:
words = [x.strip() for x in in_file.readlines()]
counts = {}
starts = {}
total = 0
for letter in letters:
counts[letter] = len([x for x in words if x.endswith(letter)])
@unixpickle
unixpickle / config.md
Last active October 13, 2019 09:09
Configuring Linux Machine

This is a set of things I suggest you do on a new Ubuntu machine to make it nice and (almost) Mac-like.

Install some packages

sudo apt install -y xclip
sudo apt install -y caffeine
sudo apt install -y gnome-tweaks
@unixpickle
unixpickle / poly_points.py
Last active February 6, 2019 02:11
Find vertices of a dodecahedron
"""
Generate points for a dodecahedron by solving an
optimization problem.
Gradient descent doesn't always converge to the global
minimum, so I run it repeatedly and keep printing the
solutions it comes up with if they're better than the
previous solution.
"""
@unixpickle
unixpickle / normact.py
Created February 4, 2019 22:26
Normalization as an activation function
"""
Get 99% accuracy on MNIST with a norm-activated network.
Test set: Average loss: 0.0395, Accuracy: 9880/10000 (99%)
Based on: https://github.com/pytorch/examples/blob/master/mnist/main.py
"""
import argparse
import torch
@unixpickle
unixpickle / puzzle.go
Created December 24, 2018 23:14
Logic puzzle
// Solve this logic puzzle:
// https://xmonader.github.io/prolog/2018/12/21/solving-murder-prolog.html
package main
import (
"fmt"
"github.com/unixpickle/approb"
)
@unixpickle
unixpickle / wallpaper.svg
Created December 20, 2018 00:44
wallpaper
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@unixpickle
unixpickle / drone.svg
Created November 29, 2018 23:32
Drone
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@unixpickle
unixpickle / count_bdays.py
Created November 23, 2018 01:07
Actor Signs
"""
Histogram actors by birthday and astrological sign.
"""
import datetime
import re
import requests
@unixpickle
unixpickle / squircle.js
Created October 28, 2018 17:14
Squircle smiley face VC
function(canvas, video) {
function setupAudioLevel() {
window.HACK_VOLUME_LEVEL = 0.0;
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then((stream) => {
const ctx = new AudioContext();
const source = ctx.createMediaStreamSource(stream);
const node = ctx.createScriptProcessor(4096, 1, 1);
node.onaudioprocess = (event) => {
const buffer = event.inputBuffer.getChannelData(0);
let sum = 0;
@unixpickle
unixpickle / hijack.js
Last active October 27, 2018 16:07
Pulsating smiley face camera-hijack
function(canvas, video) {
function setupAudioLevel() {
window.HACK_VOLUME_LEVEL = 0.0;
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then((stream) => {
const ctx = new AudioContext();
const source = ctx.createMediaStreamSource(stream);
const node = ctx.createScriptProcessor(4096, 1, 1);
node.onaudioprocess = (event) => {
const buffer = event.inputBuffer.getChannelData(0);
let sum = 0;