Skip to content

Instantly share code, notes, and snippets.

@rhettc
rhettc / .pryrc
Last active August 29, 2015 13:56
def app_path
unless @app_path
git_root = `git rev-parse --show-toplevel`.chomp
@app_path = $?.success? ? git_root : Dir.pwd
end
@app_path
end
class Exception
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@rhettc
rhettc / pgactivity
Created April 16, 2014 23:37
Show open connections to databases in a brief format conducive to CLI usage
SELECT procpid as pid,
usename as user,
datname as db,
application_name as app, waiting as wait, current_query as query
FROM pg_stat_activity
WHERE datname <> 'postgres';
const int c = 261;
const int d = 294;
const int e = 329;
const int f = 349;
const int g = 391;
const int gS = 415;
const int a = 440;
const int aS = 455;
const int b = 466;
const int cH = 523;
@rhettc
rhettc / big_consumers.sh
Created September 15, 2014 19:05
disk usage
du -chd1 -t1G
# include grand total, friendly sizes, max depth 1, greater than 1G
@rhettc
rhettc / Program.cs
Last active August 29, 2015 14:08 — forked from anonymous/Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TemplateFoo
{
class Program
{
@rhettc
rhettc / gist:ba33e5b58b2dcf0c0c04
Created November 17, 2014 22:15
use find to duplicate the parent directory’s structure into the current directory, files are not copied
# given the structure
../foo/bar
../fizz/bang
../beep
# move into the beep child dir and run the command
cd beep
find ../ -mindepth 1 -type d -printf "%P\0" | xargs --null mkdir
# now beep has the same structure
./foo/bar
./fizz/bang
MAKEDEV.i686 3.24-6.6.amzn1 installed
PyYAML.i686 3.09-5.5.amzn1 installed
acl.i686 2.2.49-4.8.amzn1 installed
acpid.i686 1.0.10-2.1.6.amzn1 installed
alsa-lib.i686 1.0.21-3.8.amzn1 installed
apr.i686 1.3.9-3.8.amzn1 @amzn-main
apr-devel.i686 1.3.9-3.8.amzn1 @amzn-main
apr-util.i686 1.3.9-3.9.amzn1 @amzn-main
apr-util-ldap.i686 1.3.9-3.9.amzn1
@rhettc
rhettc / gitconfig
Created June 5, 2013 20:12
git color config
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
@rhettc
rhettc / ember-sample.js
Last active December 30, 2015 23:39
A look at controllers and templates
// Establishing routes
<script type="text/javascript">
Notes.Router.map(function () {
this.resource('notes', {path: "/"}, function() {
this.route('note', {path: "/note/:note_id"});
});
});
Notes.NotesRoute = Ember.Route.extend({
// Note here where we are "setting the subject for the index action"