Skip to content

Instantly share code, notes, and snippets.

View gabrielengel's full-sized avatar

Gabriel Engel gabrielengel

View GitHub Profile
window.Timer = {
countdown: function(minutes,seconds){
var currentTime = new Date().getTime();
Timer.finishTime = currentTime + (minutes * 60 * 1000) + (seconds * 1000);
Timer.running = setInterval("Timer.ended()",1000)
},
ended: function(){
var currentTime = new Date().getTime();
console.log('Now: ' + currentTime + ' - ends: ' + Timer.finishTime);
@gabrielengel
gabrielengel / edit.html
Created April 27, 2015 20:00
Edit CSS Here
<a href='javascript:el=document.createElement("style");el.style.display="block";el.style.position="absolute";el.style.bottom="0";el.style.right="0";el.style.left="0";el.style.background="#fff";el.contentEditable=true;el.innerHTML="body{background: lightgreen;}";document.body.appendChild(el);event.preventDefault();'>
Edit CSS
</a>
@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 / 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)
*
*/