Skip to content

Instantly share code, notes, and snippets.

@dysinger
dysinger / docker-ruby-fpm.sh
Last active August 29, 2015 13:56
Stop using rbenv & rvm on servers. plz. kthnx.
cat > Dockerfile <<\EOF
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y ruby1.9.3 build-essential \
libc6-dev libffi-dev libgdbm-dev libncurses5-dev \
libreadline-dev libssl-dev libyaml-dev zlib1g-dev
RUN gem install fpm --bindir=/usr/bin --no-rdoc --no-ri
RUN apt-get install -y curl
RUN curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p484.tar.gz|tar oxzC /tmp
WORKDIR /tmp/ruby-1.9.3-p484
@defunkt
defunkt / test-spec-mini.rb
Created November 16, 2008 10:34
test/spec/mini 3
##
# test/spec/mini 3
# http://gist.github.com/25455
# chris@ozmm.org
# file:lib/test/spec/mini.rb
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
##
# This small script is an example of what you can do with the superfeedr :
# we monitor a few feeds with superfeedr and when, these feeds actually have
# new messages, we are posting them to a twitter account.
require "rubygems"
require "twitter"
require "superfeedr"
#############################################################
@dalibor
dalibor / gist:293474
Created February 3, 2010 08:26
JavaScript Micro-Templating
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
// http://ejohn.org/blog/javascript-micro-templating/
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
#!upstart
description "redis"
start on runlevel [23]
script
export HOME="/home/redis"
exec sudo -u redis /home/redis/redis-2.0.0-rc1/redis-server /home/redis/redis-2.0.0-rc1/redis.conf
end script
# Get your spec rake tasks working in RSpec 2.0
require 'rspec/core/rake_task'
desc 'Default: run specs.'
task :default => :spec
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
!!!
%html
%head
%title YourAwesomeApp
= stylesheet_link_tag :all
= javascript_include_tag :defaults
= csrf_meta_tag
%body
= yield
@radar
radar / intro.md
Created September 29, 2010 04:06

Ruby Intro - Setlist

  • no fucking semi-colons (unless you really want them)
  • irb
  • local variable definition
  • +, *, /, - are all methods
  • puts vs print
  • multiplying strings
  • using if & when
  • defining a method
window.addEventListener "DOMContentLoaded", ->
body = $ "body"
canvas = $ "#canvas"
chalkboard = $ "#chalkboard"
close = $ "#close"
ledge = $ "#ledge"
lightswitch = $ "#lightswitch"
output = $ "#output"
shade = $ "#shade"
share = $ "#share"