Skip to content

Instantly share code, notes, and snippets.

@mariochavez
mariochavez / jquery-ui-calendar.js
Created November 29, 2010 19:29
jquery-ui-calendar on Rails
$(document).ready(function() {
// Define the dateFormat for the datepicker
$.datepicker._defaults.dateFormat = 'dd M yy';
/**
* Sets the date for each select with the date selected with datepicker
*/
$('input.ui-date-text').live("change", function() {
var sels = $(this).siblings("select:lt(3)");
var d = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $(this).val() );
@mariochavez
mariochavez / accion.rb
Created November 30, 2010 19:21
Uso de PDFKit
def create
@modelo = Modelo.new(:params)
#generacion de HTML a partir de una vista de rails
html = render_to_string(:layout => false, :action => 'mi_formato.html.haml')
pdfKit = PDFKit.new html
#incluir un css para un mejor formato
pdfKit.stylesheets << 'public/stylesheets/pdf.css'
# rake db:seed:dump WITH_ID=1 FILE=db/site-seed.rb MODELS=Model, Model
namespace :db do
namespace :seed do
desc "Dump records from the database into db/seeds.rb"
task :dump => :environment do
# config
opts = {}
opts['with_id'] = !ENV["WITH_ID"].nil?
opts['no-data'] = !ENV['NO_DATA'].nil?
opts['models'] = ENV['MODELS'] || (ENV['MODEL'] ? ENV['MODEL'] : "")
@mariochavez
mariochavez / input.html
Created January 7, 2011 19:21
Ejemplo de html
<div class="input string required field_with_errors">
<span class="error">Por favor indique un título</span>
<label class="string required" for="job_title">Título <abbr title="requerido">*</abbr></label>
<input class="string required" id="job_title" maxlength="255" name="job[title]" size="50" type="text" value="">
<div class="hint">"Desarrollador Sr." o "Administrador de sistemas"</div>
</div>
@mariochavez
mariochavez / Demo
Created January 8, 2011 03:02
Curso de Rails
rails new demo
rails g scaffold evento name:string date:datetime
404 1463ms 1096cpu_ms 0kb Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16,gzip(gfe)
201.170.55.247 - - [18/Apr/2011:11:53:30 -0700] "GET / HTTP/1.1" 404 204 - "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16,gzip(gfe)" "tjbackhaul.appspot.com" ms=1464 cpu_ms=1097 api_cpu_ms=0 cpm_usd=0.030523 loading_request=1
I 2011-04-18 11:53:30.378
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
@mariochavez
mariochavez / routes.rb
Created May 20, 2011 23:13
Routes for config
namespace :admin do
match '/settings' => 'application_config#edit', :via => :get, :as => :settings
match '/settings' => 'application_config#update', :via => put, :as => :settings
end
class ApplicationController
include ResourceModel
end
--colour
-I app