Skip to content

Instantly share code, notes, and snippets.

View danriti's full-sized avatar

Dan Riti danriti

View GitHub Profile

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@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
@danriti
danriti / comments.js
Last active April 30, 2018 20:50
Display all hidden inline comments on a Github issue/pull request. Just copy+pasta into your JS console or make a bookmarklet.
$('.outdated-diff-comment-container').addClass('open');
@danriti
danriti / hipchat-v2.sh
Last active July 19, 2021 10:49
HipChat API v2 - Send a message to a room using cURL
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
@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 / 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 / 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 / pickaxe.sh
Created December 13, 2013 18:42
Search git log for a specific code change.
git log -S"validate=True" -- boto/s3/connection.py
@danriti
danriti / README.md
Last active February 26, 2022 07:20
Line Profiling in Python

Install the line_profiler module:

[driti@ubuntu ]$ pip install line_profiler

Add the @profile decorator and run:

[driti@ubuntu ]$ kernprof.py -l -v example.py
@danriti
danriti / pi.py
Last active August 29, 2015 13:57 — forked from Py-Gon-Gin/pi.py
#!/usr/bin/env python
import sys
import subprocess
def print_wiki_options(file) :
subprocess.call("clear")
with open(file, 'r') as f :
for line in f:
sys.stdout.write(line)