Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Lifton aaronlifton

View GitHub Profile
@aaronlifton
aaronlifton / s3_folder_upload.rb
Last active Apr 17, 2019 — 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
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 Sep 27, 2017
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
View installing-node-for-ubuntu-with-nvm.md
@aaronlifton
aaronlifton / routes.elm
Created May 30, 2017 — 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 — 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() {
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
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
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