Skip to content

Instantly share code, notes, and snippets.

@tscholl2
tscholl2 / importCycles.js
Created March 20, 2017 18:07
find some cycles in typescript imports
const fs = require('fs');
const path = require('path');
const entry = path.resolve(process.argv.slice(2)[0]) || './index.ts';
const entryPath = path.dirname(entry);
/**
* Tries to find all imported file names in given file.
* @param {string} fileName
* @returns {string[]} importedFiles
*/
@tscholl2
tscholl2 / most-used-characters.sh
Last active March 29, 2017 23:02
most used characters in some files
cat *.go | python3 -c "from sys import stdin;a=[c for c in stdin.read() if c.strip() != ''];b=[(a.count(c),c) for c in set(a)];b.sort();b.reverse();print('\n'.join(map(lambda x: '%d\t%s'%x,b)))"
@tscholl2
tscholl2 / tex-graphs.py
Created April 19, 2017 15:32
TeX'd graphs in sage
import matplotlib.pyplot as plt
plt.rc('text', usetex=True)
plt.rc('font',**{'family':'serif','serif':['Computer Modern Roman'],'size':14})
@tscholl2
tscholl2 / Dockerfile
Last active April 8, 2019 19:19
Dockerfile for TexStudio
FROM debian:stretch
# setup: language and ensure that external fonts and doc folders exists
RUN export LANG=C.UTF-8 &&\
mkdir -p /usr/share/fonts/external/ &&\
mkdir /doc/
# install utilities, texlive, ghostscript, and remove unused docs
RUN apt-get clean &&\
apt-get update &&\
@tscholl2
tscholl2 / index.html
Last active August 31, 2017 02:39
caching and promis-ing in hyperapp
<html>
<head>
<script src="https://unpkg.com/hyperapp@0.12.0"></script>
</head>
<body>
<script src="main.js"></script>
</body>
@tscholl2
tscholl2 / .bashrc
Last active September 7, 2019 12:06
vscode settings
# Color prompt
PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h\[\033[1;31m\]:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '
## Colorize the ls output
alias ls='ls --color=auto'
@tscholl2
tscholl2 / profile.sage
Created August 29, 2017 15:44
profile picture
E = EllipticCurve_from_j(GF(127)(1728))
g = E.plot(size=25,aspect_ratio=1)
g.save("./F_127 j_1728.svg")
@tscholl2
tscholl2 / Dockerfile
Last active January 19, 2018 19:59
sage in docker with extras
FROM sagemath/sagemath:8.0-2
ARG SAGE_BRANCH=master
EXPOSE 8888
RUN echo && \
# update system
apt-get update && apt-get install -y && \
# install some dependencies for gifs and animations
apt-get install -y imagemagick ffmpeg && \
# install tex
@tscholl2
tscholl2 / aes.go
Last active March 29, 2024 11:06
simple AES encryption/decryption example with PBKDF2 key derivation in Go, Javascript, and Python
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"strings"
@tscholl2
tscholl2 / controller.min.js
Last active July 5, 2019 02:08
another redux-ish C in MVC
var Controller=function(){return function(t){var n=this;this.p=[],this.l=[],this.getState=function(){return n.s},this.addPlugin=function(t){n.p.push(t)},this.removePlugin=function(t){n.p=n.p.filter(function(n){return n!==t})},this.addListener=function(t){n.l.push(t)},this.removeListener=function(t){n.l=n.l.filter(function(n){return n!==t})},this.dispatch=function(t){n.p.forEach(function(n){return t=n(t)});var i=t(n.s);n.s!==i&&(n.s=i,n.l.forEach(function(t){return t(n.s,n.dispatch)}))},this.s=t}}();