Skip to content

Instantly share code, notes, and snippets.

@kach
kach / Symbolator
Last active April 9, 2018 20:55
Convert a string to a list of element symbols, if possible.
import sys
# try: cat /usr/share/dict/words | python symbols.py -
symbols = [['ac', 'actinium'], ['ag', 'silver'], ['al', 'aluminum'], ['am', 'americium'], ['ar', 'argon'], ['as', 'arsenic'], ['at', 'astatine'], ['au', 'gold'], ['b', 'boron'], ['ba', 'barium'], ['be', 'beryllium'], ['bh', 'bohrium'], ['bi', 'bismuth'], ['bk', 'berkelium'], ['br', 'bromine'], ['c', 'carbon'], ['ca', 'calcium'], ['cd', 'cadmium'], ['ce', 'cerium'], ['cf', 'californium'], ['cl', 'chlorine'], ['cm', 'curium'], ['cn', 'copernicium'], ['co', 'cobalt'], ['cr', 'chromium'], ['cs', 'cesium'], ['cu', 'copper'], ['db', 'dubnium'], ['ds', 'darmstadtium'], ['dy', 'dysprosium'], ['er', 'erbium'], ['es', 'einsteinium'], ['eu', 'europium'], ['f', 'fluorine'], ['fe', 'iron'], ['fl', 'flerovium'], ['fm', 'fermium'], ['fr', 'francium'], ['ga', 'gallium'], ['gd', 'gadolinium'], ['ge', 'germanium'], ['h', 'hydrogen'], ['he', 'helium'], ['hf', 'hafnium'], ['hg', 'mercury'], ['ho', 'holmium'], ['hs', 'hassium'], ['i', 'iodine'], ['in', 'indium'],
@kach
kach / Lua.ne
Created April 18, 2014 04:12
A Lua grammar for nearley
# Adapted from http://www.lua.org/manual/5.2/manual.html
# No comments implemented yet, because lua comments are hard.
Chunk -> _ Block _
Block -> _Block
| _Block __ ReturnStat
ReturnStat -> "return" __ ExpList
| "return" __ ExpList _ ";"
import ssl
import socket
import time
import datetime
HOST = "irc.pdgn.co"
PORT = 6697
CHAN = "#study"
NICK = "Study_Bot"

Keybase proof

I hereby claim:

  • I am Hardmath123 on github.
  • I am hardmath123 (https://keybase.io/hardmath123) on keybase.
  • I have a public key whose fingerprint is 844A E763 FEA5 B7AD BC42 965B ECF6 E2AE 19C0 E4E6

To claim this, I am signing this object:

@kach
kach / rubik.prolog
Created May 22, 2016 04:06
Solve a 2x2x2 Rubik's cube in prolog
% Solve a 2x2x2 Rubik's Cube
% Kartik - 2016
% Query sample:
% | :- moveseq(X, cube(g,b,b,b, y,y,y,r, o,g,r,w, r,r,g,g, w,w,o,o, o,b,y,w), C), finished(C).
% C = cube(b,b,b,b,y,y,y,y,r,r,r,r,g,g,g,g,o,o,o,o,w,w,w,w)
% X = [l,u,f,f,f,u,u,l,u,f,f,l,f,u,f,u] ? ;
% Using this map:
% UUUU DDDD LLLL RRRR FFFF BBBB
% B3 B4
% B2 B1
@kach
kach / dict.swift
Created March 29, 2018 17:52
Command-line word lookup based on Apple's built-in dictionaries
import Foundation
import CoreServices
if CommandLine.argc < 2 { exit(1) }
let word = CommandLine.arguments[1] as CFString
let rang = CFRangeMake(0, CFStringGetLength(word)) //DCSGetTermRangeInString(nil, word, 0)
let defn = DCSCopyTextDefinition(nil, word, rang)
if defn != nil { print(defn!.takeUnretainedValue() as String) }
@kach
kach / 3BT AV Checklist.md
Created June 1, 2018 20:47
(You know who you are.)

Take:

  • Green battery (from the charger in Harmony)
  • Xbee on breakout board (has thick black antenna, should be in Harmony)
  • Red three-headed USB wire (should be in Harmony with the Xbee)
  • SD card adapter thing (sorry, I don't know where this went)
  • Extra nichrome (next to the plants)
  • Plastic wrap for waterproofing Skybass

Setup for launch:

  • Put the battery in Skybass (we labeled the correct terminals on both the board and battery)
import subprocess
f = open('paxos_epr.ivy')
source = f.read().split('\n')
f.close()
conjecture_line_numbers = []
all_lines = []
for i, line in enumerate(source):