Skip to content

Instantly share code, notes, and snippets.

View anselmh's full-sized avatar

Anselm Hannemann anselmh

View GitHub Profile
@anselmh
anselmh / target_blank--external.js
Created July 24, 2013 12:12
Open all external links (different hostname than current page) in new tab/window with plain vanilla JavaScript.
/**
* Open external links in new tab/window
*/
// All http:// links should open in new tab/window. Internal links are relative.
var anchors = document.querySelectorAll('a');
for (var i = 0; i < anchors.length; i++) {
if (anchors[i].host !== window.location.hostname) {
anchors[i].setAttribute('target', '_blank');
@anselmh
anselmh / dabblet.css
Created May 24, 2013 13:44
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.sticker {
display: inline-block;
width: 3rem;
height: 3rem;
@anselmh
anselmh / dabblet.css
Created May 23, 2013 05:38
Pure CSS Toggle Page Layout
/**
* Pure CSS Toggle Page Layout
*/
.content > article {
min-height: 0;
height: 0;
overflow: hidden;
opacity: 0;
@anselmh
anselmh / dabblet.css
Created April 17, 2013 12:20
Untitled
.box {
width: 400px;
height: 300px;
background: #999;
}
.box:after {
background: orange;
border: 1px solid white;
color: white;
@anselmh
anselmh / load-webfonts-async.js
Created March 11, 2013 11:07
This snippet loads webfonts (in this case from Google Webfonts) asynchronously. This means it does not block page load but also means it can cause FOUT.
WebFontConfig = {
google: { families: [ 'Istok+Web:400,700:latin' , 'Lora:400,700:latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
@anselmh
anselmh / sublimetext2-user-config.json
Created February 11, 2013 14:20
This is my preferred user configuration for ST2
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 11.0,
"translate_tabs_to_spaces": false,
"translate_spaces_to_tabs": true,
"caret_style": "phase",
"highlight_line": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"fade_fold_buttons": false,
@anselmh
anselmh / dabblet.css
Created February 9, 2013 11:42
Untitled
.overflowed > p{
width: 10em;
height: 5em;
white-space: nowrap;
overflow: hidden;
}
.overflowed-clip {
text-overflow-mode: clip;
}
@anselmh
anselmh / dabblet.css
Created February 9, 2013 11:40
Untitled
.overflowed > p{
width: 10em;
height: 5em;
white-space: nowrap;
overflow: hidden;
}
.overflowed-clip {
text-overflow: clip;
}
@anselmh
anselmh / dabblet.css
Created February 9, 2013 11:32
Untitled
.overflowed > p{
width: 10em;
height: 5em;
white-space: nowrap;
overflow: hidden;
}
.overflowed-clip {
text-overflow: clip;
}
@anselmh
anselmh / box-sizingreset.css
Created August 15, 2012 10:05
Make everything box-sizing: border-box;
*, *:before, *:after
{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}