Skip to content

Instantly share code, notes, and snippets.

View danthedaniel's full-sized avatar
👨‍💻
⠠⠵

Daniel danthedaniel

👨‍💻
⠠⠵
View GitHub Profile
@danthedaniel
danthedaniel / autosnapshot.py
Last active June 12, 2018 23:55
Vultr Auto Snapshot (Python 3.6+)
#!/usr/bin/env python3
"""
Automatically create a snapshot for a Vultr server, discarding old snapshots
to keep only the newest N snapshots.
Supports Python 3.6+.
"""
import logging
"""Use genetic programming to reverse-engineer a truth table."""
import random
import inspect
import string
from multiprocessing import Process, Value
from deap import creator, base, tools, gp
# 110 Automata
# truth_table = [
"""Drexel Web Term Master Schedule scraper."""
import bs4 as bs
import sqlite3
import requests
from datetime import datetime
def db_setup(conn):
"""Create the table and indices."""
from typing import List, Callable, TypeVar, Optional
T = TypeVar("T")
def binary_search(l: List[T], key: Callable[[T], int]) -> Optional[T]:
"""Perform a binary search.
Arguments
import json
import requests
import zlib
from functools import wraps
from urllib.parse import urlencode
class ApiResponse:
def __init__(self, response: dict):
self.data = response['data']
#!/usr/bin/env python3
import requests
from multiprocessing.dummy import Pool
from io import BytesIO
from PIL import Image
from tqdm import tqdm
from itertools import product
@danthedaniel
danthedaniel / leaderboards.tsx
Last active March 20, 2018 23:46
Preact components with persistent state.
/**
* Simple example usage of a stored component.
*/
import { h } from 'preact';
import api from '../api';
import StoredComponent from '../stored_component';
type StateType = typeof defaultState;
@danthedaniel
danthedaniel / optional.ts
Created March 20, 2018 18:23
Rust's Option type in TypeScript.
/**
* An optional value. Can be null or a T.
*/
class Optional<T> {
private _val: T;
constructor(val: T) {
this._val = val;
}
@danthedaniel
danthedaniel / phoenix.d.ts
Last active March 20, 2018 18:23
Phoneix 1.3 type definitions
declare module "phoenix" {
interface Response {
status: string,
response: any,
}
interface RecHook {
status: any,
callback: (response: any) => void
@danthedaniel
danthedaniel / english_num.py
Last active March 2, 2018 01:23
Print an integer in English
"""Print a number."""
from __future__ import print_function
size_names = [
"", "thousand", "million", "billion", "trillion", "quadrillion",
"quintillion", "sexillion", "septillion", "nonillion", "decillion"
]
num_names = [