Skip to content

Instantly share code, notes, and snippets.

View city41's full-sized avatar
🙃

Matt Greer city41

🙃
View GitHub Profile
#!/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`
function Vb(d) {
d = d | 0;
var e = 0, f = 0, h = 0, j = 0, k = 0, l = 0, m = 0, n = 0,
o = 0, p = 0, q = 0, r = 0, s = 0;
e = i;
i = i + 12 | 0;
f = e | 0;
h = d + 12 | 0;
j = c[h >> 2] | 0;
if ((j | 0) > 0) {
@city41
city41 / composite.js
Created January 29, 2012 03:33
Alpha compositing in JavaScript
function _composite(under, over) {
var alphaO = over[3],
alphaU = under[3],
invAlphaO = 1 - alphaO,
i,
len;
for(i = 0, len = under.length - 1; i < len; ++i) {
under[i] = Math.round((over[i] * alphaO)
+ ((under[i] * alphaU) * invAlphaO));
@city41
city41 / gist:958009
Created May 5, 2011 21:32
Get content type from file extension
public string GetContentType(string filename)
{
string mimeType = "application/unknown";
string extension = Path.GetExtension(filename);
if (string.IsNullOrWhiteSpace(extension))
{
return mimeType;
}