Skip to content

Instantly share code, notes, and snippets.

View jsmits's full-sized avatar

Sander Smits jsmits

  • DeepHealth
  • The Netherlands
View GitHub Profile
@jsmits
jsmits / byzanz-record-window
Created March 18, 2014 11:14
Small command-line wrapper around byzanz with window select.
#!/bin/bash
# Delay before starting
DELAY=10
# Sound notification to let one know when recording is about to start (and ends)
beep() {
paplay /usr/share/sounds/freedesktop/stereo/bell.oga &
}
@jsmits
jsmits / tour_golang_25.go
Created April 26, 2014 09:29
Tour of Golang #25
package main
import (
"fmt"
"math"
)
func newtonSqrtFormula(z float64, x float64) float64 {
return (z - (((z * z) - x) / (2 * z)))
}
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
"math"
)
type Image struct {
@jsmits
jsmits / spatialite_views.sql
Created December 3, 2014 09:23
Spatialite views examples
# spatialite views voorbeelden
# zie ook: http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/sp-view.html
##########################
### sewerage_pipe_view ###
##########################
CREATE VIEW sewerage_pipe_view AS
SELECT c.ROWID AS ROWID,
c.id AS id,
c.display_name AS display_name,
c.sewerage_type AS sewerage_type,
@jsmits
jsmits / reverse_strings.go
Created December 7, 2014 12:25
Reverse strings using a task processor
// Code from my dotGo.eu 2014 presentation
//
// Copyright (c) 2014 John Graham-Cumming
//
// Implement a factory and a task. Call run() on your factory.
package main
import (
"bufio"
@jsmits
jsmits / nginx
Last active August 29, 2015 14:13 — forked from vdel26/nginx
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
import sys
import subprocess
class Pager(object):
"""enable paging for multiple writes"""
def __init__(self):
self.proc = None
if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty():
@jsmits
jsmits / fabfile.py
Created January 24, 2010 13:56 — forked from heckj/fabfile.py
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
# ================================================================
# NOTE:
# using this fabfile expects that you have the python utility
# fabric installed locally, ssh access to reamea.com, and your
# ssh public key associated with the account 'mboza@reamea.com'
# -*- coding: utf-8 -
import os
os.environ['TRAC_ENV'] = '/Users/jsmits/.virtualenvs/trac/projects/mysite'
os.environ['PYTHON_EGG_CACHE'] = '/Users/jsmits/.virtualenvs/trac/projects/mysite/eggs'
import trac.web.main
def app(environ, start_response):
return trac.web.main.dispatch_request(environ, start_response)
(trac)[jsmits@imac:~/.virtualenvs/trac]$ gunicorn --workers=1 wsgi:app
2010-03-20 13:03:37 [88765] [INFO] Arbiter booted
2010-03-20 13:03:37 [88765] [INFO] Listening at: http://127.0.0.1:8000
2010-03-20 13:03:37 [88766] [INFO] Worker spawned (pid: 88766)
2010-03-20 13:04:02 [88766] [ERROR] Error processing request.
Traceback (most recent call last):
File "/Users/jsmits/.virtualenvs/trac/lib/python2.6/site-packages/gunicorn/worker.py", line 153, in handle
response = self.app(req.read(), req.start_response)
File "/Users/jsmits/.virtualenvs/trac/lib/python2.6/site-packages/trac/web/main.py", line 420, in dispatch_request
return _dispatch_request(req, env, env_error)