Skip to content

Instantly share code, notes, and snippets.

View lispandfound's full-sized avatar
🕶️
Vibing

Jake Faulkner lispandfound

🕶️
Vibing
  • QuakeCoRE
  • Christchurch, New Zealand
  • 13:39 (UTC +13:00)
View GitHub Profile
this is some text that might be a makefile or something
@lispandfound
lispandfound / quicksort.rs
Created December 14, 2015 00:04
Quicksort implementation in rust
// A generic quicksort algorithm implementation in rust
fn quicksort<T: Eq + PartialEq + Clone + PartialOrd>(arr: &mut Vec<T>, low: usize, high: usize) {
if low < high {
let p = partition(arr, low, high, &|a, b| {a <= b});
quicksort(arr, low, p-1);
quicksort(arr, p+1, high);
}
}
fn partition<T: Clone, F: Fn(&T, &T) -> bool>(arr: &mut Vec<T>, low: usize, high: usize, f: &F) -> usize {
@lispandfound
lispandfound / scatter.py
Last active May 24, 2017 23:57
Scatter
""" Scatter.py, scatter your files to the four corners of the wind. """
import os
import random
import tarfile
def mktarball(file_path, delete=False):
""" Create a tarball from file_path, optionally deleting the
original. """
file_dir = os.path.dirname(file_path)
file_name = os.path.basename(file_path)
''' Control and run RGB Fedora server. '''
# Asynchronous loop code
import uasyncio as asyncio
# Controlling RGB strip
import neopixel
# Controlling pin out
import machine
# Connecting to Wireless Network
import network
# Communicating over sockets
#!/usr/bin/env python3
import json
import sys
import subprocess
def stop_running_task():
subprocess.run(['timetrap', 'out'])
def value_of(knapsack, configuration):
values = zip(knapsack, configuration)
return sum(value for value, stolen in values
if stolen is True)
def combinations_of(length):
lst = [False] * length
for i in range(2 ** length):
for j in range(len(lst)):
@lispandfound
lispandfound / mfp.py
Created September 8, 2017 08:20
Download all songs from musicforprogramming.net
from collections import namedtuple
import xml.etree.ElementTree as et
import requests
import sys
from pathlib import Path
Song = namedtuple('Song', ['title', 'filename', 'url', 'size'])
RSS_URL = 'http://musicforprogramming.net/rss.php'
import random
from collections import deque
with open('words.txt') as infile:
WORDS = [l.strip() for l in infile]
def nice_hash(val):
value = ord(val[0]) << 7
for char in val:
value = ((1000003 * value) & 0xFFFFFFFF) ^ ord(char)
#!/usr/bin/env racket
#lang racket
(require (for-syntax racket/format))
(require racket/date)
(define-syntax (bar-definitions bar)
(syntax-case bar ()
[(_ forms ...)
#`(begin
import random
from collections import deque
from enum import Enum
from functools import total_ordering
import heapq
import math
import itertools
with open('words.txt') as infile:
WORDS = [l.strip() for l in infile]