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 / 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>
@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 / README.md
Created February 11, 2015 23:53
Responsible Social Share Links

Share URLs

Here’s a collection of common social share URLs and examples of their structures along with links to documentations.

(The code has been broken up into several lines for readability—remember to remove any spaces and line breaks in the href if you copy & paste.)

Taken from Responsible Social Share Links

// ----------------------------------------------------------
// 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 / 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 *;
}
@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 / fonts.keg
Last active November 11, 2018 18:38
A keg file for mass installation of Homebrew fonts via kegger (https://github.com/chrisopedia/kegger)
font-anonymous-pro
font-arvo
font-bitter
font-input
font-inconsolata
font-league-gothic
font-orbitron
font-redacted
font-source-code-pro
font-source-sans-pro
#!/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
#! /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
@iamnewton
iamnewton / tput-hex-table.md
Created July 18, 2014 23:39
A table of the tput values and their equivalent hex value

Primary 3-bit (8 colors). Unique representation!

tput hex
00 000000
01 800000
02 008000
03 808000
04 000080
05 800080