Skip to content

Instantly share code, notes, and snippets.

@dominikwilkowski
dominikwilkowski / README.md
Last active October 19, 2020 03:52
Ubuntu setup with NGINX http/2 and letsencrypt

Intro

This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.

Basics

After creating the server (droplet on DigitalOcean) log in with

@flonath
flonath / index.md
Last active April 4, 2016 15:18 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@toobulkeh
toobulkeh / deploy.rb
Created January 2, 2014 02:42 — forked from benedikt/rails.rb
Updated for Capistrano 3.
# encoding: UTF-8
# Place in config/deploy.rb
namespace :rails do
desc "Open the rails console on each of the remote servers"
task :console do
on roles(:app) do |host| #does it for each host, bad.
rails_env = fetch(:stage)
execute_interactively "ruby #{current_path}/script/rails console #{rails_env}"
@skozz
skozz / devise_authentication_api.rb
Last active January 14, 2025 04:40 — forked from marcomd/gist:3129118
Authenticate your API with Devise gem, token by header. Ruby on Rails 4. Read the comments.
#Session controller provides a token
#/controllers/api/sessions_controller.rb
class Api::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :except => [:create]
before_filter :ensure_params_exist, :except => [:destroy]
respond_to :json
def create
resource = User.find_for_database_authentication(:email => params[:user_login][:email])
return invalid_login_attempt unless resource
@sanjayginde
sanjayginde / Attachment_from_remote_url_with_Paperclip.md
Last active May 17, 2016 14:25 — forked from jgv/gist:1502777
Support setting a Paperclip attachment from a remote URL with a generic mixin for Rails

See also: http://almosteffortless.com/2008/12/11/easy-upload-via-url-with-paperclip/

Forked from: https://gist.github.com/1502777

The goal was a more generic solution to the one in gist this is forked from. It does not require the addition of any more db columns, as I choose not to store the remote URL.

Currently missing, is validation of the remote URL and error handling. Probably makes sense to just work with ActiveRecord::Errors

Currently, the file upload takes precedence over the the remote url, if a user supplies both. I'm thinking that should probably be an option flag on can_attach_remote_url.

@utf
utf / Installing RVM Ruby Rails Passenger nginx on CentOS
Created August 11, 2012 00:32 — forked from fytzzz/Installing RVM + Ruby + Rails + Passenger + nginx on CentOS
Installing RVM + Ruby + Rails + Passenger + nginx on CentOS
#Steps to install RVM + Ruby 1.9.3 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Todo get up to date repo's
# Install git and curl, if not already installed
sudo yum install git
sudo yum install curl-devel
# Create the rvm group and add any users who will be using rvm to the group
sudo su -
@rstacruz
rstacruz / index.md
Last active August 2, 2025 18:42
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end