Skip to content

Instantly share code, notes, and snippets.

View alimoeeny's full-sized avatar
💭
Strong Opinions Weakly Held

Ali Moeeny alimoeeny

💭
Strong Opinions Weakly Held
View GitHub Profile
#register this with ELB
# what is my name
myname=$(curl http://169.254.169.254/latest/meta-data/instance-id)
# what is my AvailabilityZone
myaz=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone)
#What is my region
myregion=${myaz%?}
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
package main
import (
"fmt"
"net/http"
)
func ServerModeBouncer(h http.Handler, mode *int64) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, q *http.Request) {
switch q.Method {
@alimoeeny
alimoeeny / pre-commit
Last active December 25, 2015 16:29
git pre-commit hook for automatic versioning on every commit in Matlab
#!/bin/sh
#read more at http://alimoeenysbrain.blogspot.com/2013/10/automatic-versioning-with-git-commit.html
#replace all MYPROJECT with your project name
#for languages other than matlab replace all the .go extensions with your language extensions and modify BODY to reflect you language syntax
#for go (golang) see this gits: https://gist.github.com/alimoeeny/7005725
VERBASE=$(git rev-parse --verify HEAD | cut -c 1-7)
echo $VERBASE
NUMVER=$(awk '{printf("%s", $0); next}' MYPROJECTversion.m | sed 's/.*MYPROJECT\.//' | sed 's/\..*//')
@alimoeeny
alimoeeny / pre-commit
Last active June 9, 2020 13:27
git pre-commit hook for automatic versioning on every commit in golang
#!/bin/sh
#read more at http://alimoeenysbrain.blogspot.com/2013/10/automatic-versioning-with-git-commit.html
#replace all MYPROJECT with your project name
#for languages other than go (golang) replace all the .go extensions with your language extensions and modify BODY to reflect you language syntax
VERBASE=$(git rev-parse --verify HEAD | cut -c 1-7)
echo $VERBASE
NUMVER=$(awk '{printf("%s", $0); next}' MYPROJECTversion.go | sed 's/.*MYPROJECT\.//' | sed 's/\..*//')
echo "old version: $NUMVER"
@alimoeeny
alimoeeny / gist:6048921
Created July 21, 2013 15:46
~/.gitconfig
[color]
ui = true
[alias]
lol = log --pretty=oneline --abbrev-commit --graph --decorate
la = log --pretty=\"format:%ad %h (%an): %s\" --date=short
dw = diff --word-diff
sb = status -sb
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C( bold blue)<%an>%Creset' --abbrev-comm it --
lp = log -p
@alimoeeny
alimoeeny / gist:4065881
Created November 13, 2012 13:55
login draft
<html>
<body>
<script>
alert('ali here');
function showResults(a)
{
for(var key in a['data'])
{
if (a['data'].hasOwnProperty(key)) { // this will check if key is owned by data object and not by any of it's ancestors
alert(key+': '+a['data'][key]); // this will show each key with it's value
@alimoeeny
alimoeeny / loadWithPrefix.m
Created July 9, 2012 17:35
loadWithPrefix loads the varialbles in a mat file into the base workspace
function loadWithPrefix(matFileName, prefix)
load(matFileName)
allVariables = who;
for i = 1:length(allVariables)
if (strcmp(allVariables{i}, 'prefix') || strcmp(allVariables{i}, 'matFileName'))
%
else
disp([allVariables{i} ' -> ' prefix allVariables{i}]);
eval(['assignin(''base'', [prefix allVariables{i}] ,' allVariables{i} ');']);
end
@alimoeeny
alimoeeny / hack.sh
Created March 31, 2012 22:37 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#