Skip to content

Instantly share code, notes, and snippets.

View kynan's full-sized avatar
💭
I may be slow to respond and only triage notifications irregularly

Florian Rathgeber kynan

💭
I may be slow to respond and only triage notifications irregularly
View GitHub Profile
#!/bin/sh
jq -r 'def banner: "\(.) " + (28-(.|length))*"-";
("Non-cell info" | banner), del(.cells), "",
(.cells[] | ("\(.cell_type) cell" | banner),
"\(.source|add)",
if ($show_output == "1") then
"",
( select(.cell_type=="code" and (.outputs|length)>0) |
("output" | banner),
(.outputs[] |
@thedod
thedod / .gitignore
Last active December 22, 2021 23:38
Hyde Park - githubless gh-pages with gitolite
config.py
env-*
*.pyc
@pbugnion
pbugnion / ipython_notebook_in_git.md
Last active October 22, 2023 12:25
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

bzr_branch=''
function find_bzr_branch {
local dir=. dirty head nick
# Parse all the bzr config stuff by hand, rather than calling out
# to the binary, cos it's so damn slow.
until [ "$dir" -ef / ]; do
if [ -d "$dir/.bzr/checkout" ]; then
head=$(readlink -f $dir)
dirty=''
bzr_branch=" ${red}b${green}"
@takluyver
takluyver / README.md
Created September 6, 2014 21:44
Flatten notebooks for git diff

Copy nbflatten.py to somewhere on $PATH. Then, in the root of a git repository, run these commands:

echo "*.ipynb diff=ipynb" >> .gitattributes 
git config diff.ipynb.textconv nbflatten.py

When you change a notebook and run git diff, you'll see the diff of flattened, simplified notebooks, rather than the full JSON. This does lose some information (metadata, non-text output), but it makes it easier to see simple changes in the notebook.

This doesn't help with merging conflicting changes in notebooks. For that, see nbdiff.org.

@DrPaulBrewer
DrPaulBrewer / splitTemplates
Last active August 29, 2015 13:56
splitTemplates templates.html dirname -- refactoring tool to split out each <template name="xxx">contents</template> to its own file
#!/usr/bin/python
# Copyright 2014 Dr Paul Brewer -- Economic and Financial Technology Consulting LLC
# This script is made available under the terms of the MIT LICENSE
# Intended as a helper for refactoring template-enhanced html
# warning: overwrites existing files.
# Does not delete or modify original file templates.html
# Thanks to Stack Overflow users for these helpful hints:
# use of htmlparser to unescape entities
# http://stackoverflow.com/a/21894821/103081
# http://stackoverflow.com/a/663128/103081
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@debasishg
debasishg / gist:8172796
Last active May 10, 2024 13:37
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@jhoff
jhoff / md5.js
Created November 27, 2013 18:27
Closure of Joseph's Myers md5 javascript implementation
/*
* http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
(function() {
var md5cycle = function(x, k) {
var a = x[0], b = x[1], c = x[2], d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);
@lisamelton
lisamelton / transcode-video.sh
Last active May 24, 2024 17:42
Transcode video file (works best with Blu-ray or DVD rip) into MP4 (or optionally Matroska) format, with configuration and at bitrate similar to popular online downloads.
#!/bin/bash
#
# transcode-video.sh
#
# Copyright (c) 2013-2015 Don Melton
#
about() {
cat <<EOF
$program 5.13 of April 8, 2015