Skip to content

Instantly share code, notes, and snippets.

View mcamiano's full-sized avatar

Mitch Amiano mcamiano

  • Rolesville, North Carolina, USA
View GitHub Profile
@mcamiano
mcamiano / libmigrations.sh
Last active August 29, 2015 14:07
SQL migrations with bash
#!/bin/bash
test "$1" = "--rollback" || test "$1" = "down"
export is_rollback="$?"
if ${no_run_libmigrations_twice:-true}
then
no_run_libmigrations_twice=false
if [[ -z "$DATABASE" ]]; then read -p "Database? " DATABASE; fi
@mcamiano
mcamiano / conundrum.rb
Created September 22, 2011 01:59
Conundrum, sample of UTF-8 in Ruby 1.9.2
# encoding: utf-8
# conundrum.rb
alias :λ :lambda
alias :Ω :abort
module Enumerable
alias :⇔ :collect
alias :∉ :reject
alias :∈ :select
alias :∫ :inject
@mcamiano
mcamiano / hyper-schema.js
Created December 21, 2011 17:44
Visualize a JS Schema by mapping to XML
/* this is a lot of probably unnecessary crap brought in from Compass.
*/
@import url(http://fonts.googleapis.com/css?family=Nixie+One:400);
@import url(http://fonts.googleapis.com/css?family=Cabin:500);
/* line 17, ../../../.rvm/gems/ruby-1.9.2-p0@global/gems/compass-0.11.1/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@mcamiano
mcamiano / jQuery Contrasty plugin
Created January 13, 2012 14:14
An example of: jQuery+CDN+plugin+QUnit for the WCAG 2.0 contrast algorithm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Contrast Checking Plugin</title>
<style type="text/css">
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
@mcamiano
mcamiano / joomlaOneTimePad.php
Created April 9, 2012 02:41
One-shot status update for Joomla 1.5* component (not tested)
<?php
/**
* @package One-time pad signal script
* @description Feedback signal via HTTP GET or POST using a one-time pad communicated through a separate process, as an alternative to the convoluted Joomla! 1.5.x XMLRPC feature.
* @version 1.0
* @copyright Copyright 2010 by Mitchell Amiano All Rights Reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* */
// place this script in a non-Web accessible location, then require it from a wrapper script
@mcamiano
mcamiano / OneOffQuery.php
Created April 9, 2012 18:55
One-off PHP/mySql Query
<?php
/**
* @package One-off mySQL Query in PHP via mysqli
* @description Express a query as an object in PHP
* @version 1.0
* @copyright Copyright 2010 by Mitchell Amiano All Rights Reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* */
@mcamiano
mcamiano / enumerable_nil.txt
Created April 16, 2012 14:04
Enumerable nil
$ rails c
nLoading development environment (Rails 3.2.1)
1.9.3p0 :001 > nil
=> nil
1.9.3p0 :002 > nil.nil?
=> true
1.9.3p0 :004 > nil.each
@mcamiano
mcamiano / wunderground_inquiry.rb
Created May 9, 2012 16:59
Weather Underground Ruby Sample; Show current temps in F, download radar animation gif and launch Safari to view it
#!/usr/bin/env ruby
# See http://api.wunderground.com/weather/api/d/documentation.html
require 'open-uri'
require 'json'
zip=ARGV[0]||27571
apikey=YOURWUGAPIKEYHERE
open("http://api.wunderground.com/api/#{apikey}/conditions/forecast/q/#{zip}.json") do |f|
json_string = f.read
@mcamiano
mcamiano / .rvmrc
Created May 9, 2012 18:29
"Controller" and routes for weather underground inquiry via Sinatra
rvm use ruby-1.8.7-p302@sinatra
@mcamiano
mcamiano / _vimrc
Created May 15, 2012 18:09
Installing VIM under Windows
set nocompatible
set backupdir=~/tmp " keep vim's temp files out of your repos
" Use pathogen to easily modify the runtime path to include all plugins under
" the ~/.vim/bundle directory
filetype off " force reloading *after* pathogen loaded
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
filetype plugin indent on " enable detection, plugins and indenting in one step