Skip to content

Instantly share code, notes, and snippets.

@cbess
cbess / AppNotify.swift
Last active August 10, 2019 15:58
Simple NSNotificationCenter wrapper for Swift 4.x
//
// AppNotify.swift
//
// Created by Christopher Bess on 6/30/15.
// MIT License
//
import Foundation
/// Represents the app notification.
"""
A file lock implementation that tries to avoid platform specific
issues. It is inspired by a whole bunch of different implementations
listed below.
- https://bitbucket.org/jaraco/yg.lockfile/src/6c448dcbf6e5/yg/lockfile/__init__.py
- http://svn.zope.org/zc.lockfile/trunk/src/zc/lockfile/__init__.py?rev=121133&view=markup
- http://stackoverflow.com/questions/489861/locking-a-file-in-python
- http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
- http://packages.python.org/lockfile/lockfile.html
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
<!DOCTYPE>
<html>
<head>
<title>Dissecting Gmail's Email Attachments - Dropping Files</title>
<style>
.msg {
display: none
}
.dragging .msg {
@simonw
simonw / setting-up-sublime-text-2.txt
Created July 11, 2012 12:35
Setting up Sublime Text 2
First, install it from http://www.sublimetext.com/2
Next, install the package control extension from here:
http://wbond.net/sublime_packages/package_control
Installation instructions here: http://wbond.net/sublime_packages/package_control/installation
Restart Sublime, then hit Shift+Apple+P and search for "Package Control: Install Package"
@ionrock
ionrock / lockfile.py
Created June 29, 2012 04:14
A file locking example
"""
A file lock implementation that tries to avoid platform specific
issues. It is inspired by a whole bunch of different implementations
listed below.
- https://bitbucket.org/jaraco/yg.lockfile/src/6c448dcbf6e5/yg/lockfile/__init__.py
- http://svn.zope.org/zc.lockfile/trunk/src/zc/lockfile/__init__.py?rev=121133&view=markup
- http://stackoverflow.com/questions/489861/locking-a-file-in-python
- http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
- http://packages.python.org/lockfile/lockfile.html
@joevennix
joevennix / add-to-home-screen.js
Created April 17, 2012 14:25
Add to home screen callout
// display "add to home screen" floater on iphones
// copy and paste this anywhere.
(function(){
if (document.cookie.match(/ADD_HOME_TOUCH=1/)) return;
document.addEventListener('DOMContentLoaded', function() {
if (navigator.userAgent.match(/iphone|ipod/i)) {
// create & inject css
var parent = document.body;
var arrowHeight = 56;
var bubbleHeight = 130;
@LeaVerou
LeaVerou / dabblet.css
Created April 17, 2012 05:57
Vertical centering with Flexbox + margin fallback
/**
* Vertical centering with Flexbox + margin fallback
* Lea Verou & David Storey
*/
html, body { height: 100%; }
body {
width: 100%; /* needed for FF */
margin: 0;
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
@ruckus
ruckus / gist:2293434
Created April 3, 2012 16:36
Basic setup of WAL-E for continuous archiving and recovery

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60