Skip to content

Instantly share code, notes, and snippets.

def delete_letter
@user = User.find(params[:id])
@user.remove_letter!
@user.save!
render :show
end
---
[:delete_letter, :dl_copy, :payment_proof].each do |meth|
@jteneycke
jteneycke / deploy_prep.sh
Last active August 29, 2015 14:20
rails vps deployment without ripping your eyes out
# create a deploy user, and add them to sudoers
adduser deploy
gpasswd -a deploy sudo
# generate a key so you can just pop it on your github and pull your repo down from there
ssh-keygen -t rsa -C "your_email@example.com"
# test the connection so it adds the key to your authorized hosts list
ssh -T git@github.com
# add the phussion passenger package server key, and binaries source to to your apt packages list
@wridgers
wridgers / .tmux.conf
Created February 7, 2012 16:05
tmux config file
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
# Reload key
bind r source-file ~/.tmux.conf
set -g history-limit 1000
@borkdude
borkdude / main.cljs
Created September 28, 2014 19:54
Nested wizard example in reagent
;; Create a new project with
;; lein new liberagent reagent-complex-gui-example
;; and replace main.cljs with this file
(ns reagent-complex-gui-example.main
(:require-macros [cljs.core.async.macros :refer (go)])
(:require
[reagent.core :as reagent :refer [atom]]
[sablono.core :as html :refer-macros [html]]
[cljs-http.client :as http]
@statique
statique / installation.sh
Created September 25, 2012 19:18
Setup Ubuntu 12.04 Web Server for Apache Passenger Rails RBEnv Postgres Memcache
# rbenv inspired by https://gist.github.com/1441139
# make sure running as root user
apt-get -y update
apt-get install linux-headers-2.6.32-5-amd64
apt-get -y upgrade
apt-get -y install curl git-core python-software-properties build-essential git-core curl libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev libcurl4-openssl-dev libxslt-dev libxml2-dev
# add-apt-repository
curl -o /usr/sbin/add-apt-repository http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txtchmod o+x /usr/sbin/add-apt-repository
@aaronjensen
aaronjensen / strong_parameters.rb
Created October 30, 2012 20:03
Force strong parameters
# Place in config/initializers
ActiveRecord::Base.class_eval do
class << self
def inherited_with_strong_params(sub)
inherited_without_strong_params(sub)
# Filter out plugin models that won't work with strong_parameters yet
unless sub.name =~ /^doorkeeper/i
sub.send :include, ActiveModel::ForbiddenAttributesProtection
end
end
@plapier
plapier / js2coffeescript.rb
Last active December 14, 2015 02:59
Convert Javascript to CoffeeScript (vice versa) directly from vim. Uses js2coffee library.
#!/usr/bin/env ruby
require 'tempfile'
file = Tempfile.new(['js2coffee', '.js'])
file.write ARGF.read # write vim selection to tmp file
file.rewind
file.close
puts `js2coffee #{file.path}` # requires js2coffee
file.unlink # deletes the temp file
@mattclar
mattclar / simple_form.rb
Last active December 21, 2015 13:58 — forked from tommarshall/simple_form.rb
this is a simple form initializer that is ALMOST compatible with Bootstrap3 apart from a way to set the class of the label this would work perfectly
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
# https://github.com/plataformatec/simple_form/issues/316
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
@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=
@epitron
epitron / proxy_controller.rb
Created December 13, 2013 19:28
Turn a Rails controller into a web-proxy (web.archive.org-style)
require 'pp'
class ProxyController < ApplicationController
# Example headers:
# {"GATEWAY_INTERFACE"=>"CGI/1.1",
# "PATH_INFO"=>"/proxy/http:/google.com",
# "QUERY_STRING"=>"",
# "REMOTE_ADDR"=>"127.0.0.1",
# "REMOTE_HOST"=>"127.0.0.1",