Skip to content

Instantly share code, notes, and snippets.

View minitech's full-sized avatar

Ryan O’Hara minitech

  • British Columbia, Canada
View GitHub Profile
import hashlib
import hmac
import json
import struct
import sys
def main():
if len(sys.argv) != 2:
print(f"Usage: python3 {sys.argv[0]} COURSES.jsonl\n", file=sys.stderr)
$ python --version
Python 3.6.0

$ python -m timeit -s 'import random; l = list(range(18))' 'random.choice(l)'
1000000 loops, best of 3: 0.591 usec per loop

$ python -m timeit -s 'd = {str(n): list(range(15)) for n in range(18)}' 'd["12"]'                     
10000000 loops, best of 3: 0.0224 usec per loop
import itertools
data = ['str', 'int', 'dex', 'con', 'wis', 'cha']
covered = frozenset([
# paladin
('wis', 'cha'), ('cha', 'str'), ('str', 'cha'), ('str', 'int'),
# barbarian
('str', 'dex'), ('str', 'con'), ('con', 'str'),
addDataset(id: string, content: string): Promise<InsightResponse> {
return new Promise(function (fulfill, reject) {
let zip = new JSZip();
let courseStringsPromises: Promise<string>[] = [];
if (id === "" || id === null) {
reject({"code": 400, "body": {"error": "invalid id"}});
}
if (content === "" || content === null) {
using System;
using System.Collections.Generic;
static class Application {
static void Main() {
var list = new List<int>();
for (int i = 0; i < 100; i++) {
Console.WriteLine("{0,5}/{1,5}", list.Count, list.Capacity);
list.Add(i);
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// most code is single-threaded
unsigned char* current_mem;
void* readA();
void* readB();
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
class ColorInterpolationApplication {
public static void Main() {
Application.Run(new ColorInterpolation());
}
}
alert("Don't blindly paste scripts into your console! Sheesh.");
@minitech
minitech / tail.c
Created September 10, 2013 14:27
The beginnings of an RSS reader or something in C.
#include <string.h>
#include <stdio.h>
#include <libpq-fe.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@minitech
minitech / 018-maximum-path-sum-i.hs
Created September 5, 2013 03:17
My solution to Project Euler 18.
problem = [
[75],
[95, 64],
[17, 47, 82],
[18, 35, 87, 10],
[20, 04, 82, 47, 65],
[19, 01, 23, 75, 03, 34],
[88, 02, 77, 73, 07, 63, 67],
[99, 65, 04, 28, 06, 16, 70, 92],
[41, 41, 26, 56, 83, 40, 80, 70, 33],