Skip to content

Instantly share code, notes, and snippets.

@mikekwright
mikekwright / gist:3921269
Created October 19, 2012 23:24 — forked from padolsey/gist:527683
Javascript: detect ie
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@mikekwright
mikekwright / sample.sh
Created October 20, 2012 01:17
Bash: verify argument count
ARG_COUNT=2
if [ ! $# -eq $ARG_COUNT ]; then
echo "Usage: $0 <arg1> <arg2>"
exit 1
fi
@mikekwright
mikekwright / sample.sh
Created October 20, 2012 01:19
Bash: iterate command line arguments
for arg in "$@"
do
echo "Arguments: $arg"
done
@mikekwright
mikekwright / sample.sh
Created October 20, 2012 01:22
Bash: get script directory
SCIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@mikekwright
mikekwright / sample.sh
Created October 20, 2012 01:23
Bash: read in password
stty -echo
read -p "Password: " PASSWORD; echo
stty echo
@mikekwright
mikekwright / makefile
Created October 20, 2012 01:26
Config: basic makefile
CC=g++
LINKER=$(CC)
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=posix
all: clean $(SOURCES) $(EXECUTABLE)
@mikekwright
mikekwright / Rakefile
Created October 20, 2012 01:28
Config: erlang rakefile
require 'rake'
require 'rake/clean'
# Configuration
START_MODULE = "main"
TEST_MODULE = "test_myerlang"
# No Need to change
PWD = `pwd`.strip
INCLUDE = "include"
@mikekwright
mikekwright / sample.sh
Created October 20, 2012 01:29
Bash: check for installed package
PACKAGENAME=gcc
if dpkg-query -W $PACKAGENAME
then
echo "You have $PACKAGENAME installed"
else
echo "You don't have $PACKAGENAME installed"
fi
@mikekwright
mikekwright / server.rb
Created February 13, 2013 05:29
This is a basic website demonstrating a simple lightweight web application.
require 'sinatra'
get '/' do
"<html><body><h1>Hello World</h1></body></html>"
end
@mikekwright
mikekwright / server.py
Created February 13, 2013 05:34
This is a sample of a webserver using the flask micro framework for python.
# Run using the below commands
# pip install Flask
# python server.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<html><body><h1>Hello World</h1></body></html>"