Skip to content

Instantly share code, notes, and snippets.

@flying-sheep
flying-sheep / build-python.sh
Last active January 27, 2017 10:36
Building R and Python with useful options
_py_ver=3.6.0
set -e # stop when encountering an error
#~ # Download, extract, and delete archive
wget https://www.python.org/ftp/python/$_py_ver/Python-$_py_ver.tar.xz
tar -xf Python-$_py_ver.tar.xz && rm -f Python-$_py_ver.tar.xz
cd Python-$_py_ver
#~/Python-$_py_ver # Configure with many options
./configure --prefix=$HOME/.local \
digraph {
node[shape=box]
edge[color="#775533"]
subgraph normal {
node[color=transparent, fillcolor=beige]
"Basement I" -> "Basement II" -> "Caves I" -> "Caves II" -> "Depths I" -> "Depths II" -> "Womb I" -> "Womb II" -> { Cathedral, Sheol }
Cathedral -> Chest [color="#dddddd", label=Polaroid]
Sheol -> "Dark Room" [color="#666666", label=Negative]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flying-sheep
flying-sheep / inline-vid.r
Created December 15, 2016 14:35
Inline video for Jupyter R notebooks
library(base64enc)
library(animation)
inline_vid <- function(expr, file = NULL, ext = c('.mp4', '.gif')) {
ext <- match.arg(ext)
save_fn <- switch(ext, .mp4 = saveVideo, .gif = saveGIF)
template <- switch(ext,
.mp4 = '<video src="data:video/mp4;base64,%s" autoplay loop></video>',
.gif = '<img src="data:image/gif;base64,%s">')
@flying-sheep
flying-sheep / fix-widget-heights.js
Created December 15, 2016 12:54
jupyter notebook messes up widgets
function resize_widget(iframe) {
if (parseFloat(iframe.style.height) < 50) {
iframe.setAttribute('scrolling', 'off')
const { clientHeight, clientWidth } = iframe.contentDocument.documentElement
iframe.style.height = `${clientHeight}px`
iframe.style.width = `${clientWidth}px`
}
}
function resize_all() {
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>PEP 0XXX</title>
<link rel=stylesheet href=https://www.python.org/static/stylesheets/style.css>
<link rel=stylesheet href=https://www.python.org/static/stylesheets/mq.css>
<style>
.pep-page pre {
padding: .5em;
import sys
import os
from http import HTTPStatus
from http.server import HTTPServer, SimpleHTTPRequestHandler
from pathlib import Path
from io import StringIO, BytesIO
from pep2html import PEP_TYPE_DISPATCH
here = Path(__file__).parent
@flying-sheep
flying-sheep / fonsi:server-stats
Last active December 8, 2016 12:20
rename both to “server-stats”, put the short one into your $PATH locally, the other somewhere on your server-$HOME’s $PATH
#!/bin/zsh
set -e
unique() {
awk '!x[$0]++'
}
servers=(susi fonsi hias sepp wastl)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.