Skip to content

Instantly share code, notes, and snippets.

View esundahl's full-sized avatar

Erik Sundahl esundahl

View GitHub Profile
@esundahl
esundahl / .gvimrc.after
Created January 20, 2012 20:07
Vim Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Author: Erik Sundahl
" Twitter: @eriksundahl
" Website: http://eriksundahl.com
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set Color Scheme
@esundahl
esundahl / color_test.sh
Created January 21, 2012 03:19
Bash Color Test
function color_test {
# Daniel Crisman's ANSI color chart script from
# The Bash Prompt HOWTO: 6.1. Colours
# http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
#
# This function echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
#!bash
function current_git_branch () {
# '$(__git_ps1 " %s")'
local current_branch=$(__git_ps1)
# No Branch
if [[ "$current_branch" = "" ]]; then
printf ""
@esundahl
esundahl / removeDupes.js
Created February 19, 2012 22:23
Function for removing duplicate values from a javascript array
// This is a simple javascript function for removing duplicate values from an array.
function removeDupes(arr) {
var nonDupes = [];
arr.forEach(function(value) {
if (nonDupes.indexOf(value) == -1) {
nonDupes.push(value);
}
});
return nonDupes;
@esundahl
esundahl / arrayOfProperties.js
Created February 21, 2012 22:09
Javascript: get an array of all property names in an object
keys : function (o) {
var accumulator = [];
for (var propertyName in o) {
accumulator.push(propertyName);
}
return accumulator;
}
//get values instead of keys
values : function (o) {
@esundahl
esundahl / gist:1994380
Created March 7, 2012 16:58 — forked from padolsey/gist:527683
Javascript: IE Version Detection
// ----------------------------------------------------------
// 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) {}
@esundahl
esundahl / index.html
Created March 7, 2012 17:04
HTML: minimum HTML5 markup
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
@esundahl
esundahl / retinaDetect.js
Created March 16, 2012 19:50
Javascript: detect retina display
var retina = window.devicePixelRatio > 1 ? true : false;
@esundahl
esundahl / env.json
Created March 23, 2012 20:52
This is a quick and dirty little javascript bookmarklet that I wrote to toggle between different development environments
[{
"environments": [
"site.dev",
"site.staging",
"site.com"
]
}]
@esundahl
esundahl / style_first_word.js
Created March 30, 2012 22:17
Javascript: jQuery: Style first word plugin
(function($) {
$.fn.styleFirstWord = function(attr) {
if ( typeof attr !== 'object' ) {
attr = {
class: attr || 'firstWord'
};
}
return this.each(function() {
var $this = $(this),