Skip to content

Instantly share code, notes, and snippets.

View foucist's full-sized avatar

James Robey foucist

View GitHub Profile
@foucist
foucist / gist:575421
Created September 11, 2010 18:25 — forked from crcx/gist:575177
better word names?
with quotes'
( compare two strings from the beginning and return how many )
( similar characters there are before the strings diverge. )
: ^match ( $$-n )
0 -rot repeat @+ [ swap @+ ] dip =if rot 1+ -rot else 2drop ;then again ;
( test each word in the dictionary for similarity. if similar up )
( to the current point, add to the suggestions queue. )
create list here , 100 allot

Retro Style Guide

Author: Charles Childers
Date: September 12, 2010

Formatting

@foucist
foucist / gist:3656032
Created September 6, 2012 13:03
rvm --trace install 1.8.7
+__rvm_parse_args:778> [[ -n 4.3.11 ]]
+__rvm_parse_args:810> [[ -z '' && -n '' ]]
+__rvm_parse_args:812> [[ 0 -eq 1 || -n '' ]]
+__rvm_parse_args:14> [[ -n install ]]
+__rvm_parse_args:16> rvm_token=install
+__rvm_parse_args:18> (( 1 > 0 ))
+__rvm_parse_args:20> next_token=1.8.7
+__rvm_parse_args:21> shift
+__rvm_parse_args:26> case install ([[:alnum:]]*|@*)
+__rvm_parse_args:30> case install (use)
@foucist
foucist / gist:4127990
Created November 21, 2012 21:40 — forked from wmoxam/gist:4127672
Spiral Fun - slight refactoring
def method(grid,root,rev = false)
grid.send(rev ? :reverse_each : :each) do |row|
row.send(rev ? :<< : :unshift, @num)
@num += 1
end
new_row = []
root.times do
new_row.send(rev ? :unshift : :<<, @num)
@num += 1
#
# Regular Expression for URL validation
#
# Converted Diego Perini's regexp to ruby
#
# Author: James Robey
# Updated: 2013/02/07
#
# Credits to Matt (mparodi)
#
$(document).ready ->
$(".simple_form").on("ajax:success", (e, data, status, xhr) ->
$(".list").append xhr.responseText
).bind "ajax:error", (e, xhr, status, error) ->
$(".list").prepend xhr.responseText
class UserSerializer < ActiveModel::Serializer
attributes :id, :name, :phone, :email, :balance, :children, :balance
def attributes
data = super
data[:children] = User.find(data[:id]).subordinates.any?
data
end
end
@foucist
foucist / result
Last active May 3, 2016 00:55
generate table of times
- days = 0..7
- hours = 8..18
%table
- days.each do |d|
%th= (Time.now + d.day).strftime("%A")
- hours.each do |h|
%tr
- days.each do |d|
%td= Time.parse("0001-01-01 #{h}:00:00 UTC").strftime '%l %p'
class Gear
attr_reader :chainring, :cog, :wheel
def initialize(chainring, cog, rim, tire)
@chainring = chainring
@cog = cog
@wheel = Wheel.new(rim, tire)
end
def ratio
chainring / cog.to_f
end
@foucist
foucist / testing.md
Created April 3, 2014 19:21
Just A Test

Markdown

Whatever