Skip to content

Instantly share code, notes, and snippets.

View lodestone's full-sized avatar
:octocat:
🤘Grokking Out 🤘

Matthew Petty lodestone

:octocat:
🤘Grokking Out 🤘
  • Kizmeta
  • Kansas City Area, Missouri
  • 22:42 (UTC -12:00)
View GitHub Profile
@lodestone
lodestone / dice.rb
Last active December 19, 2015 04:09
Simulate dice rolls and generate command line graphs of statistical breakdowns of result sets.
# This allows me to generate output as follows.
#
# For a DiceSet:
#
# <DiceSet:
# @set: [d8=>7, d10=>5, d12=>2, d8=>8, d6=>1]
# @results: {}>
#
# > d=Dice.instance
# > ds=DiceSet.new [d^8, d^10, d^12, d^8]
@lodestone
lodestone / cookies.js
Last active December 18, 2015 00:49
Easy javascript cookie manipulation
var Cookie = {
read: function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
@lodestone
lodestone / install.sh
Created May 19, 2013 09:44
rbenv install ruby 2.0.0-p195 on Mac OS X 10.8 with openssl installed via brew (works for me)
CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195
@lodestone
lodestone / keypad.html.haml
Created April 1, 2013 18:06
Gratuitous Ruby Use #4742
%div#keypad
- (1..9).each do |i|
%div.button{:class => (i % 3 == 1) ? 'first' : ''}= i
@lodestone
lodestone / photo_stream_sync.rb
Last active December 15, 2015 07:19
photo_stream_sync.rb
#!/usr/bin/env ruby
require 'logger'
logfile = Time.now.strftime('%Y%m%d')
logfile = "/tmp/photo_sync_#{logfile}.log"
`touch #{logfile}`
$logger = Logger.new(logfile)
USER = 'matt'
class PhotoStream
@lodestone
lodestone / production.log
Created February 10, 2013 15:24
Getting this from labrador...
Psych::BadAlias (Unknown alias: test):
lib/labrador/adapter.rb:82:in `database_yml_config'
lib/labrador/adapter.rb:43:in `configuration'
lib/labrador/adapter.rb:102:in `valid?'
lib/labrador/app.rb:102:in `block in find_adapters_from_path'
lib/labrador/app.rb:96:in `each'
lib/labrador/app.rb:96:in `find_adapters_from_path'
lib/labrador/app.rb:84:in `initialize'
lib/labrador/app.rb:26:in `new'
lib/labrador/app.rb:26:in `block in find_all_from_path'
@lodestone
lodestone / eoc.rb
Created August 27, 2012 19:25
Using `EOC` in ruby code scripts.
# Using <<`EOC` in the manner lets you run a longer script from within Ruby easily.
print <<`EOC`
echo "This one is for the bitches"
echo "This ones is too"
EOC
@lodestone
lodestone / bad_example.rb
Created August 1, 2012 14:48
An example of the type of examples I hate to see.
class A
def z
puts 'z'
end
end
module B
def z
puts "Z"
end
@lodestone
lodestone / editscript.rb
Created July 7, 2012 22:47 — forked from ttscoff/editscript.rb
Fuzzy CLI file search through configured directories, ranked results displayed as menu
#!/usr/bin/env ruby
# encoding: utf-8
# == Synopsis
# Proof of concept using Fuzzy File Finder to locate a script to edit
# Searches a set of predefined locations for a fuzzy string
# e.g. "mwp" matches both "myweatherprogram" and "mowthelawnplease"
# ................on "(m)y(w)eather(p)rogram" and "(m)o(w)thelawn(p)lease"
#
# Results are ranked and a menu is displayed with the most likely
# match at the top. Editor to be launched and directories to search
@lodestone
lodestone / syntax_highlighting.py
Created April 11, 2012 15:53 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()