Skip to content

Instantly share code, notes, and snippets.

View thomasfr's full-sized avatar

Thomas Fritz thomasfr

View GitHub Profile
@thomasfr
thomasfr / app.service
Created September 9, 2013 14:33
Systemd Services
[Unit]
Description=Description for this application
Requires=network.target
After=network.target
[Service]
WorkingDirectory=/srv/app
ExecStart=/usr/bin/npm start
Restart=always
StandardOuput=syslog
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
# - Access-Control-Max-Age=20days, to minimize repetitive OPTIONS requests
getResponseObject = (context) ->
# Later we could extend this to decide which ErrorResponse Object it should use
# based on the given error instance
if context instanceOf Error
object = new ErrorResponse context
else
object = new SuccessResponse context
send = (request, response, context) ->
object = getResponseObject context
var timers = {};
var createGeocodeChangeWhateverFunction = function(timername, $scope) {
var timer = timers[timername];
return function($event) {
if (timer != null) {
clearTimeout(timer);
}
timers[timername] = timer = setTimeout(function() {
timer = null;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasfr
thomasfr / .gitignore
Created July 26, 2013 11:15
sample .gitignore for node.js modules
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
@thomasfr
thomasfr / Spaces.js
Last active December 20, 2015 06:39
WebStorm Code Style Rules
function foo(x, y, z) {
bar(1, b);
var i = 0;
var x = {0: "zero", 1: "one"};
var foo = function () {
}
if (!i > 10) {
for (var j = 0; j < 10; j++) {
switch (j) {
case 0:
@thomasfr
thomasfr / conditions.js
Last active December 20, 2015 05:29
Coding Guidelines / Coding Styles
// Wrong:
if (condition) alert(foo);
// Correct:
if (condition) {
alert(foo);
}
//-------------------------------------------------
@thomasfr
thomasfr / PKGBUILD
Created June 19, 2013 11:33
Arch AUR PKGBUILD file for nginx with google pagespeed
# $Id$
# Maintainer: Sergej Pupykin <[email protected]>
# Maintainer: Bartłomiej Piotrowski <[email protected]>
# Contributor: Miroslaw Szot <[email protected]>
# nginx-pagespeed maintainer: Ludovic Fauvet <[email protected]>
_cfgdir=/etc/nginx
_tmpdir=/var/lib/nginx
pkgname=nginx-pagespeed
@thomasfr
thomasfr / geocodeFunctions
Created June 19, 2013 09:52
Some Google App Script functions. The functions can be used as Google Spreadsheet formulas.
function geocode(address) {
if(address) {
var response = Maps.newGeocoder().setRegion('at').geocode(address);
var longLat = {};
var l;
Logger.log("address: " + address);
if (response.status === "OK") {
Logger.log("response " + JSON.stringify(response));
if((l = response.results[0].geometry.location)) {
longLat.lng = l.lng;