This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//generic function to get JSON from a github API endpoint | |
function getJSON(url) { | |
// Your github username | |
username = "<USERNAME>" | |
// Your access token (see https://github.com/settings/tokens) | |
password = "<ACCESS_TOKEN>" | |
//basic auth using access token | |
var options = {}; | |
options.headers = {"Authorization": "Basic " + Utilities.base64Encode(username + ":" + password)}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What is it? Use docker to host an html file using nginx! | |
# Pre-requisites: You've installed docker and logged into docker-hub | |
#make our html file | |
echo "<h1>Hello world</h1>" > index.html | |
#start docker and mount our current working directory into nginx | |
docker run -p 80:80 -v "$(PWD)":/usr/share/nginx/html:ro -d nginx | |
#go have a look! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This script will create the required Dockerfile, docker-compose.yml, Gemfile, etc. and create a new rails app (using postgres) | |
#BEWARE! It will overwrite any existing files in the folder including Dockerfile, docker-compose.yml, and README.md | |
#the databses will be called "myapp_development", and "myapp_test" | |
cat << EOF > Dockerfile | |
FROM ruby:latest | |
#USER $USER | |
#make sure we don't get tripped up by any inherited proxies | |
#RUN unset HTTP_PROXY | |
#RUN unset HTTPS_PROXY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create a local html file | |
echo "<html><h1>Yo</h1></html>" > index.html | |
#start nginx inside a container | |
docker run -p 80:80 -v "$(PWD)":/usr/share/nginx/html:ro -d nginx & | |
#fire up a browser and point it at local host | |
open http://localhost | |
#get the container ID to kill it later... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See if the /usr mount is over 60% full | |
# If so, exit with a status of 1. Otherwise, OK | |
df -h | grep "/usr" | grep -oP "\d+%" | grep -oP "\d+" | xargs -L1 -I{} bash -c 'if [ {} -ge 60 ]; then exit 1; else exit 0; fi' | |
# BONUS! | |
# remove any gz file older than 60 days which are type "file" (not directories) | |
find /path/to/logs/ -name "*.gz" -mtime +60 -type f -exec rm {} + | |
#zip any log file older than 10 days | |
find /path/to/logs/ -name "*.log" -mtime +10 -type f -exec gzip {} + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# upgrade centos and make sure you have the docker repo | |
sudo yum install -y yum-utils | |
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo | |
# dunno why I had to do this but I did...any ideas? | |
sudo yum makecache fast | |
# Install these dependencies | |
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.33-1.git86f33cd.el7.noarch.rpm | |
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/pigz-2.3.3-1.el7.centos.x86_64.rpm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: &default | |
adapter: postgresql | |
encoding: unicode | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
timeout: 5000 | |
host: db | |
username: postgres | |
password: | |
development: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to | |
For Centos (because that's what some companies give you for a VM) | |
Follow these steps: | |
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7 | |
yum install -y vim | |
vim /etc/nginx/nginx.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# Creates user and adds public key | |
# Must be run as root | |
# | |
# Requires: | |
# 1) Full name | |
# 2) Username | |
# 3) Public key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | |
# | |
# If you find yourself ignoring temporary files generated by your text editor | |
# or operating system, you probably want to add a global ignore instead: | |
# git config --global core.excludesfile '~/.gitignore_global' | |
# Ignore bundler config. | |
/.bundle | |
# Ignore all logfiles and tempfiles. |