Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am alanbriolat on github.
  • I am alanbriolat (https://keybase.io/alanbriolat) on keybase.
  • I have a public key whose fingerprint is 139D 86F0 095A E34A 4E82 AED9 4911 5981 D488 B8BB

To claim this, I am signing this object:

program pointer_remap
type :: real_pointer
real, pointer :: p => null()
end type real_pointer
real, target, dimension(1:3) :: vec
type(real_pointer), dimension(-1:1) :: pVec
integer :: i
import logging
logging.basicConfig(level=logging.DEBUG)
class Foo(object):
def __init__(self):
self.bar = "hello"
def __getitem__(self, key):
return getattr(self, key)
@alanbriolat
alanbriolat / log_exception.py
Created June 9, 2014 14:15
Log unhandled Python exceptions with logging.critical(...).
import traceback
import sys
def excepthook(type, value, tb):
for part in traceback.format_exception(type, value, tb):
for line in part.splitlines():
logging.critical(line)
sys.excepthook = excepthook
#!/usr/bin/env python2
"""
Generate a script to create a multi-hop SSH connection.
Usage: sshroute.py [options...] HOST
Options:
-l SPEC, --local=SPEC Tunnel a port - local:via:remote
-r SPEC, --remote=SPEC Reverse tunnel a port - remote:via:local
-h HOST, --host=HOST Go via another host
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alanbriolat
alanbriolat / gist:630048
Created October 16, 2010 17:20
Checking an IP address is within a range, the correct way (NOT using regular expressions!)
>>> ip = "192.168.75.10"
>>> a, b, c, d = map(int, ip.split('.'))
>>> a == 192 and b == 168 and 72 <= c <= 79 and 1 <= d <= 254
True
@alanbriolat
alanbriolat / fcgiwrap_gitolite.conf
Created October 3, 2011 15:38
fcgiwrap setup for gitweb + gitolite
; Spawn fcgiwrap as the user owning the git repositories, with a socket writeable by nginx
[fcgi-program:fcgiwrap_gitolite]
command = /usr/sbin/fcgiwrap
user = gitolite
socket = unix:///var/run/supervisor/%(program_name)s.sock
socket_owner = gitolite:nginx
socket_mode = 0770
@alanbriolat
alanbriolat / redmine.conf
Created October 6, 2011 09:25
nginx configuration for redmine
server {
listen 80;
server_name projects.hexi.co redmine.codescape.net;
root /home/alan/www/redmine.codescape.net/public;
include global/restrictions.conf;
location / {
try_files $uri @redmine_fcgi;
}
-- A simple IRC bot using http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot
-- as a starting point
module HBot where
import Data.List
import Network
import System.IO
import System.Console.ANSI
import Control.Applicative ((<$))
import Control.Monad.Reader hiding (join)