Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jhafner
jhafner / sass-mediaquery-mixin.scss
Created July 12, 2013 14:59
Sass Media Query Mixin
// Mixin Function
@mixin breakpoint($point) {
@if $point == desktop {
@media (max-width: 1600px) { @content; }
}
@else if $point == tablet {
@media (max-width: 1250px) { @content; }
}
@else if $point == handheld {
@media (max-width: 650px) { @content; }
@jhafner
jhafner / sass-grid.scss
Created July 11, 2013 14:52
Simple grid in Sass
/* Your variables */
$nb-columns : 6;
$wrap-width : 1140px;
$column-width : 180px;
/* Calculations */
$gutter-width : ($wrap-width - $nb-columns * $column-width) / $nb-columns;
$column-pct : ($column-width / $wrap-width) * 100;
$gutter-pct : ($gutter-width / $wrap-width) * 100;
@jhafner
jhafner / copyright.php
Created July 7, 2013 02:28
Echo the copyright date.
@jhafner
jhafner / add-commas.js
Created June 28, 2013 16:33
Formats a string as a comma-separated number.
function addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
@jhafner
jhafner / .inputrc
Created June 10, 2013 02:24
Type the beginning of the command (e.g. "cd") and press the up arrow to see the most recent command containing the text you typed (e.g "cd ~/Library"). Source: http://lifehacker.com/supercharge-your-command-lines-history-search-with-fou-478683529
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@jhafner
jhafner / oo-js-boilerplate.js
Created June 6, 2013 16:13
Basic example of Object-Oriented JS
function Element($el) {
// The jquery obj for the dom element represented
this.$el = $el;
// Other object properties used by the object
this.$trigger = $el.closest('.trigger');
this.openClass = 'js-active';
// Object functions to be called on object instantiation
this.init();
@jhafner
jhafner / prefetch.html
Created June 5, 2013 14:46
HTML5 DNS Prefetching and Link Prefetching/Prerendering. Source: http://daker.me/2013/05/5-html5-features-you-need-to-know.html
<!--
DNS hostname resolution is one of the issues that can make any website slow. Modern browsers start to be very smart when it comes to DNS resolution, they try to resolve domain names then cache them before the user tries to follow any link on the webpage.
With the dns-prefetch feature you are allowed to manually control this operation by telling the browser which domain names to resolve
-->
<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="dns-prefetch" href="//google-analytics.com">
<link rel="dns-prefetch" href="//www.google-analytics.com">
<link rel="dns-prefetch" href="//platform.twitter.com">
/* Don't forget to add placeholder elements to your grid */
#grid{
text-align: justify;
font-size: 0.1px; /*hide whitespace between elements*/
}
#grid li{
display: inline-block;
width: 23%;
@jhafner
jhafner / no-ios-highlights.css
Created May 30, 2013 15:50
Disable Mobile Webkit Highlights
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@jhafner
jhafner / bgnoise.css
Created May 30, 2013 15:48
Pure CSS Background Noise
body {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy+kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcmzbyMiqhzuYqtHRVG2y4x+KOlnyqla8AoWWpuBoYRxzXrfKuILl6SfiWCb