Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Lifton aaronlifton

View GitHub Profile
@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/
View s3_folder_upload.rb
#!/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
@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.
View mastodon assets-precompile-on-other-machine.sh
# 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' mastodon@server.example.com:/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 / describe_ec2_instances.sh
Created September 27, 2017 00:48
describe ec2 instances in all regions
View describe_ec2_instances.sh
for region in `aws ec2 describe-regions --output text | cut -f3`
do
echo -e "\nListing Instances in region:'$region'..."
aws ec2 describe-instances --region $region
done
@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
View installing-node-for-ubuntu-with-nvm.md
@aaronlifton
aaronlifton / routes.elm
Created May 30, 2017 19:52 — forked from hallettj/routes.elm
Example of a graph in Elm
View routes.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 / Enhance.js
Created May 30, 2017 18:08 — forked from sebmarkbage/Enhance.js
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@aaronlifton
aaronlifton / optparse-template.rb
Created May 17, 2017 21:00 — forked from rtomayko/optparse-template.rb
Ruby optparse template
View optparse-template.rb
#!/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 / extended_original_payment.rb
Created May 2, 2017 19:48
extending spree original payment reimbursement type
View extended_original_payment.rb
module Spree::ReimbursementType::ExtendedOriginalPayment
def self.included(base)
class << base
include ClassMethods
end
end
module ClassMethods
def reimburse(reimbursement, return_items, simulate)
if simulate
@aaronlifton
aaronlifton / callbacks.rb
Created May 2, 2017 18:41
active support callbacks example
View callbacks.rb
class V
include ActiveSupport::Callbacks
define_callbacks :derp
set_callback :derp, :after, :after_derp
attr_accessor :x
def derp
run_callbacks :derp do
@x = 1
puts @x
end