Skip to content

Instantly share code, notes, and snippets.

View michaelwclark's full-sized avatar

Michael W Clark michaelwclark

View GitHub Profile
@michaelwclark
michaelwclark / ActiveRubyVer.sh
Created November 16, 2012 21:57
Command line command for getting current active version of Ruby. Tested on OSX 10.8.2 w/ zsh and iTerm2. RVM + iTerm = headaches. Hopefully this helps someone else out there..
#!/bin/bash -e
echo `ruby -v | sed 's/(.*//g' | sed 's/ruby//g' |sed 's/ //g' |sed 's/[ \t]*$//'`
# I realized after spending about 30 minutes on building up this command for my zsh Prompt that
# rvm_ruby_string contains the same thing.
# However, the reason I added this to my prompt is RVM kept giving me problems with not switching from OSX inbuilt ruby to the
# current environment...so adding an indicator always helps.
@michaelwclark
michaelwclark / Echo.rb
Created November 16, 2012 22:07
Ruby script I wrote to help me learn the language better. It is an echo like utility that utilizes english colors/modes for terminal output rather than complicated char codes. It's not fully polished or the most practical of tools, but it worked for what
#!/usr/bin/env ruby
#Usage:
# Echo.bold OutputString
#
# \e[z;XX;YYm
class TermFormat
@DEFAULTS ={
@michaelwclark
michaelwclark / GetPID.rb
Created November 16, 2012 22:43
Gets PID(s) of matching argument query if there are any and outputs them nicely with Echo.rb (git://gist.github.com/4091319.git).
#!/usr/bin/env ruby
class GetPid
#Main
ARGV.each do |arg|
puts `Echo.rb bold red "Query: #{arg}"`
pids=`ps aux | grep -v grep | grep #{arg} | awk '{print $2}'`.split("\n")
pids.each do |pid|
puts `Echo.rb bold blue "\tPID: #{pid}"`
end
@michaelwclark
michaelwclark / .gitconfig
Created November 19, 2012 14:58
Git Config. Includes colored logs, aliases, and MBC project specific info.
[user]
email = [email protected]
name = Michael Clark
[credential]
helper = osxkeychain
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
rmb = !sh -c 'git branch -D $1 && git push origin :$1' -
cob = checkout -b
up = !git fetch origin && git rebase origin/master
@michaelwclark
michaelwclark / default_syntax.py
Created December 4, 2012 17:28
Sets current project to updae default syntax for new files or unknown filetypes.
import sublime, sublime_plugin
class DefaultSyntaxCommand(sublime_plugin.EventListener):
def on_new(self, view):
view.set_syntax_file('Packages/Ruby/Ruby.tmLanguage')
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@michaelwclark
michaelwclark / fast-forward-mini-cal.php
Last active October 5, 2015 16:42 — forked from barryhughes/fast-forward-mini-cal.php
Revision for 'fast forward the calendar widget' code
<?php
/**
* Tries to force the minicalendar widget to show the month of the next upcoming event by default, rather
* than simply showing the current month (which might be empty).
*/
class Tribe_Advance_Minical
{
protected $target_date = false;
/**
@michaelwclark
michaelwclark / ThreeCol.html
Created October 6, 2015 19:46
Short Example of three col alignment.
<html>
<style type="text/css">
.container{width:400px;}
.container .element {width:33%; float:left;}
.blue {background:blue;}
.orange {background:orange;}
.gray {background: gray;}
</style>
<div class="container">
<div class="element blue">&nbsp;</div>
@michaelwclark
michaelwclark / WeekendTrip.js
Created March 19, 2017 23:06
This snippit can be run in your JS console in your browser. The output will be the weekend trip destination idea.
options = ['St Louis', 'KC', 'Omaha', 'Minneappolis','Branson', 'Nashville', 'Indy'];
votes = [0,0,0,0,0,0,0]
for(count = 0; count < 10; count++){
let idx = Math.floor(Math.random() * options.length)
votes[idx]++
}
document.open();
document.close();
document.write('Winner: ' + options[votes.indexOf(Math.max(...votes))])
@michaelwclark
michaelwclark / killPort.zsh
Created April 5, 2017 16:07
OSX El Capitan+ Kill process listening on port.
function killPort(){
lsof -i tcp:$1 | awk '{print $2}' | grep -v 'PID' | xargs kill
}