Navigation Menu

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 / sshd_config.sh
Last active January 4, 2017 14:46
Digital Ocean Droplet sshd_config
# /etc/ssh/sshd_config
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com
PasswordAuthentication no
PubkeyAuthentication yes
Protocol 2
HostKey /etc/ssh/ssh_host_ed25519_key
@anselmh
anselmh / hosts
Last active July 26, 2016 09:14
block newrelic tracker from sending data
##
# Enter this into your /etc/hosts file to re-route traffic to newrelic hostnames to null
##
0.0.0.0 beacon-1.newrelic.com
0.0.0.0 beacon-2.newrelic.com
0.0.0.0 beacon-3.newrelic.com
0.0.0.0 beacon-4.newrelic.com
0.0.0.0 beacon-5.newrelic.com
0.0.0.0 beacon-6.newrelic.com

Conference User Stories

====================================

As an Organizer

  • As an organiser I want to create an event where everyone feels safe and welcome.
  • As an organiser I want attendees to show a level of personal responsibility. That means ensuring that they arrive in time for all sessions, don't consume food or drink that they know will have adverse personal results and respect the speakers by listening to them and not being heads down on their laptops.
  • As a conference treasurer I want a ticketing system that pays straight away (like tito and not like eventbrite) so I have nice cash-flow management.
@anselmh
anselmh / timer.js
Created December 19, 2013 12:15
Better timers with closures and throttling through debouncing methods. By Remy Sharp: http://remysharp.com/2010/07/21/throttling-function-calls/
// Debounce without jQuery
function debounce(fn, delay) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
fn.apply(context, args);
}, delay);
};
var inspect_me = 0,
result = '';
switch (inspect_me) {
case 0:
result = "zero";
break;
case 1:
result = "one";
break;
default:
@anselmh
anselmh / faster-for-loops.js
Created December 12, 2013 12:06
# Cached and faster `for` loops
/*
* The trouble with collections is that they are live queries against the underlying document (the HTML page). This means that every time you access any collection’s length, you’re querying the live DOM, and DOM operations are expensive in general.
*
* It's only good if you don't update the length by f.e. adding DOM nodes
*
* That’s why a better pattern for for loops is to cache the length of the array (or collection) you’re iterating over, as shown in the following example:
*/
for (var i=0, max = myarray.length; i < max; i++) {
// do sth.
/* Wildcard selector searches through any part of the string */
html[data-useragent*='Chrome/13.0'] .nav{
background:url(img/radial_grad.png) center bottom no-repeat;
}
@anselmh
anselmh / resimg-syntax-test.html
Last active December 25, 2015 20:49
It's a quick demo of the three candidates of #respimg syntax. I simply want to compare verbosity of all those.
<!--
A quick demo of the three current candidates of Responsive Images syntax on a real world example for one image.
This on purpose does not include any of the proposed viewport syntaxes because this IMO adds confucion and
is stylistic only (therefore should go in CSS IMO).
-->
<!-- This is the src-{N} way: http://tabatkins.github.io/specs/respimg/Overview.html -->
@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;