Skip to content

Instantly share code, notes, and snippets.

View lgraubner's full-sized avatar

Lars Graubner lgraubner

View GitHub Profile
@lgraubner
lgraubner / dhcpcd.conf
Last active February 20, 2016 19:49
Static ip on Raspbian Jessie
# path: /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
interface wlan0
static ip_address=192.168.1.200/24
static routers=192.168.1.1
@lgraubner
lgraubner / ga_id.js
Created October 28, 2015 10:35
Get Google Analytics tracking id.
ga.getAll().shift().b.data.values[':trackingId']
@lgraubner
lgraubner / debounce.js
Last active January 26, 2016 09:33
Function to debounce function calls. Useful for scroll and resize events.
var debounce = function(func, wait, immediate) {
var timeout;
return function() {
var context = this;
var args = arguments;
var later = function() {
timeout = null;
if ( !immediate ) {
func.apply(context, args);
}
@lgraubner
lgraubner / throttle.js
Last active April 27, 2016 09:15
Throttles a function call to only execute every x milliseconds.
function throttle(callback, limit) {
var wait = false;
return function () {
if (!wait) {
callback.call();
wait = true;
setTimeout(function () {
wait = false;
}, limit);
}
@lgraubner
lgraubner / umd.js
Created December 18, 2015 09:36
UMD Module definition
;(function(root, factory) {
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = factory();
} else if (typeof define === "function" && define.amd) {
define([], factory);
} else {
root.ModuleName = factory();
}
}(this, function() {
return function() {
@lgraubner
lgraubner / .htaccess
Last active January 13, 2016 10:57
non www to www redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_ADDR} !=127.0.0.1
RewriteCond %{SERVER_ADDR} !=::1
RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@lgraubner
lgraubner / .htaccess
Last active January 13, 2016 10:56
www to non www redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
</IfModule>
@lgraubner
lgraubner / nav-icon.css
Last active January 7, 2016 13:49
Animated navigation button
.nav-icon {
width: 60px;
height: 45px;
position: relative;
outline: 0;
border: 0;
background: transparent;
padding: 0;
}
@lgraubner
lgraubner / dump.sh
Last active February 25, 2016 10:57
Export/import a MySQL dump
# export
mysqldump -u USERNAME -pPASSWORD DATABASE > dump.sql
# import
mysql -u USERNAME -pPASSWORD DATABASE < dump.sql
@lgraubner
lgraubner / wpa_supplicant.conf
Last active March 17, 2016 18:24
Enable WLAN on Raspbian Jessie
# path: /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID"
psk="PASSWORD"
}