Skip to content

Instantly share code, notes, and snippets.

View milesrout's full-sized avatar

Miles Rout milesrout

View GitHub Profile
import java.io.silliness;
public class HelloWorld {
final static string HELLO = "hello";
final static string WORLD = "world";
public static void main(String[] args) {
StringBuilder greetingBuilder = new StringBuilder();
greetingBuilder.add(HELLO, StringBuilder.CAPITALIZE);
greetingBuilder.add(StringBuilder.Punctuation.SPACE);
greetingBuilder.add(WORLD);
let @q=yiw?def small^MOdef ^[pA(self0<80>kb):^Mraise NotImplementedError^M^[^Ojj
def intersperse(z, d):
q = [x for y in z for x in [y, y]]
q[1::2] = [d for x in z]
return q[:-1]
from enum import Enum
CounterEvent = Enum('CounterEvent', 'UP DOWN')
def counter():
def apply(f, x):
return f(x)
def handle_event(e):
etype, data = e
#include <iostream>
#include <map>
using namespace std;
struct person { std::string first, last; };
int main() {
std::map<std::string, person> m;
if (auto [_, was_inserted] = m.emplace("43662121", person{"Miles", "Rout"}); was_inserted) {
std::cout << "Student 43662121 was added to the map";
import random
def make_board():
return [[None, None, None], [None, None, None], [None, None, None]]
def f(x):
if x is None:
return 'X'
--partially derived from http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/
module Collatz where
import Numeric.Natural
import qualified Data.Set as Set
import Data.Set (Set)
data Bit = Zero | One deriving (Eq, Show)
type Cantor = Natural -> Bit
@milesrout
milesrout / foreach.py
Created March 15, 2017 01:31 — forked from louisswarren/foreach.py
Javascript's foreach in python
accumulate = lambda t: lambda f: lambda *a, **k: t(f(*a, **k))
@accumulate(list)
def foreach(iterable, func):
for i, x in enumerate(iterable):
yield func(x, i)
mylist = list(chr(n) for n in range(65, 75))
foreach(mylist, lambda x, i: print('{} => {}'.format(i, x)))
@milesrout
milesrout / youtube-terminal.py
Last active March 8, 2017 02:24 — forked from anonymous/youtube-terminal.py
Play audio from a youtube search in the terminal
#!/usr/bin/env python3
from os import system
from sys import argv
# Example:
# youtube-terminal.py foo bar baz
# calls youtube-dl 'ytsearch:foo bar baz' --max-downloads 1 -o - | cvlc - --no-video
call = 'youtube-dl "ytsearch:{}" --max-downloads 1 -o - | cvlc - --no-video'.format
system(call(' '.join(argv[1:])))
# mandatory!
dev-libs/glib:2
dev-libs/libgcrypt
dev-libs/nspr
dev-libs/nss
gnome-base/gconf
media-libs/alsa-lib
media-libs/fontconfig
media-libs/freetype:2
media-libs/libjpeg-turbo