Skip to content

Instantly share code, notes, and snippets.

View rodriguezartav's full-sized avatar

Roberto Rodriguez rodriguezartav

View GitHub Profile
@lancejpollard
lancejpollard / less2stylus.coffee
Created February 9, 2012 19:33
Convert LESS to Stylus for Twitter Bootstrap
# Quick hack of regular expressions to convert twitter bootstrap from LESS to Stylus
less2stylus = (string) ->
string = string
.replace(/^(\ *)(.+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/^(\ *)([^\ \n]+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/\ *\{\ *\n*/g, "\n") # remove opening brackets again (some random cases I'm too lazy to think through)
.replace(/\ *\}\ *\n*/g, "\n") # remove closing brackets
.replace(/\;\ *?$/gm, "") # remove semicolons
.replace(/@(\w+):(\ *)\ /g, (_, $1, $2) -> # replace @variable: with $variable =
"$#{$1}#{$2} = "
@rodriguezartav
rodriguezartav / haml-mongo-application.rb
Created October 13, 2011 18:22
config/application.rb snippet for Haml and Mongomapper used by Rails Generators
#this goes in config/application.rb
#just before the closing "end" tag
#it tels rails generators to use Haml and Mongomapper
config.generators do |g|
g.orm :mongo_mapper # :active_record
g.template_engine :haml
g.stylesheet_engine = :sass
g.test_framework :rspec, :fixture => true, :views => false
end
@emk
emk / comet_client.coffee
Created September 19, 2010 03:39
Real-time Comet with Faye, Node.js and Coffee
# Client-side Comet code. See comet_server.coffee for instructions.
client = new Faye.Client '/faye', timeout: 90
# Attach a security key to all our subscription messages.
client.addExtension
outgoing: (msg, callback) ->
return callback(msg) unless msg.channel is '/meta/subscribe'
(msg.ext ?= {}).authToken = 'secret'
callback(msg)