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 functools import partial | |
def classtree(cls, indent=0): | |
return (classtree(type(cls), indent) if type(cls) != type | |
else (stringy(cls, indent) | |
+ ''.join(map(partial(classtree, indent=indent+3), | |
filter(lambda sub: sub != type, | |
subclasses(cls)))))) |
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<pthread.h> | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<sys/time.h> | |
#define THREADS 4 | |
void *do_nothing(void* _) { | |
return NULL; | |
} |
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
use std::cell::RefCell; | |
use std::io::{stdin, stdout, Write}; | |
fn main() { | |
loop { | |
print!("Enter a positive integer: "); | |
stdout().flush().expect("could not flush buffer"); | |
let mut input = String::new(); | |
let read = stdin().read_line(&mut input).expect("failed to read line"); |
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 python | |
from functools import reduce | |
from math import e, factorial | |
from operator import mul | |
from os.path import basename | |
from sys import argv | |
# https://stackoverflow.com/a/4941932 | |
def ncr(n, r): |
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
/// short-circuiting version of iter.max_by_key | |
/// | |
/// partially taken from https://doc.rust-lang.org/src/core/iter/traits/iterator.rs.html#2591 | |
/// | |
/// Example: | |
/// | |
/// ``` | |
/// let list = [[1, 2, 3], [5, 4, 3], [1, 1, 4]]; | |
/// assert_eq!(try_max_by_key(list.into_iter(), |vec| vec.last().ok_or(())), Some(Ok(&[1, 1, 4]))); | |
/// |
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
% make -n --always-make| tee output.txt | |
mkdir webpages | |
python -m gradeforge download catalog > webpages/catalog.html | |
if grep '404 page not found' webpages/catalog.html; then echo file "'webpages/catalog.html'" gave a 404 not found; rm -f webpages/catalog.html; exit 999; fi | |
sed -i 's/\s\+$//' webpages/catalog.html | |
python -m gradeforge parse catalog --department-output catalog.departments.csv webpages/catalog.html catalog.csv | |
mkdir grades | |
python -m gradeforge download \ | |
--season `echo grades/Fall-2008-Columbia.pdf | cut -d. -f1 | cut -d/ -f2 | cut -d- -f1` \ | |
--year `echo grades/Fall-2008-Columbia.pdf | cut -d. -f1 | cut -d- -f2` \ |
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
-----BEGIN PGP MESSAGE----- | |
hQIMAyxhjqrO4XvZAQ//aA+DJwZ5G1T08+Ynh6v3L/c+/tbeDhT1vg8DV2gne2QP | |
5DPv3vktSIRyXe2iJrLPCMNX/y3lLAkOiifRoNmCUD2edUSu3T+euSMYUbQnJ/vO | |
S98yosssIX96i1WbHd4ShyeCamSsXRgyVK+fU5WOqfPGWZa1oJtNlKC+SNcoURgm | |
vI2nZfN5JlmsZKKUblcKUGwHvGTFQ8u06HF/J233riNXKXI33Hzx/yyRnUsbDufV | |
n0HVZLGDEXk3/fWMfX3gqpeVzRdYTS+310HbZgWf687AG+0mb41fuABuq+Y7QRso | |
/up36iakYzjK5woY7M83Z4cJtIWzMQkiX1OpnpfZlrtbGEfSZ0XtRjWRlWoxu0ER | |
fwzzh4UqODY5P50hkb/6ibXFKnIuqJr0CSnjNWtTOEbvZqG8/Efr+Iykqctbu6v7 | |
c+UI2YeQxyryowvyT5PQSHagzDIJ3rsyD/v0TZhDRnU41yeo3wDMxE+jYjNG0m3n |
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
Note this could be done in pure `sh` by replacing $((n - 1)) with `echo n - 1 | bc`; | |
I chose to assume `bc` was not installed so as to prevent errors. | |
-----BEGIN PGP MESSAGE----- | |
hQIMAyxhjqrO4XvZAQ/9EgNOiSRuQS58Uy4RLw2ldt5LHa3zndn/bJ9qxpyfS+f+ | |
OtLCOD8SwUvwiFuFECX2gCZpQKyteGMT7n2ohvBRWZ69Ijmgl63nwbWxPh62KYpW | |
3SYgtA3WkIHEz84Pr0QIEStBt1GAZkHvuYDAeIzlTNC9kxsr/zOzOIWU3f7hv7On | |
oSHLtdR3Q43JT+0J+bhEiT1RD2lYf87dYFCz/dS0QtXKx45QSFF5fFtI/wNsI37m | |
HUEdVs7SLoFim/WOp23fQOxGhw5RwTK1owoAYoDOVMyPmu63BQWlcRiIup0SxhY8 |
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
-----BEGIN PGP MESSAGE----- | |
hQIMAyxhjqrO4XvZAQ//bZWISUxqCzqHBf+RJyhqtAWGXaLEYa6O2MYwwfdRAiFy | |
DxK6ZpqGjScl9EVghk15lRg0IeuSJEKZ5aLEP5rv7xhTxxTJu55DwFT9C9Pw7o5w | |
dYnw1EpIFjNx0g8tQvvFTmNIpXSj0kF/7Mo5t4Hd1e+EOmdXCkf0Px10cuxtbdUI | |
6AKIVgrFSn7Ci+ViHVW+9l5mGPNJCvCcsk1CTS5IBh1pJtP8T+ng3dW3ZJIEuegQ | |
zzmtAAR5Dk1hFE0/x2bnPmjmi9Qm2dRuv+lEFYR610ozm1c4AbAsBUlERba/xeCa | |
Eymy666P/oVw64IRA+zRZg567a0Rdr8uCY3Gh/xeMgu5tQqHo8tiZYSWsFELqRTT | |
snyqw4JUi7CJi964j3G606GfRDPw9qPLad/nQrnKcfXypGi5wxn1i2LchdN9Rb/8 | |
S+MORUPIC4IMLYwGHLAvpdDXhquPuEuAmgxMIn/CxlM/eCVzNo0MTPLILgNEFhPU |