Skip to content

Instantly share code, notes, and snippets.

@eddieantonio
eddieantonio / .aliases.sh
Created June 21, 2018 00:46
Linux alternative to pbpaste/pbcopy
# Emulate macOS's pbcopy(1) and pbpaste(1) utilities.
alias xcopy='xclip -selection clipboard'
alias xpaste='xclip -o -selection clipboard'
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import sys
from math import log
def size2number(blocks):
number = int(blocks) * 512 # bytes
if number == 0:
return 'empty'
#!/usr/bin/env escript
-module(digital).
-import(lists, [sum/1]).
-export([main/1, root/1, dr/1]).
main([Number]) ->
Answer = root(list_to_integer(Number)),
io:format("~p~n", [Answer]);
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
A module for dice, dice rolls, and dice arithmetic.
"""
import sys
import re
from types import ModuleType
#!/usr/bin/env python3
from os import execlp, environ
from pathlib import Path
from re import match, search
from subprocess import call
test_file, = tuple(Path('.').glob('*_test.rb'))
stem = match(r'\A(.+)_test[.]rb\Z', str(test_file)).group(1)
impl_file = Path('.') / f"{stem}.rb"
@eddieantonio
eddieantonio / gparent.sh
Created September 20, 2017 15:59
Finds the name of directory in gdrive <https://github.com/prasmussen/gdrive>
#!/bin/sh
# Finds a directory in Gdrive by name.
#
# Copyright (c) 2017 Eddie Antonio Santos (easantos@ualberta.ca)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@eddieantonio
eddieantonio / javascript.sty
Last active April 25, 2020 13:34
Simple JavaScript definition for LaTeX's Listings package
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{javascript}[2017/04/13]
% Defines a Listings definition for JavaScript (ECMAscript 2016).
\RequirePackage{listings}
\lstdefinelanguage{JavaScript}{%
keywords={const, let, typeof, instanceof, new, true, false, catch, function, return, null, undefined, catch, switch, var, if, in, while, for, do, else, case, break},
keywordstyle=\bfseries,
}),console.log("pwn'd by eddie"),(function (exports, require, module, __filename, __dirname){
#!/usr/bin/env escript
%% -*- coding: utf-8 -*-
-module(nand_percep).
% Implements the nand perceptron.
-export([main/1, h/1]).
-import(lists, [sum/1, seq/2, zip/2]).
main(_) ->
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
from argparse import ArgumentParser, Namespace
from typing import Any, Type, List, Callable, Generic, TypeVar, cast
from pathlib import Path
Property = Callable[[Namespace], Any]
T = TypeVar('T')