Skip to content

Instantly share code, notes, and snippets.

View lgraubner's full-sized avatar

Lars Graubner lgraubner

View GitHub Profile
@lgraubner
lgraubner / OuterClick.jsx
Created May 15, 2017 11:47
Handle clicks outside of react components
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class OuterClick extends Component {
constructor() {
super();
this.handleClickOutside = this.handleClickOutside.bind(this);
}
@lgraubner
lgraubner / eslint-config-airbnb.sh
Created May 11, 2017 19:56
Airbnb eslint config install script
(
export PKG=eslint-config-airbnb;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
@lgraubner
lgraubner / index.html
Last active February 22, 2018 12:23
Barebones html template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<meta name="description" content="">
@lgraubner
lgraubner / isNumber.js
Created February 9, 2017 07:35
Checks if value is a number.
const isNumber = x => Number(x) === x;
@lgraubner
lgraubner / shairport-sync.conf
Created January 6, 2017 19:29
Shairport-Sync config for Raspberry Pi
// Sample Configuration File for Shairport Sync
// Commented out settings are generally the defaults, except where noted.
// General Settings
general =
{
name = "Wohnzimmer"; // This means "Hostname" -- see below. This is the name the service will advertise to iTunes.
// The default is "Hostname" -- i.e. the machine's hostname with the first letter capitalised (ASCII only.)
// You can use the following substitutions:
// %h for the hostname,
@lgraubner
lgraubner / pubsub.js
Last active December 16, 2016 09:29
Simple PubSub pattern object literal
const pubsub = {
handlers: [],
subscribe(event, handler) {
const o = {
event,
handler,
};
this.handlers.push(o);
return o;
@lgraubner
lgraubner / nginx.conf
Created October 23, 2016 10:30 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@lgraubner
lgraubner / bash
Created October 12, 2016 07:50
Clear memcached
echo 'flush_all' | nc localhost 11211
@lgraubner
lgraubner / crontab
Created October 5, 2016 07:10
Add real cron to Wordpress (5 minute interval)
*/5 * * * * curl http://example.com/wp-cron.php
@lgraubner
lgraubner / rot13.js
Created September 19, 2016 12:07
ROT13 implementation in Javascript
"Encrypt me!".replace(/[A-Z-a-z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + (c.toUpperCase() <= "M" ? 13 : -13)));