Skip to content

Instantly share code, notes, and snippets.

set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab "expandtab (whitespace)
set number "line numbers
set ai "autoindent
set si "smartindent
set tw=79 "wrap on 79
set sta "smarttab
set history=100 "remember more than 20 cmd-history
@hermansc
hermansc / gist:6501296
Created September 9, 2013 20:48
itkadduser
#! /usr/bin/perl
use strict;
use warnings;
use ITK::usermod;
my $host = "login.stud.ntnu.no";
my $user = $ENV{'SUDO_USER'} // $ENV{'LOGNAME'};
if (not $user) {
$user = ITK::usermod::prompt("Brukernavn på lynx")
}
class Node:
def __init__(id, symbol = None):
self.id = id
self.valeur = 1
self.symbol = symbol
self.pere = None
self.gauche = None
self.droit = None
self.special = False
@hermansc
hermansc / gist:4106022
Created November 18, 2012 16:09
Gunicorn config & ab-test
### /etc/gunicorn.d/ukeweb.gunicorn
CONFIG = {
'mode': 'wsgi',
'environment': {
'PYTHONPATH': '/var/www/uka.no/staging/ukeweb/',
},
'user': 'uka-web',
'group': 'uka-web',
'args': (
'--bind=0.0.0.0:5060',
@hermansc
hermansc / fabfile2.py
Created October 29, 2012 09:32
Fabfile
STAGING = { 'directory': '/var/www/stagingcode/',
'fcgi': 'fcgi-staging.fcgi' }
PROD = {'directory': '/var/www/productioncode/',
'fcgi': 'fcgi-prod.fcgi'}
env.hosts = ['host.domain.com']
env.user = getpass.getuser()
USER_ID = 'productionuser'
@task
def deploy():
@hermansc
hermansc / fabfile.py
Created October 21, 2012 12:24
fabfile.py
from fabric.api import *
import subprocess, shlex, atexit, time
@task
def deploy():
env.user = prompt('Your username at login and deployment box: ')
prod = SSHTunnel(env.user, 'loginserver', 'productionserver')
env.hosts = [prod.entrance()]
env.host_string = prod.entrance()
print "[INFO] Running SSH commands to production server through tunnel at localhost:2022"
Counting objects: 18, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 3.75 KiB, done.
Total 11 (delta 8), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To login.iterate.no:/srv/beachfinder
2012-02-16 00:57:42.238 /kontakt/handlehealthform/ 200 1487ms 7kb Opera/9.80 (Macintosh; Intel Mac OS X 10.6.6; U; en) Presto/2.10.229 Version/11.61
129.241.159.164 - - [15/Feb/2012:15:57:42 -0800] "POST /kontakt/handlehealthform/ HTTP/1.1" 200 7906 "http://www.fornebuklinikken.no/kontakt/" "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.6; U; en) Presto/2.10.229 Version/11.61" "www.fornebuklinikken.no" ms=1487 cpu_ms=838 api_cpu_ms=324 cpm_usd=0.024305 instance=00c61b117c4415adeab6728d0f46d3a04ab4
2012-02-16 00:57:42.230
Saved; key: __appstats__:060700, part: 111 bytes, full: 51593 bytes, overhead: 0.001 + 0.051; link: http://www.fornebuklinikken.no/_ah/stats/details?time=1329350260763
2012-02-16 00:57:41.441 /_ah/queue/deferred 200 150ms 0kb AppEngine-Google; (+http://code.google.com/appengine)
0.1.0.2 - - [15/Feb/2012:15:57:41 -0800] "POST /_ah/queue/deferred HTTP/1.1" 200 84 "http://www.fornebuklinikken.no/kontakt/handlehealthform/" "AppEngine-Google; (+http://code.google.com/appengine)" "www.fornebu
@hermansc
hermansc / gist:1669227
Created January 24, 2012 09:23
Render GLUT
int SIZE = 1;
bool UP;
void Render() {
// Clean up the colour of the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
36 bytes from 193.156.90.50: Communication prohibited by filter
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 5400 cd1d 0 0000 3a 01 24f5 192.168.95.194 160.68.205.231