Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Newton iamnewton

🏠
Working from home
View GitHub Profile
@iamnewton
iamnewton / optional.keg
Created Jun 26, 2014
A keg file for mass installation of optional Homebrew casks via kegger (https://github.com/chrisopedia/kegger)
View optional.keg
bassjump
candybar
View colortrans.py
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
View uninstall_homebrew.sh
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@iamnewton
iamnewton / imagemagick-tips.sh
Created Jan 29, 2015
ImageMagick Tips & Tricks
View imagemagick-tips.sh
# Export an Image from Layered Photoshop PSD from Command Line
# http://davidwalsh.name/export-photoshop-file-image
# usage: export_photoshop_layer website-design 1 ~/file.png
export_photoshop_layer() {
readonly FILE=$1
readonly LAYER=$2
readonly DEST=$3
convert "${FILE}.psd[${LAYER}]" $DEST
}
@iamnewton
iamnewton / httpd.conf
Created Feb 5, 2015
CORS configuration for allowing fonts across a CDN
View httpd.conf
# http://davidwalsh.name/cdn-fonts
# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
# nginx config
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
View very-small-ie-detect.js
// ----------------------------------------------------------
// 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 6) then:
// ie === 0
// If you're in IE (>=6) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@iamnewton
iamnewton / triangles.css
Last active Aug 29, 2015
SASS triangles
View triangles.css
ul {
min-height: 40px;
margin: 40px 0;
padding-left: 0;
background-color: grey;
list-style: none;
}
ul > li {
display: inline-block;
position: relative;
@iamnewton
iamnewton / domready.html
Last active Aug 29, 2015 — forked from dciccale/README.md
DOM Ready: Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.
View domready.html
<!doctype html>
<title>Demo</title>
<script>
var DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DOMContentLoaded',a):window.attachEvent('onload',a)}
DOMReady(function () {
alert('The DOM is Ready!');
});
</script>
View qualify.css
.button {
border: none;
}
button.button {
-webkit-appearance: none;
}
a.button {
text-decoration: none;
}
@iamnewton
iamnewton / fix-javascript-errors.md
Created Mar 11, 2015
Strange JavaScript Errors
View fix-javascript-errors.md

Below is a list of the strange errors in JavaScript. Different browsers can give you different messages for the same error, so there are several different examples where applicable.

How to read errors?

Before the list, let’s quickly look at the structure of an error message. Understanding the structure helps understand the errors, and you’ll have less trouble if you run into any errors not listed here.

A typical error from Chrome looks like this:

Uncaught TypeError: undefined is not a function