Skip to content

Instantly share code, notes, and snippets.

View jsmits's full-sized avatar

Sander Smits jsmits

  • DeepHealth
  • The Netherlands
View GitHub Profile
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'
(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)
# -*- 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)
@jsmits
jsmits / omelette2venv.py
Last active December 24, 2015 21:39
File for adding buildout omelette paths to virtualenv in vagrant for use by PyCharm. With this file, PyCharm can use the omelette packages from the vagrant remote interpreter. Usage: tweak paths in file if necessary, make it executable and put it in /usr/local/bin. Then run omelette2venv.py.
#!/usr/bin/env python
import os
def main(omelette_dir='/srv/parts/omelette'):
"""
Workaround to enable PyCharm to get access to the project modules.
Requirements:
- omelette directory created by buildout
- a virtualenv with the system packages named /home/vagrant/venv
@jsmits
jsmits / flake8.xml
Last active August 2, 2018 16:52
PyCharm 3.x Flake8 Configuration XML
<toolSet name="Code Checking">
<tool name="Flake8" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="/usr/local/bin/flake8" />
<option name="PARAMETERS" value="--max-complexity 10 $FilePath$" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec>
<filter>
<option name="NAME" value="Filter 1" />
<option name="DESCRIPTION" />
@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,