Skip to content

Instantly share code, notes, and snippets.

View emartini's full-sized avatar

Esteban Martini emartini

  • Chile
  • 14:28 (UTC -12:00)
View GitHub Profile
@emartini
emartini / find_upcoming_monday.rb
Created November 12, 2011 13:42
Find upcoming moday
Date.commercial(Date.today.year, 1+Date.today.cweek, 1)
@emartini
emartini / products_controller.rb
Created November 12, 2011 14:22
Rails controller for using 'valums/file-uploader' in IE9 and other
def upload_image
image = ProductImage.new
begin
# Set the path where images will be uploaded:
#IE9 sends a file:
unless params['qqfile'].is_a? String
upload_path = "#{image.tmp_path}/IE9_#{params['qqfile'].original_filename}"
@emartini
emartini / non_ascii.rb
Created December 10, 2011 18:57
remove all non 127-ASCII chars
class String
# remove all non 127-ASCII chars
def remove_non_ascii
n=self.split("")
self.slice!(0..self.size)
n.each { |b|
if b[0].to_i< 33 || b[0].to_i>127 then
self.concat('')
else
@emartini
emartini / sql_to_excel.rb
Created January 12, 2012 02:35
Create excel file from SQL query using mysql2 and spreadsheet
# How to create a excel file from any sql query
# @emartini86
# Based on basic documentation from required gems:
# https://github.com/brianmario/mysql2
# http://spreadsheet.rubyforge.org/file.GUIDE.html
require "rubygems"
require "mysql2"
require 'spreadsheet'
@emartini
emartini / config.ru
Created February 2, 2012 15:20
Mount Resque server in Rails 2.3 app
#Autor: emartini
require ::File.expand_path('../config/environment', __FILE__)
require "resque/server"
app_name = Rack::Builder.new do
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new
end
@emartini
emartini / application_controller.rb
Created February 16, 2012 13:48
Really simple breadcrumbs for Rails
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
include Breadcrumbs
# The rest of your application controller...
# ...
end
@emartini
emartini / README.md
Created March 23, 2012 13:44 — forked from necolas/README.md
Experimenting with component-based HTML/CSS naming and patterns

Template Components

Used to provide structural templates.

Pattern

t-template-name
t-template-name--modifier-name
t-template-name__subcomponent-name--subcomponent-modifier-name
@emartini
emartini / addMethod.js
Created April 5, 2012 13:05
For example, by augmenting Function.prototype, we can make a method available to all functions.
//from Javascript: The Goods Parts
// http://shop.oreilly.com/product/9780596517748.do
Function.prototype.method = function (name, func) {     
this.prototype[name] = func;     
return this;
};
@emartini
emartini / hack.sh
Created April 6, 2012 16:09 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@emartini
emartini / octave_install.sh
Created September 25, 2012 01:09
Octave installation - OSX 10.8
brew install gfortran;
export FC=/usr/local/bin/gfortran;
brew install octave;