Skip to content

Instantly share code, notes, and snippets.

@jhafner
jhafner / vCenter.css
Created May 30, 2013 15:36
Vertically center inline content.
.container {
min-height: 6.5em;
display: table-cell;
vertical-align: middle;
}
@jhafner
jhafner / gradients.css
Created May 30, 2013 15:37
CSS3 Gradients Template.
#colorbox {
background: #629721;
background-image: -webkit-gradient(linear, left top, left bottom, from(#83b842), to(#629721));
background-image: -webkit-linear-gradient(top, #83b842, #629721);
background-image: -moz-linear-gradient(top, #83b842, #629721);
background-image: -ms-linear-gradient(top, #83b842, #629721);
background-image: -o-linear-gradient(top, #83b842, #629721);
background-image: linear-gradient(top, #83b842, #629721);
}
@jhafner
jhafner / textcolumns.css
Created May 30, 2013 15:43
CSS Text Columns
#columns-3 {
text-align: justify;
-ms-column-count: 3;
-ms-column-gap: 12px;
-ms-column-rule: 1px solid #c4c8cc;
-moz-column-count: 3;
-moz-column-gap: 12px;
-moz-column-rule: 1px solid #c4c8cc;
-webkit-column-count: 3;
-webkit-column-gap: 12px;
@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
@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;
}
/* 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 / 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">
@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 / .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 / 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;