Skip to content

Instantly share code, notes, and snippets.

View iamnewton's full-sized avatar
🏠
Working from home

Newton iamnewton

🏠
Working from home
View GitHub Profile
@iamnewton
iamnewton / optional.keg
Created June 26, 2014 21:45
A keg file for mass installation of optional Homebrew casks via kegger (https://github.com/chrisopedia/kegger)
bassjump
candybar
#! /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
#!/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 January 29, 2015 18:19
ImageMagick Tips & Tricks
# 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 February 5, 2015 00:00
CORS configuration for allowing fonts across a CDN
# 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 *;
}
// ----------------------------------------------------------
// 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 August 29, 2015 14:15
SASS triangles
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 August 29, 2015 14:16 — forked from dciccale/README.md
DOM Ready: Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.
<!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>
.button {
border: none;
}
button.button {
-webkit-appearance: none;
}
a.button {
text-decoration: none;
}
@iamnewton
iamnewton / fix-javascript-errors.md
Created March 11, 2015 23:31
Strange JavaScript Errors

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