Skip to content

Instantly share code, notes, and snippets.

@justintv
justintv / .bashrc
Created August 17, 2009 00:53
Display git branch in bash prompt
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
@sebclaeys
sebclaeys / autodict.py
Created September 19, 2011 20:49
Python autodict: implicitly create a dictionary instead of raising KeyError + support for object-like dot access + dictionary visitor
# Autodict class
# Create new autodict if accessing undefined key
# support dot access syntax (mydict.test == mydict['test'])
class autodict(dict):
def __getitem__(self, name):
if not name in self:
dict.__setitem__(self, name, autodict())
return dict.__getitem__(self, name)
def __getattr__(self, name):
@jwebcat
jwebcat / gist:5122366
Last active October 9, 2025 13:52 — forked from lemenkov/gist:1674929
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active July 23, 2025 13:28
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active September 8, 2025 00:49
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active October 8, 2025 11:34
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@jagrosh
jagrosh / Github Webhook Tutorial.md
Last active October 24, 2025 19:41
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@douduck08
douduck08 / README.md
Last active May 17, 2025 19:06
The general GetValue extension of SerializedProperty in Unity Editor.

Unity's SerializedProperty not support custom type value setting. This extension use Reflection to get target instance of SerializedProperty in Custom Editor, made value setting of general type is posible.

@ditzel
ditzel / MathParabola.cs
Last active October 16, 2025 15:26
A simple Math class to calculate a point in 2D or 3D space lying on a parabola. And a more complex parabola controller that you can put on an object.
using UnityEngine;
using System;
public class MathParabola
{
public static Vector3 Parabola(Vector3 start, Vector3 end, float height, float t)
{
Func<float, float> f = x => -4 * height * x * x + 4 * height * x;
//Attach to player object
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class Voice : NetworkBehaviour
{
int lastSample;
AudioClip c;