Skip to content

Instantly share code, notes, and snippets.


Myles Eftos madpilot

View GitHub Profile
madpilot / icons.rake
Created Apr 17, 2015
Rake task to generate font icons from a folder full of SVGs
View icons.rake
require 'fileutils'
RANGE = (0xe000...0xf8ff);
def map_fonts(src, map_file)
map = {
'meta' => {
'author' => "Redbubble"
'font' => {
getMyIP() {
local _ip _myip _line _nl=$'\n'
while IFS=$': \t' read -a _line ;do
[ -z "${_line%inet}" ] &&
_ip=${_line[${#_line[1]}>4?1:2]} &&
[ "${_ip#}" ] && _myip=$_ip
done< <(LANG=C /sbin/ifconfig)
printf ${1+-v} $1 "%s${_nl:0:$[${#1}>0?0:1]}" $_myip
madpilot / blueprints.rb
Created Feb 22, 2010
Some sample test setup files
View blueprints.rb
require 'machinist/active_record'
require 'sham'
require 'faker'
Sham.define do
title { Faker::Lorem.words(2).join(' ') }
permalink { Faker::Lorem.words(2).join('-') }
status(:unique => false) do
when 0:
View gist:333732
if Rails.env == 'production' && File.exists?(File.join(Rails.root, 'REVISION'))
revision =, 'REVISION')).strip
ActionController::Base.asset_host = "{revision}"
module Sass::Script::Functions
def url(string)
if Rails.env == 'production' && File.exists?(File.join(Rails.root, 'REVISION'))
revision =, 'REVISION')).strip
path = string.value
View gist:480932
// Create a file on your desktop, enter the code, and then open it LOCALLY in your browser
// This works...
var http = new XMLHttpRequest();
var url = "";
var params = "<data></data>";"POST", url, true);
// This doesn't...
View gist:519205
require 'test_helper'
class SyncTest < Test::Unit::TestCase
include TestHelper
context 'SyncTest' do
setup do
View how_to_teach_method_missing.rb
class SmokeyTheBear
def method_missing(symbol, *args)
responses = [ :me, :you ]
if responses.include?(symbol)
what_was_said = symbol.to_s
what_was_meant = responses.dup.delete_if { |r| r == symbol }.first.to_s
return "You chose '#{what_was_said}' referring to '#{what_was_meant}'. That is incorrect. The correct answer is '#{what_was_meant}'."
madpilot / base_record.rb
Created Dec 1, 2010
Base Record - allows you to use validations without active model in rails 2.3.x
View base_record.rb
class BaseRecord
attr_accessor :values
def self.fields(fields)
BaseRecord.field_list = fields
def self.field_list=(field_list)
@field_list = field_list
madpilot / index.html
Created Sep 16, 2011
Client side i18n tranlation demo
View index.html
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>i18n Demo</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
var languages = {
en: {
madpilot / gist:1407763
Created Nov 30, 2011
Replay an AJAX request if the first one failed due to an authentication error
View gist:1407763
statusCode: {
403: function() {
// This calls a backbone view that renders a login window, then
// calls the success function one the user has been authenticated
// The call back simply re-runs $.ajax using the current context object,
// which conveniently is a hash of the original AJAX request params.
var sessionLogin = new SessionsLoginView();
var context = this;