Skip to content

Instantly share code, notes, and snippets.

@codeopensrc
codeopensrc / deployToServer.sh
Last active August 29, 2015 14:21
Deploy Webpack files and DB functions to Github and Heroku (project specific atm)
#!/bin/bash
- # Stack overflow of course helped, parentheses create a "sub-shell" that returns
- # to the original directory it was run in.
(cd src/E*/E* && make development)
git add -A
git reset -- src/E*/E*/public/bundle.js
read -p "Enter message for commit > " message
@codeopensrc
codeopensrc / gist:f430506c93618bf4e4f7
Last active February 2, 2016 20:19
Create Safe User for non-root port 80
apt-get install sudo
useradd -s /bin/bash -m -d /home/$USER -c "$USER" $USER
passwd $USER
##(enter password)
usermod -aG sudo $USER
sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep /usr/local/bin/node
@codeopensrc
codeopensrc / createClientOvpn.sh
Last active February 13, 2016 08:18
Quickly create multiple client .ovpn's from a template .ovpn
#!/bin/bash
# First of course, build your key(s) using `./build-key my-new-client` in the /etc/openvpn/easy-rsa dir
# Within the /etc/openvpn/easy-rsa/keys directory
# (or wherever you have your built-keys at)
# bash createClientOvpn.sh my-template-ovpn my-new-client Think cp command
# or ./createClientOvpn.sh my-template-ovpn my-new-client2
cp $1.ovpn $2.ovpn;
@codeopensrc
codeopensrc / Windows Network Public To Private.sh
Last active April 5, 2020 22:00
Set your "unidentified" network (OpenVPN or others) from public to private on Windows 8
# Put in OpenVpn server.conf
# Add:
# push "route 0.0.0.0 0.0.0.0"
# Once the above route is pushed, it should be identified and you should be able to configure the name and set to private.
# The below steps are if you don't have control over the VPN or "unidentified" network.
# WILL POST A BETTER OPTION FOR OPENVPN SOON
# Until then, you can use the below option for any unidentified network
@codeopensrc
codeopensrc / GitCheatSheet.md
Last active February 3, 2017 01:25
Some git CLI help

Have server working directory based off of bare git repo

In the bare git-repo on the server
  • Change post-update.sample to post-update
  • Have the below command inside post-update
    GIT_WORK_TREE=/home/path/to/working/dir/mytest git checkout -f

List latest commit sha

git rev-parse --short <branchname>

Working on dev, several commits ahead of master, check what you've added

@codeopensrc
codeopensrc / CmdLinePrint.sh
Created February 4, 2016 10:17
Linux print remote -> local, local -> remote strictly from command line
# Have a printer hooked up to linux os
# Have CUPS installed on it and make sure the printer prints from linux
# Have abiword (This is used to convert file to pdf via command line)
# sudo apt-get install abiword
cat dev.json | ssh user@ip 'cat - > tmp.doc; abiword --to=pdf tmp.doc; lp tmp.pdf; rm tmp.doc'
# Havent tested with removing the pdf right after issuing lp, might work.
# Also havnt tested converting other files besides .doc to .pdf
@codeopensrc
codeopensrc / limitSSH.sh
Last active June 8, 2016 18:27
Limit ssh attempts to your ubuntu computer/server to 3 attempts every 5 minutes (4th dropped)
# Source/Reference https://serverfault.com/questions/275669/ssh-sshd-how-do-i-set-max-login-attempts#275672
# Before enabling, be sure you
# a) Know you're public ip address
# b) Know that your public ip address won't change (fixed ip)
# c) Have a backup method to get in just in case (Digital Ocean's "console" for example)
# sudp apt-get install ufw
# sudo ufw allow to any port 22 from your.ip.address.here proto tcp
# sudo ufw enable
@codeopensrc
codeopensrc / sshKeyUpload.sh
Last active February 6, 2016 01:15
One step place ssh keys in your remote server
# Try your best to remove root login and if possible, password authentication (after ssh keys work)
cat ~/.ssh/id_rsa.pub | ssh username@yourip "cat >> ~/.ssh/authorized_keys"
@codeopensrc
codeopensrc / NodeJavaOnPi.sh
Last active February 9, 2016 01:48
Install node java package on Raspberry Pi 2 B
# Because I'm not entirely sure if all the previous steps were needed or only the final one, I included other problems
# that may cause the node-gyp rebuild to fail during java installation (or bcrypt throwing install errors)
# This assumes you are using 7.8 "wheezy"
# More information regarding other distros: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
# Use the correct node version for the Raspberry ARM architecture:
# https://stackoverflow.com/questions/32563173/installing-node-js-on-raspberry-pi-2
wget http://yourARMarchitecurelink
cd /usr/local
@codeopensrc
codeopensrc / SambaPi.md
Last active February 15, 2016 05:23
Set up Samba on Raspberry Pi 2 B Wheezy

To get Samba installed

sudo apt-get update  
sudo apt-get install samba samba-common-bin

Set Samba password

sudo smbpasswd -a pi