Skip to content

Instantly share code, notes, and snippets.

View aaronlifton's full-sized avatar

Aaron Lifton aaronlifton

View GitHub Profile
@aaronlifton
aaronlifton / base_controller.rb
Created March 28, 2017 22:20 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@aaronlifton
aaronlifton / Gemfile
Created April 19, 2017 17:38 — forked from skolf/Gemfile
A Rake task for precompiling assets in a Sinatra app using Sprockets.
source 'http://rubygems.org'
# app base
gem 'logger'
gem 'rack'
gem 'sinatra'
gem 'sinatra-assetpack'
gem 'sprockets'
gem 'sprockets-helpers'
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@aaronlifton
aaronlifton / optparse-template.rb
Created May 17, 2017 21:00 — forked from rtomayko/optparse-template.rb
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@aaronlifton
aaronlifton / Enhance.js
Created May 30, 2017 18:08 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@aaronlifton
aaronlifton / routes.elm
Created May 30, 2017 19:52 — forked from hallettj/routes.elm
Example of a graph in Elm
import Html exposing (text)
import List exposing (concatMap, filter)
import List.Extra exposing (uniqueBy)
type alias CityId = Int
type alias City =
{ id: CityId
, name: String
}
@aaronlifton
aaronlifton / installing-node-for-ubuntu-with-nvm.md
Created September 11, 2017 20:26 — forked from d2s/installing-node-with-nvm.md
Installing Node.js for Ubuntu with nvm
@aaronlifton
aaronlifton / mastodon assets-precompile-on-other-machine.sh
Created November 2, 2017 06:38 — forked from skoji/mastodon assets-precompile-on-other-machine.sh
Mastodon : execute assets:precompile on a local machine.
# on the mastodon server
cd /home/mastodon/live
git checkout <release tag>
docker-compose pull && docker-compose build && docker-compose stop
# on the local machine
rsync -trzv --delete --rsync-path='sudo rsync' [email protected]:/home/mastodon/live/ backup # get full backup
cd backup
docker-compose pull && docker-compose build && docker-compose run --rm web rails assets:precompile
cd ..
@aaronlifton
aaronlifton / s3_folder_upload.rb
Last active April 17, 2019 21:23 — forked from fleveque/s3_folder_upload.rb
Upload folder to S3 recursively with ruby, multi threads and aws-sdk v2 gem, based on http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively/
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket, :include_folder
attr_accessor :files
# Initialize the upload class