Skip to content

Instantly share code, notes, and snippets.

View brianwebb01's full-sized avatar

Brian Webb brianwebb01

View GitHub Profile
@brianwebb01
brianwebb01 / remote_pw_update.rb
Created January 26, 2011 12:41
Update a password on a remote system via SSH using ruby of course
require 'rubygems'
require 'net/ssh'
def update_remote_password(hostname, port, username, password, newpassword, print_output=false)
begin
Net::SSH.start( hostname, username, :password => password, :port => port ) do |session|
command = "passwd"
@brianwebb01
brianwebb01 / gist:1080161
Created July 13, 2011 11:49
Wigwam CMS relationships example Liquid code.
{% for school in custom_modules.schools.records %}
<h1>{{ school.name }}</h1>
<p>{{ school.description }}</p>
<p><b>Students:</b></p>
<ul>
{% for student in school.students %}
<li>{{ student.name }}</li>
{% endfor %}
@brianwebb01
brianwebb01 / gist:1826288
Created February 14, 2012 11:53
Get MySQL DB size
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
@brianwebb01
brianwebb01 / gist:2000752
Created March 8, 2012 12:17
Convert existing rails migration code to new script/generate command
data = <<EODATA
t.string :physical_address
t.string :physical_address2
t.string :physical_city
t.integer :physical_state_id
t.string :physical_postal_code
t.integer :physical_country_id
t.string :billing_address
t.string :billing_address2
t.string :billing_city
@brianwebb01
brianwebb01 / mysql-describe-regex.rb
Created March 22, 2012 18:21
Regex to run on the output of $mysql> describe {table}; to get each column's data for some other use... maybe code generation. (remove first 3 lines of mysql output)
data = <<EODATA
| id | int(11) | NO | PRI | NULL | auto_increment |
| physical_address | varchar(255) | YES | | NULL | |
| physical_address2 | varchar(255) | YES | | NULL | |
| physical_city | varchar(255) | YES | | NULL | |
| physical_state_id | int(11) | YES | | NULL | |
| physical_postal_code | varchar(255) | YES | | NULL | |
| physical_country_id | int(11) | YES | | NULL | |
| billing_address | varchar(255) | YES | | NULL | |
| billing_address2 | varchar(255) | YES | | NULL | |
@brianwebb01
brianwebb01 / mysql-describe-to-ios-properties.rb
Created March 22, 2012 18:45
iOS property, synthesize and dealloc output generated from MySQL describe table output
data = <<EODATA
| id | int(11) | NO | PRI | NULL | auto_increment |
| status_id | int(11) | YES | | NULL | |
| project_type_id | int(11) | YES | | NULL | |
| physical_address | varchar(255) | YES | | NULL | |
| physical_address2 | varchar(255) | YES | | NULL | |
| physical_city | varchar(255) | YES | | NULL | |
| physical_state_id | int(11) | YES | | NULL | |
| physical_postal_code | varchar(255) | YES | | NULL | |
| physical_country_id | int(11) | YES | | NULL | |
@brianwebb01
brianwebb01 / gist:2375894
Created April 13, 2012 11:07
Ubuntu 11.10 terminal color custom colors and bash prompt
Setting: Text Color = #D0DDDE
Setting: Background Color = #133441
PS1=\n\[\033[1;31m\]\u\[\033[0;96m\]@\h: \[\033[1;92m\]\w\n\[\033[1;30m\]→ \[\033[0m\]
@brianwebb01
brianwebb01 / .bash_profile
Created May 9, 2013 14:22
OS X .bash_profile entry to color and format the bash prompt as: user@host: pwd [gitrepo(*)] →
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\n\[\033[1;31m\]\u\[\033[0;96m\]@\h: \[\033[1;92m\]\w \[\033[1;33m\]$(parse_git_branch)\n\[\033[1;33m\]→ \[\033[0m\]'
@brianwebb01
brianwebb01 / .tmux.conf
Created May 9, 2013 16:36
My tmux.conf 5/8/2013
# set prefix to Ctrl-a
set -g prefix C-a
unbind C-b
# reduce delay btwn chars in cmd seq
set -s escape-time 1
# increase repeat time for better multi-hits of cmd
set repeat-time 1000
<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{