Skip to content

Instantly share code, notes, and snippets.

View ethnt's full-sized avatar
🐢

Ethan Turkeltaub ethnt

🐢
View GitHub Profile
@lipchyk
lipchyk / gist:667549
Created November 8, 2010 10:15
Using timestamps in MongoMapper Embedded document
class Foo
include MongoMapper::EmbeddedDocument
plugin MongoMapper::Plugins::Timestamps
belongs_to :bar
key :bar_id, ObjectId
#...
timestamps! #voila!
end
@ethnt
ethnt / SOPA.markdown
Created January 18, 2012 15:26
Down with SOPA!

Yesterday, I made this site redirect to SOPA Strike in opposition of SOPA (Stop Online Piracy Act) and PIPA (Protect IP Act). I am vehemently opposed to such draconian, broad bills such as these.

If you don't know, SOPA and PIPA aim to shut down sites that are infringing upon American intellectual property such as music, movies, photos, and books.

That idea is sound, but the methods and language that the bills use are morally and ethically wrong. Sites that are found to be infringed by industry organizations (like the RIAA and MPAA) can be shut down without due process or chance for an appeal. The DMCA (Digital Millennium Copyright Act) handles this by providing "safe harbor" to social networking sites such as Facebook, Twitter and YouTube. But under SOPA or PIPA, these sites would be gone from the Internet.

These bills allow the United States to assert control over all domestically registered domains (.com, .net, .org, et cetera). Any international site that infringes upon

@dirk
dirk / state_machine.rb
Last active December 17, 2015 05:38
The only state machine I'll (probably) ever need.
class StateMachine
def initialize
@transitions = {}
end
def transition(opts, &block)
from = opts[:from]
to = opts[:to]
@transitions[from] ||= {}
@transitions[from][to] = block
end
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@inertialbit
inertialbit / ansible-ubuntu-ruby-playbook.yml
Created January 21, 2013 18:10
installs rbenv via rbenv-installer, ruby matching $ruby_version and passenger + apache2 module to $user home and updates $user/.bash_profile w/ rbenv env vars
---
- name: install rb-installer
action: shell curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
- name: update PATH in ~/.bash_profile for rb-env
action: lineinfile dest=/home/$user/.bash_profile line=export\ PATH="$HOME/.rbenv/bin:$PATH" regexp=PATH.*rbenv
- name: add rb-env init to ~/.bash_profile
action: lineinfile dest=/home/$user/.bash_profile line='eval "$(rbenv init -)"' regexp=eval.*rbenv
#!/usr/bin/env ruby
$: << File.dirname(__FILE__)+'/lib'
require 'benchmark/ips'
require 'fast_blank'
class String
# active support implementation
def slow_blank?
/\A[[:space:]]*\z/ === self
end
@sawyerh
sawyerh / blogs_controller.rb
Created June 24, 2016 14:08
Siteleaf on S3 + Rails
class BlogsController < ApplicationController
def index
@slug = params[:slug]
@file = AWS::S3.new.buckets['YOUR-SITELEAF-BUCKET-HERE']
.objects[File.join('blog', @slug.to_s, 'index.html')]
unless @file.exists?
puts @file.key
raise ActionController::RoutingError.new('Not Found')
end
@ethnt
ethnt / Media.markdown
Created December 10, 2011 03:29
All of the media.

This is all the media that I would like, have but need to be converted to *.m4a or *.m4v, and holes in my collection. To see what I currently do have, look at Tree.txt.

In order to create the directory tree, use the following command in the Media directory.

ls -R | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/' > Tree.txt && mv Tree.txt .Manifest/

Music

  • Disney Parks — Disney's Electrical Parade
@cannikin
cannikin / README.md
Last active March 28, 2019 16:08
Typical Ruby on Rails AWS Server Setup

Typical Ruby on Rails AWS Server Setup

You should be able to start a fresh EC2 instance of Ubuntu and follow the instructions below to get a server with your preferred version of Ruby, nginx ready to delegate requests to Unicorn, and logrotate setup to keep your disk from filling up with log files. You will also have ruby-install for installing new rubies and chruby for switching between them. A .ruby-version file will be added to the home directory of the user that runs this script.

Install

  1. Start an EC2 instance using the latest Ubuntu image (as of 2015-06-18 ami-5189a661 for EBS, 64-bit SSD)
  2. Copy the config files below into /tmp using the file names specified in the title.
  3. Edit /tmp/setup.sh and change the variables at the top to match your setup
  4. Make /tmp/setup.sh executable: chmod +x /tmp/setup.sh
@jodosha
jodosha / Gemfile
Last active December 9, 2020 15:09
Full stack Lotus application example
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'