Skip to content

Instantly share code, notes, and snippets.

View coffeeworks's full-sized avatar

Nicolas Gaivironsky coffeeworks

View GitHub Profile
@coffeeworks
coffeeworks / _modal.haml
Created March 5, 2013 06:12
opening twitter bootstrap modals
- no_sections ||= false
- callback ||= false
.modal.fade{:id => modal_id}
- if no_sections
= yield
- else
.modal-header
%a{:href => '#', :class => 'close', 'data-dismiss' => 'modal'}x
- if content_for?(:modal_header)
@coffeeworks
coffeeworks / custom.js
Created November 17, 2011 04:28
solares site tweaks
Event.observe(window, 'load', function() {
var img = $$('.property-picture img').first();
if(img){
img.src = "http://assets.moveglobally.com/organization_files/3867/Solares_001.jpg";
img.setStyle({
width: '820px',
height: 'auto'
});
img.up('.property-picture').setStyle({
width: 'auto',
@coffeeworks
coffeeworks / examples.rb
Created August 24, 2011 02:42
datamapper demo
Actor.count
Movie.count
Movie[0]
Movie[422]
Movie[100..110]
@coffeeworks
coffeeworks / 1_properties.rb
Created August 24, 2011 01:40
Slides con codigo
# ActiveRecord
# post.rb
class Post < ActiveRecord::Base
end
# 20110813001308_create_posts.rb
class CreatePosts < ActiveRecord::Migration
def self.up
@coffeeworks
coffeeworks / htmlsendmail
Created November 27, 2009 22:10
send html email with sendmail
(cat <<EOCAT
Subject: HTML Email
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
EOCAT
cat txt_file) | sendmail user@email.com
#!/usr/bin/env ruby
# put in /etc/munin/plugins and restart munin-node
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
def output_config
puts <<-END
graph_category App
graph_title Passenger memory stats
graph_vlabel count
class BaseClass
@@var = "BaseValue"
def var
@@var
end
end
class SubClass < BaseClass
@@var = "OverriddenValue"
var AutoGrowTextArea = Class.create({
initialize: function(textarea){
this.textarea = textarea;
this.line_height = parseInt(textarea.getStyle('lineHeight')) || 15;
this.max_height = parseInt(textarea.getStyle('maxHeight')) || 600;
this.min_height = parseInt(textarea.getStyle('minHeight')) || 100;
// set default style
this.textarea.setStyle({
@coffeeworks
coffeeworks / gist:86233
Created March 26, 2009 18:25
Bash Tricks
We couldn’t find that file to show.