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 collections import OrderedDict | |
OBSTACLES = OrderedDict([('grass', ("long, wavy", "swishy-swashy")), | |
('a river', ("deep, cold", "splash-splosh")), | |
('mud', ("thick, oozy", "squelch-squerch")), | |
('a forest', ("big, dark", "stumble-trip"))]) | |
def hunting_anthem(): | |
print("We're going on a bear hunt, &c.") |
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
# if you can easily fit it in less than one and a half tweets, I don't think it | |
# deserves to be called a "project" | |
from string import ascii_uppercase as u, ascii_lowercase as l; c = lambda m, n: ''.join((chr((ord(c)-97+n)%26+97) if c in l else chr((ord(c)-65+n)%26+65)) if c in l+u else c for c in m) |
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
in [1]: import ast; from ast import * | |
in [2]: m = ast.parse('def at(): print("@")') | |
in [3]: m.body[0].name = "@" | |
in [4]: exec(compile(m, "<string>", 'exec')) | |
in [5]: globals()['@'] | |
Out[5]: <function __main__.@> |
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
in [1]: import ast; from ast import * | |
in [2]: m = ast.parse('def at(): print("@")') | |
in [3]: m.body[0].name = "@" | |
in [4]: exec(compile(m, "<string>", 'exec')) | |
in [5]: globals()['@'] | |
Out[5]: <function __main__.@> |
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
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"io" | |
"net/http" | |
"os" | |
) |
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
pub fn singular_value_decomp(&self) -> (Matrix<T>, Matrix<T>, Matrix<T>) { | |
let ata = self.transpose() * self; | |
let (ata_eigenvals, ata_eigvecs) = ata.eigendecomp(); | |
// (index, √λ) pairs (indices being order of return from `.eigendecomp`) | |
let mut enumerated_singular_vals = ata_eigenvals.iter() | |
.map(|s| s.sqrt()) | |
.enumerate() | |
.collect::<Vec<_>>(); |
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 enum import Enum | |
from random import choice, randint | |
from datetime import datetime | |
from operator import add, sub, mul # binary operations as functions! | |
# Enums were introduced in 3.4! | |
Operation = Enum('Operation', ('add', 'subtract', 'multiply')) |
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
break | |
} | |
panic(err) | |
} | |
log.Printf("request is %#+v", req) | |
switch req := req.(type) { | |
case *fuse.StatfsRequest: | |
stats, err := mountHandle.Statfs() |
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 csv | |
import logging | |
import bleach | |
import textblob | |
import gensim | |
from sklearn.decomposition import PCA | |
from numpy import dot | |
from numpy.linalg import norm |
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
in [200]: by_first_component[:100] | |
Out[200]: | |
[('u', -1.9398326), | |
('parameter', -1.8654854), | |
('1-p', -1.8631597), | |
('f', -1.8552135), | |
('T', -1.7352118), | |
('q', -1.6937695), | |
('F', -1.6872095), | |
('Pr', -1.6614704), |