This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let @q=yiw?def small^MOdef ^[pA(self0<80>kb):^Mraise NotImplementedError^M^[^Ojj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def make_board(): | |
return [[None, None, None], [None, None, None], [None, None, None]] | |
def f(x): | |
if x is None: | |
return 'X' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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:]))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |