Skip to content

Instantly share code, notes, and snippets.

View topfunky's full-sized avatar
🛠️

Geoffrey Grosenbach topfunky

🛠️
View GitHub Profile
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
require 'rubygems'
require 'benchmark/ips'
class ExampleClass
def foo; 42; end
end
module ExampleMixin
def foo; 43; end
end
@bakkdoor
bakkdoor / while_else.fy
Created December 15, 2012 19:57
Sample implementation of while loop with additional else branch, if loop doesn't get executed (in Fancy).
class Object {
def while: condition do: body else: alternative {
if: (condition call) then: {
body call
while: condition do: body
} else: alternative
}
}
# usage:
@josevalim
josevalim / 0_README.md
Created September 13, 2012 21:52
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

Given: this rspec file is in PROJECT_ROOT/spec

describe 'codebase' do
  let(:lines_with_more_than_80_characters) do
    Dir.glob( File.expand_path('../../lib/**/*.rb', __FILE__ ) ).map do |path|
      File.open( path ) do |file|
        idx = 0
        file.lines.map do |line|
          idx += 1
require "minitest/autorun"
class ZOMGIO < Struct.new(:io)
def puts str = nil
return io.puts str unless str =~ /\[([\/\w.]+):(\d+)\]:\n/
io.print $`
io.print $&
io.puts "> #{File.readlines($1)[$2.to_i - 1].strip}"
io.puts $'
@juliocesar
juliocesar / localstorage.js
Created April 8, 2011 00:44
Backbone.js localStorage if specified
// Generate four random hex digits.
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
// Generate a pseudo-GUID by concatenating random hexadecimal.
function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
};
# When anything, including nil, is a valid param and you need
# a clear way to know if a param was set or not.
def foo a, b = (b_was_not_passed = true; nil)
result = [a]
result << b unless b_was_not_passed
result
end
# When anything, including nil, is a valid param and you need
# a clear way to know if a param was set or not, use `None`.
None = Object.new
def foo(a, b=None)
result = [a]
if b != None
result << b
end
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'