Skip to content

Instantly share code, notes, and snippets.

from abc import ABC, abstractmethod
class PickleCache(ABC):
"""Cache Python objects on disk to save on API calls
Clients can treat this class like a key/value store. The fetch() method
must be overridden to fetch a value from the API for a specific key.
Then subclasses can be used as in this example:
cache = SubclassedPickleCache(filepath)
#!/bin/sh
#
# This script automatically runs 'make' whenever any of the LaTeX files in
# this directory are saved. Open the PDF file you want to view in the
# background, and run this script in the shell. Every time you save a
# LaTeX file, the LaTeX will be recompiled and an updated version of the PDF
# will be displayed in your PDF viewer.
#
@snim2
snim2 / stat.md
Last active August 29, 2015 14:26

stat.h

Based on: sys/stat.h

Field Size Offset Note
ST_DEV 2 0 dev_t is a u short
ST_INO 2 2 ino_t is a u short
ST_MODE 4 4 mode_t is a u int
### Keybase proof
I hereby claim:
* I am snim2 on github.
* I am snim2 (https://keybase.io/snim2) on keybase.
* I have a public key whose fingerprint is 194B B3F0 4F1A 6987 24D6 ACED 46D2 1328 8DF5 C798
To claim this, I am signing this object:
@snim2
snim2 / screenie-howto.md
Created February 22, 2015 20:47
Instructions on how to create an animated git of a shell session

How to produce an animated gif

Step 1: Record a terminal session

$ ttyrec myrecording.tty

Press Ctrl+d when finished.

@snim2
snim2 / interp.py
Last active August 29, 2015 14:07
Pylab interpolation example
{
"metadata": {
"name": "Heatmap example"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@snim2
snim2 / keywords.tex
Created August 25, 2014 14:56
Example LaTeX listings with mixed alphanumeric keywords
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{listings}
\renewcommand{\ttdefault}{pcr}
\definecolor{Black}{gray}{0.0}
\definecolor{Blue}{rgb}{0.12,0.29,0.53}
@snim2
snim2 / tocloft_example
Last active August 29, 2015 14:05
An example use of tocloft and IEEE format
%
% http://tex.stackexchange.com/questions/197369/how-to-use-tocloft-to-create-a-list-which-appears-in-the-middle-of-the-document
%
% http://tex.stackexchange.com/questions/198326/tocloft-cross-references-a-section-as-a-subsection
%
\documentclass[conference]{IEEEtran}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage[titles]{tocloft}

Creating the post-commit file

Note: If you want to use your personal Twitter account to post commits, go to Step 2

  1. Create a new Twitter account for your commit messages. Example
  2. Go to http://dev.twitter.com and Sign In with your Twitter account you are posting commit messages to.
  3. Hover over your username in the top-right corner after signing in and select "My Applications"
  4. Create a new application
  5. The name, description, and site can all be whatever you want, but leave Callback URL empty
  6. Under "Application Settings" click "modify app permissions" next to "Access level"
#!/bin/bash
# Usage Example: $ clone-github github_id
# would clone all the git repositories managed under github_id at current path
# save it as /etc/profiles/a.github.sh
##
clone-github(){
GITHUB_ID=$1
GITHUB_REPO_URI="https://github.com/"$GITHUB_ID"?tab=repositories"
repos=`curl -skL $GITHUB_REPO_URI | grep 'title="Forks"' | sed "s/.*$GITHUB_ID\///" | sed 's/\/network"\stitle="Forks">//'`