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 / 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 / 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

RAILS_RELATIVE_URL_ROOT

Rails

By default RAILS_RELATIVE_URL_ROOT is used only for asset pipeline.

To namespace your rails routes you need to wrap run MyApp::Application with map in your config.ru:

map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
# app/cells/museo_table_view_cell.rb
class StyledCell < UITableViewCell
attr_accessor :image_cell, :title_cell, :subtitle_cell
#stylesheet :main_screen
def layoutSubviews
p title_cell
p subtitle_cell
@michelson
michelson / picker_with_search_row.rb
Last active January 1, 2016 17:18
Formotion Picker with search bar
module Formotion
module RowType
class PickerWithSearchRow < PickerRow
include RowType::ItemsMapper
def after_build(cell)
super
@items_for_search = items
keyboardDoneButtonView = UIToolbar.new
keyboardDoneButtonView.barStyle = UIBarStyleBlack
default: build
build:
./make.sh build
run:
./make.sh run
deps:
@michelson
michelson / time_parser.go
Created July 17, 2014 20:33
parse time string like 1.minutes, 2.minutes , 3.hours , 3.hrs
package main
import(
"time"
"strings"
"strconv"
"fmt"
"errors"
)
package main
import (
"bytes"
"flag"
"fmt"
//"log"
"os"
"os/exec"
"strings"
@michelson
michelson / test_mail_catcher.rb
Created August 3, 2015 20:44
mail catcher for rails env
if Rails.env.test?
class MailCatcher
def self.create(opts)
File.open("#{Rails.root}/tmp/mailcatcher/mail-#{Time.now.to_i}.html", 'w') do |f|
f.write(opts[:body].raw_source)
end
end
end
@michelson
michelson / blender-cheatsheet.md
Created January 24, 2016 19:29
Blender Hotkeys Cheatsheet-Tufts OCW Blender Design 2.6x

Blender Hotkeys Cheatsheet-Tufts OCW Blender Design 2.6x

General

  • ESC Stops ongoing operation
  • TAB Toggles Edit/Object mode
  • ZKEY Toggles Solid/Wireframe display
  • CTRL-Z Undo
  • SHIFT-CTRL-Z Redo
  • CTRL-N Open New Default File