Skip to content

Instantly share code, notes, and snippets.

View nagelflorian's full-sized avatar

Florian Nagel nagelflorian

View GitHub Profile
@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;
/**
* 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 / 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){
@nagelflorian
nagelflorian / happyNumbers.swift
Created May 4, 2015 23:22
Happy Numbers in Swift
// Happy Numbers
// info: http://en.wikipedia.org/wiki/Happy_number
// by Florian Nagel
// floriannagel.net
import Foundation
func isHappyNumber(var number: Int) -> Bool {
var history = [Int]()
@nagelflorian
nagelflorian / howto.md
Created January 17, 2016 12:41
Node-Color-Thief on Ubuntu Server

Installing dependencies

$ sudo apt-get update
$ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

Important: libjpeg8-dev is required rather than just libjpeg-dev

Installing node-canvas

$ sudo npm install canvas
@nagelflorian
nagelflorian / .hyperterm.js
Created July 16, 2016 12:15
HyperTerm Config – JS/HTML/CSS Terminal
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 16,
// font family with optional fallbacks
fontFamily: '"Inconsolata for Powerline", Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color (hex)
cursorColor: '#fff',
@nagelflorian
nagelflorian / strongestContrast.swift
Created March 11, 2015 21:54
Returns black or white based on relative luminance
func strongestContrast(color: UIColor) -> UIColor {
let colorRef: CGColorRef = color.CGColor
let components = CGColorGetComponents(colorRef)
let relativeLuminance = 1 - (0.2126 * components[0] + 0.7152 * components[1] + 0.0722 * components[2])
if (relativeLuminance >= 0.5) {
return UIColor.whiteColor()
} else {
return UIColor.blackColor()
@nagelflorian
nagelflorian / install-tensorflow.sh
Created April 5, 2017 21:27 — forked from erikbern/install-tensorflow.sh
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
@nagelflorian
nagelflorian / keybase.md
Created September 14, 2018 08:40
Keybase Verification

Keybase proof

I hereby claim:

  • I am nagelflorian on github.
  • I am floriannagel (https://keybase.io/floriannagel) on keybase.
  • I have a public key ASAoYXjd0alXuujiaSse4qJAaUH0gd9U-THLKHqgcfrzQAo

To claim this, I am signing this object:

@nagelflorian
nagelflorian / circle.yml
Created January 14, 2016 13:04
CircleCI File for Meteor using Velocity with Jasmine and Galaxy for deployment
machine:
node:
version: 0.10.40
pre:
# download if meteor isn't already installed in the cache
- meteor || curl https://install.meteor.com | /bin/sh
post:
- meteor --version
checkout: