Skip to content

Instantly share code, notes, and snippets.

View nagelflorian's full-sized avatar

Florian Nagel nagelflorian

View GitHub Profile
@nagelflorian
nagelflorian / scrollBasedNavBar.js
Created December 4, 2014 22:52
Scroll based navigation bar (inspired by Teehan+Lax)
var lastScrollY = 0,
minScroll = 20,
delay = 150;
var navMovement = setInterval(function() {
var nav = document.getElementById('nav')
var scrollY = document.all? iebody.scrollTop : pageYOffset;
if(scrollY + minScroll < lastScrollY || scrollY <= 25) {
nav.style.top = "0px"
} else if (scrollY > lastScrollY){
/**
* Levenshtein edit distance calculator
* Usage: levenstein <string> <string>
*
* To compile:
* sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer
* xcrun swift -sdk $(xcrun --show-sdk-path --sdk macosx) levenshtein.swift
*/
import Foundation
@nagelflorian
nagelflorian / dynamicPageTitle.html
Last active August 29, 2015 14:10
Dynamic website title based on user focus, e.g. when a user switches to another browser tab.
<!DOCTYPE html>
<HTML>
<head>
<title>Original Title</title>
<script>
var originalTitle = document.title;
var altTitle = 'Alternative Title';
var onBlurEvents = window.onblur;
var onFocusEvents = window.onfocus;