Skip to content

Instantly share code, notes, and snippets.

@cr0wg4n
cr0wg4n / switch-github-user.sh
Last active July 4, 2024 00:32
A Bash script to interchange multiple GitHub users in a unique machine
#!/bin/bash
gh_user="${1:-Nothing}"
if [ "$gh_user" == 'USERNAME_1' ]; then
ssh-add -D
git config --global user.email "USERNAME_1_EMAIL"
ssh-add /PRIVATE_KEY_PATH/.ssh/github-USERNAME_1
elif [ "$gh_user" == 'USERNAME_2' ]; then
ssh-add -D
git config --global user.email "USERNAME_2_EMAIL"
@bean5
bean5 / gist:1245ecbb8976099daf5dcc8c2e76e8cd
Created June 7, 2021 15:11 — forked from jaxbot/gist:5748513
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}

git

This is list of the git commands I use.

The usual flow of developed is clone or fork a repo, create a branch, change code, create commits at logical stopping points, push those commits, and finally merge the branch (usually done on a website).

Branches

Branches let you create a copy all the code from whatever branch you are on. This lets you make changes that can be merged back into the original branch, but doesn't effect the original. They help with conflicting changes by multiple people and code reviews.

Create new branch

from scapy.all import *
import requests
import time
MAGIC_FORM_URL = 'http://put-your-url-here'
def record_poop():
data = {
"Timestamp": time.strftime("%Y-%m-%d %H:%M"),
"Measurement": 'Poopy Diaper'
}
@mlota
mlota / README.md
Last active April 6, 2016 17:54
Inspirational Quotes Widget for Dashing

##Preview

##Description

A simple Dashing widget to display a random inspirational quote. The widget is set to update every 4 hours, however this is easily configurable in the job file. The data is pulled from the free api provided by Forismatic.com.

##Installation

@mvndaai
mvndaai / echo_with_colors.sh
Created September 27, 2014 02:41
Bash echo with colors
#!/bin/sh
echo-bold(){
echo -e '\e[1m'$1'\e[0m'
}
echo-black(){
#You probably shouldn't use this
echo -e '\e[30m'$1'\e[0m'
}
echo-red(){
#!/bin/bash
# Disclaimer - make backups, use at your own risk.
#
# Based on this comment: http://stackoverflow.com/a/13944924/843067
# Views and stored procedures have to be done separately.
OLDDB="old_db_name"
NEWDB="new_db_name"
MYSQL="mysql -u root -pyour_password "
@danriti
danriti / hipchat-v2.sh
Last active July 18, 2024 14:34
HipChat API v2 - Send a message to a room using cURL
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
@jaxbot
jaxbot / gist:5748513
Created June 10, 2013 12:58
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}
@pixelhandler
pixelhandler / pre-push.sh
Last active July 2, 2024 11:27
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`