Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
alanbriolat / ifort_initialisation_bug.f90
Created October 2, 2013 13:09
A demonstration of a weird cross-module array-inside-derived-type initialisation bug in ifort.
! A demonstration of a weird cross-module array-inside-derived-type
! initialisation bug in ifort. ifort --version: ifort (IFORT) 14.0.0 20130728.
! None of these issues appear in other compilers tested (gfortran 4.6 and 4.7).
module module_a
implicit none
private
integer :: i
! Test the array initialiser, works just fine.

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
@alanbriolat
alanbriolat / bind_c_optional.c
Last active February 10, 2021 16:55
Fortran BIND(C) optional arguments
void do_the_thing(int*, double*, double*, double*);
extern const int blah;
int main(int argc, char **argv)
{
int n = 5;
double x[5] = {1, 2, 3, 4, 5};
double y[5] = {10, 20, 30, 40, 50};
double z[5];
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alanbriolat
alanbriolat / walk.py
Last active December 17, 2017 17:04
A Python function for walking and mutating a tree of mappings and sequences.
import collections
def identity(x):
return x
def item_identity(k, v):
return k, v

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 1301 24CE B74D 9528 F3CF CD0D 83AC 368A 2100 CE08

To claim this, I am signing this object: