Skip to content

Instantly share code, notes, and snippets.

View dandye's full-sized avatar

DanDye dandye

View GitHub Profile
@dandye
dandye / mount_edge.sh
Last active May 25, 2017 11:57
VBox Shared Folder mount script
#!/bin/bash
#
# Mount a MacOS Directory via VirtualBox Shared Folder
# and open port 8000 for Django development server
#
# Args:
# ${1} mount name (optional; default: "edge_dev")
#
# Usage:
# sudo ./mount_edge.sh edge_dev
@dandye
dandye / lxc_centos.sh
Created May 20, 2017 17:46
LXC CentOS
[admin@edge ~]$ sudo yum install lxc lxc-templates
...
[admin@edge ~]$ rpm -qil lxc-templates | grep centos
/usr/share/lxc/config/centos.common.conf
/usr/share/lxc/config/centos.userns.conf
/usr/share/lxc/templates/lxc-centos
[admin@edge ~]$ sudo lxc-create -t centos -n c1
@dandye
dandye / gist:3b2439bad4893dbb0f3f0bbf37d47b7d
Created May 13, 2017 14:54
MacOS save screenshots to dir
mkdir ~/Documents/Screenshots
defaults write com.apple.screencapture location ~/Documents/Screenshots
killall SystemUIServer
@dandye
dandye / compile_install_tmux2.3.sh
Created April 6, 2017 00:07
Compile tmux 2.3 on CentOS 6
sudo yum install gcc kernel-devel make ncurses-devel wget automake
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xzvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
make
sudo make install
@dandye
dandye / ranpwd.spec
Created January 19, 2017 22:39
RPM spec file for ranpwd v1.1-1
[admin@localhost ~]$ vim ranpwd.spec
Summary: A program to generate random passwords
Name: ranpwd
Version: 1.1
Release: 1
License: GPL
Group: Applications/System
Source0: ftp://ftp.kernel.org/pub/software/utils/admin/ranpwd/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
@dandye
dandye / aws_cli_open_port.sh
Created January 17, 2017 13:43
AWS CLI Open Port for my IP in specified security group
pip install awscli
export AWS_ACCESS_KEY_ID=$AWS_alice_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_alice_SECRET_ACCESS_KEY
export AWS_DEFAULT_REGION=$AWS_alice_DEFAULT_REGION
export AWS_GROUP_ID=$AWS_alice_GROUP_ID
aws ec2 authorize-security-group-ingress \
--group-id $AWS_GROUP_ID \
--protocol tcp \
--port 22 \
--cidr $(dig +short myip.opendns.com @resolver1.opendns.com)/32)
@dandye
dandye / gist:a4b3f154aab6c1bbc082a21abc6bfd14
Created January 16, 2017 13:33
Rebase and Squash before opening Pull Request
git checkout master
git pull
git checkout -b travis_runs_protractor_tests travis_integration_tests_for_edge_v2x
git rebase master
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" -n 45
git rebase -i HEAD~32
git push origin travis_runs_protractor_tests
@dandye
dandye / extract_public_key.sh
Created January 10, 2017 12:11
openSSL: how to extract public key
openssl rsa -in privkey.pem -pubout > key.pub
# http://stackoverflow.com/questions/10271197/openssl-how-to-extract-public-key
@dandye
dandye / bootstrap_salt_cloudinit.rst
Created December 30, 2016 12:41 — forked from abhishekctn/bootstrap_salt_cloudinit.rst
Bootstrapping Salt on Linux EC2 with CloudInit

Boostrapping Salt on Linux EC2 with Cloud-Init

Salt is a great tool for remote execution and configuration management, however you will still need to bootstrap the daemon when spinning up a new node. One option is to create and save a custom AMI, but this creates another resource to maintain and document.

A better method for Linux machines uses Canonical's CloudInit to run a bootstrap script during an EC2 Instance initialization. Cloud-init takes the user_data string passed into a new AWS instance and runs it in a manner similar to rc.local. The bootstrap script needs to:

  1. Install Salt with dependencies
  2. Point the minion to the master
@dandye
dandye / ubuntu-cloud-virtualbox.sh
Created December 28, 2016 10:21 — forked from smoser/ubuntu-cloud-virtualbox.sh
example of using Ubuntu cloud images with virtualbox
## Install necessary packages
$ sudo apt-get install virtualbox-ose qemu-utils genisoimage cloud-utils
## get kvm unloaded so virtualbox can load
$ sudo modprobe -r kvm_amd kvm_intel
$ sudo service virtualbox stop
$ sudo service virtualbox start
## URL to most recent cloud image of 12.04
$ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release"