Skip to content

Instantly share code, notes, and snippets.

@alx
alx / deploy-bot.rb
Created November 15, 2010 16:27
jabber bot to deploy rails app
#!/usr/bin/env ruby
require 'rubygems'
require 'jabber/bot'
# Create a new bot
bot = Jabber::Bot.new({
:name => 'Git Rails Bot',
:jabber_id => '[email protected]',
:password => 'same-password-everywhere',
:master => ["[email protected]"],
@ijt
ijt / http_get.go
Last active August 21, 2024 05:11
Example of using http.Get in go (golang)
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
@carlhoerberg
carlhoerberg / Rakefile.rb
Created May 17, 2011 19:33
How to do automatic backup with Heroku PGBackups and Heroku Cron. http://carlhoerberg.com/automatic-backup-of-heroku-database-to-s3
require 'aws/s3'
require 'heroku'
require 'heroku/command'
require 'heroku/command/auth'
require 'heroku/command/pgbackups'
task :cron do
class Heroku::Auth
def self.client
Heroku::Client.new ENV['heroku_login'], ENV['heroku_passwd']
@mbostock
mbostock / .block
Last active February 26, 2019 22:38
Marimekko Chart
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-marimekko-chart
@gmonfort
gmonfort / debian6-rvm-ree-gems.erb
Created June 6, 2011 05:28
bootstrap a debian 6 node with rvm and ree patched to avoid SSLv2 issues
# Debian 6 bootstrap template file for chef
#
# Installs RVM and ruby enterprise edition (ree) patched to workaround
# issues with SSLv2 in debian systems (SSLv2 is deprecated)
#
# Also only installs ruby dependencies listed in `rvm notes`
#
# RVM is installed system-wide in /usr/local/rvm
#
# Usage:
@aliang
aliang / mymodel.rb
Created June 13, 2011 06:25
render from model in Rails 3
# yes, sometimes you need to do this. you get pilloried in a forum if you
# ask about it, though!
# this code taken from
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/
class MyModel < ActiveRecord::Base
# Use the my_models/_my_model.txt.erb view to render this object as a string
def to_s
ActionView::Base.new(Rails.configuration.paths.app.views.first).render(
@mheffner
mheffner / README.md
Created June 20, 2011 23:06
Setting up syslog logging on Heroku with Sinatra 1.2.x

Setting up syslog logging on Heroku with Sinatra 1.2.x

1. Update your Gemfile to include:

gem 'remote_syslog_logger'

2. Add the file remote_syslog.rb below to your Sinatra app as lib/remote_syslog.rb.

3. Modify your config.ru to match the example one below.

@namelessjon
namelessjon / user.rb
Created June 21, 2011 22:14
Example user with a BCrypt password
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation
timestamps :at
property :id, Serial
@exoer
exoer / db_server.rb
Created July 4, 2011 17:58 — forked from coderanger/db_server.rb
Create postgres users and databases from Chef
include_recipe "postgresql::server90"
# inspiration from
# https://gist.github.com/637579
execute "create-root-user" do
code = <<-EOH
psql -U postgres -c "select * from pg_user where usename='root'" | grep -c root
EOH
command "createuser -U postgres -s root"