Skip to content

Instantly share code, notes, and snippets.

@codeopensrc
codeopensrc / GitServeRepos.sh
Last active June 8, 2016 18:18
Quickly serve folders/git repos to others privately
# Linux/Mac - No windows
# Quickly share your code/script with others that have ssh access to the same server.
# Include one or both functions inside your ~/.bash_aliases.
# `gitinitrepo` needs `gitserverepo`, otherwise it just inits a git repo
# To use, change the SERVER1, SERVER2, SHORTNAME1, SHORTNAME2 variables to whatever you want
# adding or removing if you want as well.
# Then inside the folder without a git repo attached
@codeopensrc
codeopensrc / Useful.md
Last active June 3, 2016 22:30
Articles/links to useful toolls/stuff I don't feel like bookmarking and feel like sharing.
@codeopensrc
codeopensrc / KeyBoardCheatSheet.MD
Last active May 14, 2016 03:49
Mac (currently) keyboard shortcuts I use.

Mac OSX

NOTE - Currently this is a non-exhaustive list. I will add more each day.

  • A lot of these are built-in and some are my personal shortcuts. In the future I will mark defaults vs. changed
  • On my Mac, the CMD key and CTRL key are swapped, so whererever you see CMD, it will be the default CTRL and vice versa
  • For MY sanity, I kept it that way so I am not second guessing myself.
Terminal:
Key Command
@codeopensrc
codeopensrc / paramHelper.MD
Last active April 15, 2016 23:31
Parameter type checking in JS

A helper parameter check for functions in JS

TODO: Turn into a .js file or npm module
TODO: Improve the single object version and demonstrate good usage with function parameters
TODO: Seperate arrays from objects

Supports: string, number, object, function, boolean

3rd iteration

  • This would/will be the npm module
@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
@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 / 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 / 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 / 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 / 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