Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢

Ethan Turkeltaub ethnt

🐢
View GitHub Profile
@sawyerh
sawyerh / blogs_controller.rb
Created June 24, 2016 14:08
Siteleaf on S3 + Rails
View blogs_controller.rb
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
View benchmark
#!/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
@cannikin
cannikin / README.md
Last active March 28, 2019 16:08
Typical Ruby on Rails AWS Server Setup
View README.md

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
View Gemfile
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'
@dbreunig
dbreunig / ReporterSaveFileDescription.md
Last active January 22, 2021 16:07
A description of the data written to the Reporter App Dropbox save folder.
View ReporterSaveFileDescription.md

#Reporter Save File Schema

##The Reporter Export File

Reporter saves to your Dropbox account with plaintext JSON files, one for each day. When a Report is entered in the app a file is created for that day if it does not exist. Otherwise, the report is appended to the existing file. The save folder is located in 'Dropbox/Apps/Reporter-App/'.

Reporter save files are named according to the following convention:

YYYY-MM-DD-reporter-export.json
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
View build_frontend.sh
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@jbenet
jbenet / simple-git-branching-model.md
Last active March 16, 2023 15:34
a simple git branching model
View simple-git-branching-model.md

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@konklone
konklone / ssl.rules
Last active August 3, 2022 15:13
nginx TLS / SSL configuration options for konklone.com
View ssl.rules
# Basically the nginx configuration I use at konklone.com.
# I check it using https://www.ssllabs.com/ssltest/analyze.html?d=konklone.com
#
# To provide feedback, please tweet at @konklone or email eric@konklone.com.
# Comments on gists don't notify the author.
#
# Thanks to WubTheCaptain (https://wubthecaptain.eu) for his help and ciphersuites.
# Thanks to Ilya Grigorik (https://www.igvita.com) for constant inspiration.
server {
@dirk
dirk / state_machine.rb
Last active December 17, 2015 05:38
The only state machine I'll (probably) ever need.
View state_machine.rb
class StateMachine
def initialize
@transitions = {}
end
def transition(opts, &block)
from = opts[:from]
to = opts[:to]
@transitions[from] ||= {}
@transitions[from][to] = block
end
@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
View ansible-ubuntu-ruby-playbook.yml
---
- 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