Skip to content

Instantly share code, notes, and snippets.

View fhemberger's full-sized avatar

Frederic Hemberger fhemberger

View GitHub Profile
@bitboxer
bitboxer / tower.sh
Last active June 25, 2018 15:19
Open tower in current directory
# opens the current git repo in tower if no argument is given
tower() {
if [[ "$#" > 0 ]]; then
gittower $@
else
gittower `git rev-parse --show-toplevel`
fi
}
# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'

Strict Mode: The Summary!

Identifiers (variables, functions) cannot be named any of these: "implements", "interface", "let", "package", "private", "protected", "public", "static", and "yield"

OctalLiterals are not allowed.

@rodneyrehm
rodneyrehm / urlify.js
Last active October 4, 2015 07:37
Reduce (UTF-8) strings to alphanumeric
// port of https://gist.github.com/909692
// TODO: check char-map of https://github.com/jbroadway/urlify/blob/master/URLify.php for characters we've missed
// TODO: check performance against http://stackoverflow.com/questions/1946040/using-javascript-to-normalize-url-rewriting-strings-entered-by-users
var Urlifyer = function(options) {
var _key, _code, i, _source, _sources;
// Allow instantiation without the 'new' keyword
if (!(this instanceof Urlifyer)) {
return new Urlifyer(options);
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@nathansmith
nathansmith / .htaccess
Created October 1, 2011 03:33
Route extension-less files to HTML.
# Route extension-less URLs to the equivalent *.html file.
# For instance: example.com/about = example.com/about.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
</IfModule>
@rodneyrehm
rodneyrehm / urlify.php
Created April 8, 2011 11:52
Reduce (UTF-8) strings to alphanumeric
<?php
/*
consider decomposing the characters to "capture" more "obscure" characters such as ṩ
- http://www.php.net/manual/en/normalizer.normalize.php#92592
*/
/**
* Normalize a string to only contain alphanumeric characters and dashes.
*
@cowboy
cowboy / webkit_inspector_font_size.sh
Created October 13, 2010 12:55
Increase WebKit Inspector's font size (probably will need to re-run after updates)
#!/bin/bash
sudo find '/Applications/Google Chrome.app' \
\( -name inspector.css -or -name devTools.css \) \
-exec sh -c 'cat >> $1 <<WAT
/* Added on `date` */
#drawer .monospace,
#drawer .source-code {
font-size: 18px !important;
@rcmachado
rcmachado / jquery.unserialize.js
Created November 25, 2009 10:19
$.unserialize for jQuery
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array.
*
* Example:
*
* Input: param1=value1&param2=value2
* Return: { param1 : value1, param2: value2 }
*