Skip to content

Instantly share code, notes, and snippets.

View gabrielengel's full-sized avatar

Gabriel Engel gabrielengel

View GitHub Profile
@gabrielengel
gabrielengel / bootstrap101.html
Created August 24, 2011 03:58
Testing Bootstrap from Twitter
<html>
<head>
<title>Need Wisdom?</title>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap-1.1.0.min.css">
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/docs.css">
<style>
.sidebar { background: #eee;}
.filler {background: #ff3; height: 20px; border: thin solid #999;}
</style>
</head>
@gabrielengel
gabrielengel / tabuada.rb
Created November 9, 2011 01:16
Tabuaba de 1 a 10
(1..10).each do |y|
(1..10).each do |x|
print (y * x).to_s.rjust(4)
print " | "
end
puts
end
@gabrielengel
gabrielengel / strftime_nolocale.rb
Created December 6, 2011 16:42
How strftime_nolocale works
require 'date'
puts Time.now.respond_to?(:strftime_nolocale)
class Time
Date::ABBR_DAYNAMES = %w(dom seg ter qua qui sex sab)
alias :strftime_nolocale :strftime
def strftime(format)
format = format.dup
@gabrielengel
gabrielengel / upload_to_cloudfiles.rb
Created April 17, 2012 19:13
Upload folders into Rackspace Cloudfiles
# encoding : utf-8
#
# Author: Gabriel Engel
# Based on: https://github.com/rackspace/cloudfiles
#
require 'rubygems'
require 'cloudfiles'
# Configure Here
@gabrielengel
gabrielengel / clone_remote.rb
Created April 20, 2012 19:00
Rake Clone Remote (production) Database - Mysql or Postgresql
#!/usr/bin/env rake
clone = {
db_host: "user@server",
rdbms: "postgresql", # postgresql or mysql
prod_db: "db",
prod_user: "user",
prod_pass: "pass",
dev_db: "localdb",
dev_user: "user",
@gabrielengel
gabrielengel / start_server.sh
Created May 25, 2012 05:43
Install Nginx, Unicorn & ruby 1.9.3
#!/usr/bin/env bash
# Setup a ubuntu 12.04 LTS machine with nginx, unicorn, ruby 1.9.3
# RUN: curl -L http://goo.gl/M8SXl | bash
mkdir ~/server ; cd ~/server
wget https://github.com/gabrielengel/chef-ubuntu/tarball/master
tar -zxf master
cd gab*
mv dna.aws-sample.json dna.json
@gabrielengel
gabrielengel / symbol_array.rb
Created November 15, 2012 14:02
Get Symbol Array from a String
def symbol_array_from_string(value)
regex = /\[((:([^ ,\]])+) *,{0,1} *)+\]/
return value unless value =~ regex
value.scan(/:[^ ,\]]+/).map{|v| v.gsub(/^:/,'').to_sym}
end
result = symbol_array_from_string("[:a, :apple,:dog]")
result == [:a, :apple, :dog]
/*
wysihtml5 v0.4.0pre + autoresize On Chrome
https://github.com/xing/wysihtml5
Author: Christopher Blum (https://github.com/tiff)
Copyright (C) 2012 XING AG
Licensed under the MIT license (MIT)
Rangy, a cross-browser JavaScript range and selection library
/**
* @license wysihtml5 v0.4.0pre
* https://github.com/xing/wysihtml5
*
* Author: Christopher Blum (https://github.com/tiff)
*
* Copyright (C) 2012 XING AG
* Licensed under the MIT license (MIT)
*
*/
// Editor specific listener
editor.on("aftercommand:composer", resize); // Set bold, italic, etc
editor.on("change_view", resize); // Change wysi/source view
// Typing listeners
editor.on("newword:composer", resize); // Only way to observe on firefox
editor.on("undo:composer", resize);
editor.on("paste", resize);
iframeBody.addEventListener('keyup', resize, false);
iframeBody.addEventListener("keydown", resize, false);