Skip to content

Instantly share code, notes, and snippets.

View danriti's full-sized avatar

Dan Riti danriti

View GitHub Profile
@danriti
danriti / Gemfile
Last active December 30, 2015 23:28
Sinatra Example for TraceView Heroku Add-on
source "https://rubygems.org"
ruby "2.0.0"
gem 'sinatra'
group :production, :staging do
gem 'oboe-heroku', '~> 0.9.10.0'
end
@danriti
danriti / replace.sh
Last active December 28, 2015 19:39
Search and replace text in files
#!/bin/bash
git grep -l replaceMe | xargs sed -i 's/replaceMe/replace.me/g'
@danriti
danriti / json-stub.py
Created November 8, 2013 17:17
Quick JSON Stub in Python
# Useful way to stub an endpoint with JSON contained in a file.
import json
f = open('/path/to/file.json', 'r')
return json.load(f)
@danriti
danriti / sync.sh
Created August 30, 2013 00:41
Rsync two directories while ignoring existing files
rsync --ignore-existing --dry-run --verbose -r SOURCE/* DESTINATION

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@danriti
danriti / md2html.sh
Created June 4, 2013 15:19
Convert markdown to HTML
#!/bin/bash
# http://johnmacfarlane.net/pandoc/demos.html
pandoc -s README.md -o README.html
@danriti
danriti / ffmpeg.sh
Last active December 17, 2015 04:29
FFMPEG FOR THE WIN!
# List audio devices
ffmpeg -list_devices true -f dshow -i dummy
# Pipe audio from Line In to another computer (192.168.1.17)
ffmpeg -f dshow -i audio="Line In (High Definition Audio " -acodec libmp3lame -ab 320000 -f rtp rtp://192.168.1.17:1234
# Listen to audio on destination computer
ffplay rtp://192.168.1.17:1234
@danriti
danriti / README.md
Last active October 13, 2015 09:47
Git Deployment Post Receive

Instructions

Put your ssh key on the server:

$ ssh-copy-id username@remote-server.org

On the server, create a bare git repo:

$ mkdir website.git
@danriti
danriti / decorator.py
Created July 21, 2012 17:28
Django - Restrict access to a view to only active and authenticated users
from django.contrib.auth.decorators import user_passes_test, login_required
active_required = user_passes_test(lambda u: u.is_active,
login_url='/profile/not_active')
def active_and_login_required(view_func):
decorated_view_func = login_required(active_required(view_func))
return decorated_view_func