Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
alanbriolat / color_descriptor.py
Created May 30, 2012 21:34
Descriptors gone wrong
class Color(object):
def __init__(self, initial=None):
self.value = initial
def __get__(self, obj, objtype):
return self.value
def __set__(self, obj, value):
self.value = value
@alanbriolat
alanbriolat / descriptor_docstring.py
Created June 6, 2012 11:39
Descriptor not seen as class in Sphinx
class ValueFilter(object):
"""A descriptor which applies *filter* to assigned values, which are stored
at *attr*. If the value is unset it is *default*.
"""
def __init__(self, attr, filter, default=None):
self.attr = attr
self.filter = filter
self.default = default
def __get__(self, instance, owner):
@alanbriolat
alanbriolat / compiler output
Created July 18, 2012 11:33
The many faces of function definition in Fortran 95
fortran_hell.f95:146.12:
j = foo * foo
1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1)
@alanbriolat
alanbriolat / PKGBUILD
Created July 27, 2012 11:21
monodevelop-git AUR package tweaks
# Maintainer: Dominic Werner <aka.vince@gmail.com>
# Contributor: Jonathan Lestrelin <zanko@daemontux.org>
# Part of this PKGBUILD was taken from the monodevelop one from:
# Contributor: Daniel Isenmann <daniel@archlinux.org>
# Contributor: Timm Preetz <timm@preetz.us>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
pkgname=monodevelop-git
_pkgname=monodevelop
pkgver=20120727
@alanbriolat
alanbriolat / PKGBUILD
Created October 23, 2012 12:07
Better heroku-toolbelt PKGBUILD
# Maintainer: pisuka <tekmon@gmail.com>
# Contributor: Alan Briolat <alan.briolat@gmail.com>
pkgname=heroku-toolbelt
pkgver=2.32.14
pkgrel=2
pkgdesc="Everything you need to get started using Heroku"
arch=(any)
url="https://toolbelt.heroku.com"
license=(GPL)
groups=()
@alanbriolat
alanbriolat / tpl-0.8.1.php
Created October 30, 2012 20:08
A simple PHP template engine
<?php
/**
* Tpl - A PHP template engine
*
* Tpl is a simple hierarchical template engine inspired by the
* {@link http://www.djangoproject.com/ Django} template engine. Since PHP is
* already a template language (of sorts), Tpl does not attempt to replace it,
* but extends it with a useful inheritance framework to simplify the writing
* of templates for both small and complex web applications.
*
@alanbriolat
alanbriolat / strings.f90
Created October 31, 2012 15:45
Horrible indistinguishable Fortran strings
program strings
implicit none
character(len=20) :: a, b
print *, "strings: ", a, b
if (a == b) then
print *, "strings are equal"
endif
@alanbriolat
alanbriolat / 21-yubikey.conf
Created January 10, 2013 10:01
yubikey /etc/X11/xorg.conf.d/ snippet
Section "InputClass"
Identifier "yubikey"
MatchIsKeyboard "on"
MatchVendor "Yubico"
MatchProduct "Yubico Yubikey II"
Driver "evdev"
Option "XkbRules" "evdev"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
Option "XkbVariant" "basic"
@alanbriolat
alanbriolat / examples.txt
Last active December 11, 2015 05:49
An ugly Python script to work out what proportion of weekday instances are on odd "day of month" numbers for a given year
$ python3 odd_days.py 2012
Mon 0.49056603773584906
Tues 0.5192307692307693
Wed 0.4807692307692308
Thurs 0.5192307692307693
Fri 0.5
Sat 0.5
Sun 0.5094339622641509
$ python3 odd_days.py 2013
@alanbriolat
alanbriolat / broken_associate.F90
Created June 3, 2013 14:43
Checking for ASSOCIATE deficiencies in Fortran compilers when combined with derived type arrays. Must be saved with uppercase extension (broken_associate.F90) so the C preprocessor bits will work.
program test_associate
implicit none
type foo_t
integer :: a, b, c
end type
type(foo_t), dimension(6) :: foo
type(foo_t) :: sfoo