Skip to content

Instantly share code, notes, and snippets.

@iMilnb
iMilnb / snsread.py
Created August 2, 2015 20:20
Basic Flask snippet to handle AWS SNS messages and subscription
from flask import Flask, request
import requests
import json
app = Flask(__name__)
def msg_process(msg, tstamp):
js = json.loads(msg)
msg = 'Region: {0} / Alarm: {1}'.format(
js['Region'], js['AlarmName']
@sjl
sjl / ext.vim
Created December 15, 2014 18:58
ways to run external commands in vim
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
@m3nu
m3nu / md2pdf.py
Last active November 21, 2016 18:34
md2pdf - Command line Markdown to PDF converter with support for CSS stylesheets and custom fonts
#!/usr/bin/env python
import os
import sys
from markdown2 import markdown
from xhtml2pdf import pisa
"""
## Inspired by
#!/usr/bin/ruby
# Requirements:
# - rb-dayone and doing gems installed for the system Ruby.
# (Mine (OSX 10.10) are in /Library/Ruby/Gems/2.0.0/gems/)
#
# How to run:
# $./dayone-to-doing.rb 0A8BE4BB9F7E40B5A6F3F621797FC6F5.doentry
# The parameter passed to the script is the doentry file that was just created.
# The script will:
@gruber
gruber / make_bookmarklet.pl
Last active May 5, 2024 21:11
JavaScript Bookmarklet Builder
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@kstrauser
kstrauser / freezewheels.py
Created August 29, 2013 17:45
This works like a hypothetical "pip freezewheels" that makes wheels of all installed packages.
#!/usr/bin/env python
"""
Build wheels of all currently installed packages (as listed by "pip freeze")
"""
import glob
import importlib
from subprocess import call
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@miohtama
miohtama / gist:5158737
Created March 14, 2013 04:11
Colorful Python logger
# -*- coding: utf-8 -*-
"""
Python logging tuned to extreme.
"""
__author__ = "Mikko Ohtamaa <mikko@opensourcehacker.com>"
__license__ = "MIT"
@almet
almet / supergenerator.py
Last active December 14, 2015 13:58
Exemple of plugin for pelican defining a new reader.
from pelican import signals
from pelican.readers import EXTENSIONS, Reader
class NewReader(Reader):
enabled = True
file_extensions = ['yeah']
def read(self, filename):
metadata = {'title': 'Oh yeah',