Skip to content

Instantly share code, notes, and snippets.

View michelson's full-sized avatar
🏠
Working from home

Miguel Michelson Martinez michelson

🏠
Working from home
View GitHub Profile
@michelson
michelson / async_resque.rb
Created June 9, 2012 15:10
Use async methods for Sidekiq & Resque
# -*- encoding : utf-8 -*-
module AsyncResque
extend ActiveSupport::Concern
included do
include Sidekiq::Worker
def perform(*args)
self.class.find(args.first).send(args.last)
end
end
@michelson
michelson / check_boxes_input.rb
Created April 5, 2012 21:56
Formtastic check boxes with awesome_nested_set
# put this file in any autoloaded path on rails app. HINT: app/inputs/check_boxes_input.rb
class CheckBoxesInput < Formtastic::Inputs::CheckBoxesInput
def to_html
unless options[:nested_set]
super
else
nested_wrapping(options)
end
@michelson
michelson / gist:1368246
Created November 15, 2011 20:33
fast deploy in rails 3.1
# comment out "deploy/assets" in your capfile, we are doing this locally
namespace :noumad do
desc "Compress assets in a local file"
task :compress_assets do
run_locally("rm -rf public/assets/*")
run_locally("bundle exec rake assets:precompile")
run_locally("touch assets.tgz && rm assets.tgz")
Uploadizr = $.klass({
initialize: function(submiter , path ){
//console.log("picker!! " +submiter+" "+$(this.element).attr("token")+" "+path);
var current_id = "";
var token = $(this.element).attr("token")
var uploader = new plupload.Uploader({
runtimes : "html5",
browse_button : $(this.element).attr("id"),
max_file_size : '10mb',
url : path,
@michelson
michelson / gist:986130
Created May 23, 2011 02:38 — forked from gma/gist:674141
Bluepill config for resque
ENV["PATH"] = "/opt/ruby/bin:#{ENV['PATH']}"
ENV["RAILS_ENV"] = "production"
ENV["QUEUE"] = "*"
Bluepill.application("nichelator") do |app|
app.working_dir = "/var/apps/nichelator/current"
app.uid = "app"
app.gid = "app"
2.times do |i|
app.process("resque-#{i}") do |process|
@michelson
michelson / gist:805882
Created February 1, 2011 13:55
examples for lazy high chart
##### controllers
@time_chart = HighChart.new('chart_tag') do |f|
f.chart({:zoomType =>'x', :defaultSeriesType => 'spline'})
f.title(:text => 'Flower Market')
f.x_axis({:type =>'datetime'})
f.y_axis({:title => 'flowers'})
chart_begin_js = "Date.UTC(#{@last_x_days[0].year}, #{@last_x_days[0].month-1}, #{@last_x_days[0].day})"
f.series(:name => 'violets', :data => generate_numbers(number), :pointInterval => 24*3600*1000)
f.series(:name => 'sunflowers', :data => generate_numbers(number), :pointInterval => 24*3600*1000)
end
require 'net/pop'
module Mailman
class Receiver
# Receives messages using POP3, and passes them to a {MessageProcessor}.
class POP3
# @return [Net::POP3] the POP3 connection
attr_reader :connection
// togglea values de inputs
InputValueHelper = $.klass({
initialize: function(){
this.initial_value = $(this.element).val()
},
onblur: function(){
if($(this.element).val() == '') {
$(this.element).val(this.initial_value);
}
# ----------------------------------------------
# Class for Youtube (youtube.com)
# http://www.youtube.com/watch?v=25AsfkriHQc
# ----------------------------------------------
class VgVimeo
def initialize(url=nil, options={})
# general settings
curl = Curl::Easy.new('http://metrik.tricdev.com:3000/tablero')
curl.perform
curl.cookies = session_id
curl.perform
puts curl.perform.body_str