Skip to content

Instantly share code, notes, and snippets.

@mbajur
mbajur / README.md
Created June 27, 2014 11:12
Add git branch name to terminal prompt (mac)

Open up your bash profile file with

vim ~/.bash_profile

and at the end of that file, add:

# Git branch in prompt.
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

}

@mbajur
mbajur / nginx
Created April 2, 2014 20:04
nginx startup script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@mbajur
mbajur / url.rb
Created February 20, 2014 13:34
AZURE SAS URL Generator
require 'time'
require 'openssl'
require "base64"
require 'uri'
require 'addressable/uri'
def create_signature(path = '/', resource = 'b', permissions = 'r', start = '', expiry = '', identifier = '')
# If resource is a container, remove the last part (which is the filename)
path = path.split('/').reverse.drop(1).reverse.join('/') if resource == 'c'
canonicalizedResource = "/mediasvc78m7lfh2gnn2x/#{path}"
{ payload: '{\\n \\"taskDueDate\\": \\"No due\\",\\n \\"oldTaskMilestone\\": null,\\n \\"isUpdatedTask\\": \\"true\\",\\n \\"oldTaskAssignee\\": null,\\n \\"statusType\\": \\"OPEN\\",\\n \\"oldTaskVisibility\\": null,\\n \\"isEstimationUpdated\\": \\"false\\",\\n \\"invokerEmail\\": \\"mike@domain\\",\\n \\"oldTaskStatus\\": \\"Resolved\\",\\n \\"projectId\\": \\"61193\\",\\n \\"taskContent\\": \\"Add god to monit background processes\\",\\n \\"taskAssignee\\": \\"Mike B.\\",\\n \\"invokerId\\": \\"38073\\",\\n \\"isLabelsUpdated\\": \\"false\\",\\n \\"taskLabels\\": \\"Improvement\\",\\n \\"isAssignmentUpdated\\": \\"false\\",\\n \\"oldTaskEstimation\\": null,\\n \\"isVisibilityUpdated\\": \\"false\\",\\n \\"isStatusUpdated\\": \\"true\\",\\n \\"isMilestoneUpdated\\": \\"false\\",\\n \\"domain\\": \\"xxx\\",\\n \\"invokerSmallAvatarURL\\": \\"xxx\\",\\n \\"invoker\\": \\"Mike B.\\",\\n \\"taskId\\": \\"33\\",\\n \\"accountURL\\": \\"xx\\",\\n \\"taskAuthor\\": \\"Mike B.\\",\\n \\"

Raw JSON

{\n "accountURL": "https://domain.com\",\n "newCommitsCount": "1",\n "pushURL":"https://domain.com/project/64249/git/source/compare/revisions/0b6438955f2a5a7981fd25cfa5b48fe3fb4c888d,7771e638d1356a14d1dc46f3f5cfaab858370a5e\",\n "unsubscribeURL": "https://domain.com:443/unsubscribe?token=receiverToken&type=COMMITS&projectId=64249\",\n "invokerEmail": "email@email.com",\n "projectURL": "https://domain.com/project/64249\",\n "projectId": "64249",\n "afterPushRevision": "7771e638d1356a14d1dc46f3f5cfaab858370a5e",\n "invokerId": "38074",\n "pushDate": "2014-02-11T15:26:36+0000",\n "beforePushRevision": "0b6438955f2a5a7981fd25cfa5b48fe3fb4c888d",\n "repositoryURL": "git_url",\n "subdomain": "subdomain",\n "domain": "domain",\n "branch": "develop",\n "invokerProfileURL": "url",\n "commitsCount": "1",\n "invokerSmallAvatarURL": "xx",\n "projectName": "NAME",\n "invoker": "Invoker Name.",\n "commits": {

{
"comment": {
"video_id": 1,
"body": "xx",
"cue_point": 360
},
"auth_token": 'xxxx',
"user_email": "mbajur@gmail.com"
}
@mbajur
mbajur / index.html
Last active January 27, 2024 23:14
Working example of window.postMessage used for sending data from popup to parent page (works in IE)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
<script type="text/javascript">
window.open ("popup.html","mywindow", "width=350,height=250");
// Create IE + others compatible event handler
Test gist created with sublime gist package
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>dummy tiwtter callback</title>
</head>
<body>
<script type="text/javascript">
window.opener.twitterAccess('27886675-ZsGQnbdNXJ55bJmg3zHIOQxWzd2wZC1nwcHciHOC5', '11aC8gNkbCadU1te898q5HEgJxWEO2SVZz2ndvppeHYLX')
Disabling CD Sources and Updating Apt Packages and Installing Pre-Reqs
Reading package lists...
Building dependency tree...
Reading state information...
git is already the newest version.
The following extra packages will be installed:
binutils ca-certificates-java consolekit cpp cpp-4.6 cryptsetup-bin dbus-x11
dconf-gsettings-backend dconf-service dpkg-dev fakeroot fontconfig
fontconfig-config g++ g++-4.6 gcc gcc-4.6 gconf-service
gconf-service-backend gconf2 gconf2-common gvfs gvfs-common gvfs-daemons