Skip to content

Instantly share code, notes, and snippets.

View tacitphoenix's full-sized avatar

Samson Ondiek tacitphoenix

View GitHub Profile
@tacitphoenix
tacitphoenix / add_example_code.sh
Created August 8, 2020 10:45
A script to add example repos to a companion practice repo
#!/bin/bash
BOOK_REPO=<git url to example repo>
EXCODE=temp/example_code
# make top-level temp directory
mkdir -p ../$EXCODE
# add top-level temp directory to gitignore
if ! grep -q $EXCODE ../.gitignore; then
@tacitphoenix
tacitphoenix / aws-ec2-docker.sh
Created August 4, 2020 12:03
Docker ready ec2 instance
#!/bin/bash
# update and dependencies
sudo yum update -y
sudo yum install docker -y
# start docker
sudo service docker start
@tacitphoenix
tacitphoenix / aws-codedeploy-install.sh
Created August 1, 2020 00:23
Install codedeploy agent on an ec2 instance in us-east-1 region
#!/bin/bash
# update and dependencies
sudo yum update -y
sudo yum install ruby -y
sudo yum install wget -y
# install codedeploy agent
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
@tacitphoenix
tacitphoenix / stress.sh
Created July 31, 2020 23:17 — forked from mikepfeiffer/stress.sh
Install Stress Utility on Amazon Linux 2
sudo amazon-linux-extras install epel -y
sudo yum install stress -y
@tacitphoenix
tacitphoenix / apache2.sh
Created July 31, 2020 14:48 — forked from mikepfeiffer/apache2.sh
EC2 Bootstrap Script for Apache v2
#!/bin/bash
yum update -y
yum install -y httpd
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id)
echo "<h1>Hello World from $instanceId</h1>" > /var/www/html/index.html
systemctl start httpd
systemctl enable httpd
@tacitphoenix
tacitphoenix / apache.sh
Created July 30, 2020 18:24 — forked from mikepfeiffer/apache.sh
EC2 Bootstrap Script for Apache
#!/bin/bash
yum update -y
yum install -y httpd
echo '<h1>Hello World</h1>' > /var/www/html/index.html
systemctl start httpd
systemctl enable httpd
@tacitphoenix
tacitphoenix / db-container-seed.txt
Last active April 23, 2020 04:50
Seed database containers
# PostgreSQL
```
create role postgres with password 'postgres';
alter role postgres with login;
create database db_one owner=postgres;
grant all privileges on database testdb to postgres;
\connect db_one
create table person (name varchar, age int);
insert into person (name, age) values ("John Doe");
@tacitphoenix
tacitphoenix / sandbox.rake
Created November 22, 2019 15:32
Rake tasks in rails to chain dependencies
namespace :sandbox do
desc "run main"
task :main => [:environment, :one] do
puts "Running main"
end
desc "run one"
task :one => :two do
puts "Running one"
end
@tacitphoenix
tacitphoenix / rails_rakes.rake
Created November 22, 2019 15:11
Pass arguments to rake tasks in rails
namespace :rails_rakes do
desc "say hi"
task :hi => :environment do
puts "Hi"
end
desc "say hi with arg"
task :hi_with_arg, [:name] => :environment do |t, args|
puts "Hi #{args[:name]}"
end
@tacitphoenix
tacitphoenix / JS Utility functions
Created November 15, 2019 19:22
Nice to have wrapper utility functions wrapped around core libraries
const randNum = (n) => Math.floor(Math.random() * n) + 1;
const makeArr = (n) => Array.from(Array(n)).map(() => 0);
const seqFn = (fn) => makeArr(20).map(() => fn());