Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
@RichardBronosky
RichardBronosky / lock_your_screen
Created November 16, 2010 18:02
When a someone fails to lock their screen, curl this file and pipe it to bash to teach them a lesson.
# This is the one stop prank script for unattended Unix-like workstations.
# Use it with the simple one-liner:
# curl -L j.mp/__lys | bash
linux_specific(){
echo "Doing Linux-specific pwnage..."
true
}
@RichardBronosky
RichardBronosky / jquery oneliner
Created November 20, 2010 02:46
This is the shortest line of code for getting jquery into a js console (Chrome, Safari, Firefox, etc.)
($=document.createElement('script')).src='http://j.mp/jqueryjs';(document.getElementsByTagName('head')[0]).appendChild($)
function parse_git_branch {
local DIRTY=""
git diff --quiet HEAD &>/dev/null
case $? in
129)
# not a git repo, don't waste a second git command
return $?
;;
1)
DIRTY="⚡"
from django.contrib import admin
from django.contrib.auth.models import User
from pto.models import Request, Holiday
class HolidayAdmin(admin.ModelAdmin):
list_display = ('name', 'start_date')
list_display_links = ('name',)
class RequestAdmin(admin.ModelAdmin):
list_display = ('employee', 'start_date', 'end_date')
@RichardBronosky
RichardBronosky / nfs-setup.sh
Created February 1, 2011 17:45
setup your VirtualBox guest to export a folder to you host Mac
if [[ $(uname -a) = *Darwin* ]]; then
echo "Run this from your Linux guest, not your Mac";
else
sudo apt-get install nfs-kernel-server
sudo mkdir /export
sudo chmod a+rwx /export
mkdir /export/devel
sudo mount --bind $HOME/devel /export/devel
cat <<EOF | sudo tee -a /etc/fstab
from functools import wraps
from flask import request
import os
print 'TEST 1'
def cached(timeout=5 * 60, key='view/%s'):
print 'TEST 2'
def decorator(f):
print 'TEST 3'
@wraps(f)
cat << EOF > /tmp/ono
. /admin/bin/vm/vm_funcs.sh
load_prod_db
EOF
chmod +x /tmp/ono
screen /tmp/ono
@RichardBronosky
RichardBronosky / hash_tests.sh
Created April 28, 2011 18:04
A series of tests to find a viable solution for comparing directories between multiple hosts.
#!/usr/bin/env bash
# Create and cd into a new temp dir before running this series of tests.
p(){ echo; read -sn 1 -p "Press any key to continue..."; echo; echo;}
n(){ n=$1; echo -n "$ "; sed "$BASH_LINENO!d" $0; }
# Create
d=$(date +%y%m%d%H%M%S)
echo "Creating files...";
@RichardBronosky
RichardBronosky / userprofiles.admin.py
Created May 10, 2011 14:54
Django admin field order by m2m (or FK) relationship
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from userprofiles.models import UserProfile
class UserProfileInline(admin.StackedInline):
model = UserProfile
fk_name = 'user'
max_num = 1
@RichardBronosky
RichardBronosky / jquery.selectOptgroup.js
Created May 12, 2011 05:07 — forked from SmileyChris/jquery.selectOptgroup.js
Convert select boxes with optgroup elements into multiple select boxes. Registers itself as an onReady handler.
(function(jQuery) {
// adapted from the work of Chris Beaven https://gist.github.com/967775
jQuery.fn.selectOptgroup = function(options) {
var settings = jQuery.extend({
optSelect: '_options',
inBetween: '',
optBlank: null,
selectBlank: null,
keepOrphans: true,
showSpeed: 200