Skip to content

Instantly share code, notes, and snippets.

View jphenow's full-sized avatar
💻
👋🏻 :octocat:

Jon Phenow jphenow

💻
👋🏻 :octocat:
View GitHub Profile
@jphenow
jphenow / .vimrc
Created May 4, 2011 20:20 — forked from jeresig/.vimrc
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on
@jphenow
jphenow / LogCat through GoSMS
Created July 1, 2011 13:08
Issues with sending SMS from third part Android App on Incredible 2
--------- beginning of /dev/log/main
06-30 15:55:41.043 D/DATA ( 1575): [QCTMM] DataNetStatistics sent == 0 && received == 0 newActivity=DORMANT
06-30 15:55:41.043 D/DATA ( 1575): sentSinceLastRecv=0,watchdogTrigger=10
06-30 15:55:41.393 D/dalvikvm( 2035): GC_EXPLICIT freed 3092 objects / 189552 bytes in 72ms
--------- beginning of /dev/log/system
06-30 15:55:41.943 I/ActivityManager( 1450): Starting activity: Intent { dat=content://mms-sms/conversations/4 cmp=com.jb.gosms/.ui.ComposeMessageActivity (has extras) }
06-30 15:55:42.043 D/DATA ( 1575): [QCTMM] DataNetStatistics sent == 0 && received == 0 newActivity=DORMANT
06-30 15:55:42.043 D/DATA ( 1575): sentSinceLastRecv=0,watchdogTrigger=10
06-30 15:55:42.073 D/com.jb@Mms/compose( 2460): [1] [az] loadDraft: call WorkingMessage.loadDraft
06-30 15:55:42.073 D/com.jb@Mms( 2460): [1] readDraftSmsMessage tid=4
@jphenow
jphenow / lpstat_email.py
Created July 10, 2011 22:42
Quick little script for Linux admins. Run periodically and setup to email someone with a description of printers that may happen to go down. Currently only written to run lpstat on localhost, so must be printers avilable to the localhost.
#! /usr/bin/python
"""
Description: Will run an lpstat -p and send an email to jtrutwin notifying him of a disabled printer, if there is one, so that he can take action.
TODO:
1) Add parameter to override the recipient of the email
2) Add functionality for only sending email when a printer hasn't been found to be disabled today - ie. email sent at 5am shouldn't be sent again if only that same printer is disabled as of 8am, should only send another email if another printer has been disabled or if the original printer has been disabled, enabled and re-disabled.
"""
import commands
@jphenow
jphenow / mywol.py
Created July 10, 2011 22:50
Little script for running Wake On LAN on a sqlite db of nodes. Must suppy a sqlite file with 'hostname', 'mac_addr', 'ip_addr' columns within a table 'client_info'. Must enable WOL in BIOS and there may still be issues, WOL can be finicky (mostly because
#!/usr/bin/python -u
# mywol.py
# TODO need to check that too many options aren't being mixed at once, some should be exclusive
import subprocess
import sqlite3
from subprocess import Popen, PIPE
from optparse import OptionParser
import sys
@jphenow
jphenow / notifier.py
Created October 7, 2011 02:05
Python script I use as a template for notification scripts that check various statuses or folders and email if there are changes
#! /usr/bin/python
"""
Checks a program you name below for conditions you also name below and emails either the default (below) or can be set at command runtime
"""
import commands
import smtplib
from email.mime.text import MIMEText
import json
from optparse import OptionParser
@jphenow
jphenow / rvm_setup.sh
Created October 25, 2011 17:40
Setup RVM, install ruby 1.9.2, setup default gemset and install Rails 3.1.1 and Bundler
#!/bin/bash
#
# This script is for settingup a usable rvm environment for ruby development
# Enables user to manage versions of ruby and sets of Gems in a clean manner
#
# Information on rvm is available at http://beginrescueend.com/
git="git"
rvm="rvm"
rvmdir="$HOME/.rvm"
@jphenow
jphenow / Gemfile
Created September 26, 2012 15:31
speeding up rails habtm inserts
gem "m2m_fast_insert"
@jphenow
jphenow / class_inheritance.rb
Last active October 13, 2015 15:37
Why isn't this default behavior?
def self.inherited(sub)
instance_variables.each do |field|
sub.instance_variable_set field, instance_variable_get(field)
end
end
@jphenow
jphenow / failed_specs.sh
Created December 5, 2012 19:50
My one liner for listing broken specs - which I open into vim
alias rr="rake spec | grep \"rspec.*#\" | awk '{ print \$2 }' | sed -e 's/\.rb:.*/\.rb/' | uniq"
# For vim I would do:
vim $(rr)
@jphenow
jphenow / .zshrc
Created December 19, 2012 16:42 — forked from ehlertij/.bash_profile
function title {
#[ "$DISABLE_AUTO_TITLE" != "true" ] || return
if [[ "$TERM" == screen* ]]; then
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" #set window name
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
fi
}