Skip to content

Instantly share code, notes, and snippets.

View riccardomurri's full-sized avatar

Riccardo Murri riccardomurri

View GitHub Profile
@riccardomurri
riccardomurri / LaTeX-transpose-table.el
Created August 19, 2011 18:44
Emacs command to transpose the contents of a (La)TeX table.
(defun LaTeX-transpose-table (start end)
(interactive "r")
(goto-char start)
(let ((last start)
(rows (list ()))
(nrows 0)
(ncols 0)
(maxcols 0))
(while (re-search-forward "&\\|\\\\\\\\" end t)
(setf (car rows)
@riccardomurri
riccardomurri / gist:1157664
Created August 19, 2011 18:51
Emacs commands to wrap a block of text into start/end tags, or insert them. Similar to what AUC-TeX' font commands do, but generic.
(defun wrap-region-in (start-text end-text)
"Insert START-TEXT at the beginning of the currently active
region, and END-TEXT at the end of it."
(let ((start (min (point) (mark)))
(end (max (point) (mark))))
(save-excursion
(goto-char end)
(insert end-text)
(goto-char start)
(insert start-text))))
@riccardomurri
riccardomurri / yaml_and_persitent_id.py
Created November 8, 2011 19:29
non-working example of implementing `persistent_id` on top of PyYAML
#! /usr/bin/python
import yaml
class Persistable(object):
# simulate a unique id
_unique = 0
def __init__(self, *args, **kw):
Persistable._unique += 1
@riccardomurri
riccardomurri / concurrent_bitset.hpp
Created December 30, 2011 18:51
Implementation of a concurrent `std::bitset` using Intel TBB.
/**
* @file concurrent_bitset.hpp
*
* Implementation of a concurrent @c std::bitset using Intel TBB.
*
* @author riccardo.murri@gmail.com
* @version $Revision$
*/
/*
* Copyright (c) 2011 Riccardo Murri <riccardo.murri@gmail.com>. All rights reserved.
@riccardomurri
riccardomurri / gc3pie-poster-preview.tex
Created August 22, 2013 12:45
Poster preview for the GC3Pie poster @ EuroSciPy 2013
\documentclass[final,english,serif]{beamer}
\usetheme{gc3}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{gc3}
@riccardomurri
riccardomurri / gist:6763235
Last active December 24, 2015 07:19
Full error trace leading up to Numba's "NotImplementedError: Unable to cast from { i64, i8* }* to { i64, i8* }"
DEBUG -- translate:361:translate
; ModuleID = 'tmp.module.fatghol.simplematrix.__new__.25311b8'
@PyArray_API = linkonce_odr global i8** inttoptr (i64 46912560938432 to i8**)
define { i64, i8* }* @__numba_specialized_0_fatghol_2E_simplematrix_2E___new__({ i64, i8* }* %cls, i32 %rows, i32 %columns) {
entry:
%objtemp3 = alloca { i64, i8* }*
store { i64, i8* }* null, { i64, i8* }** %objtemp3, !tbaa !2
(defun check-cfengine-block-length (filename)
(save-excursion
(find-file filename)
(goto-char (point-min))
(while (re-search-forward "\\[%CFEngine +BEGIN *%\\]" nil 'noerror)
(let ((start (match-end 0))
(start-line (what-line)))
(if (re-search-forward "\\[%CFEngine +END *%\\]" nil 'noerror)
(let ((end (match-beginning 0))
(end-line (what-line)))
@riccardomurri
riccardomurri / TEST.cf
Last active August 29, 2015 13:55
CFEngine module for generating contexts and variables based on the output of `ip addr show`.
# Sample CFEngine usage of the `ips` module.
#
# You should get something like the following:
#
# $ cf-agent -I -f ./TEST.cf -K
# 2014-01-31T16:43:01+0100 info: Executing 'no timeout' ... 'ips'
# 2014-01-31T16:43:01+0100 info: Completed execution of 'ips'
# 2014-01-31T16:43:01+0100 notice: R: Running a test
# 2014-01-31T16:43:01+0100 notice: R: Interface `lo` NOT detected, as it's not UP
# 2014-01-31T16:43:01+0100 notice: R: Interface `wlan0` detected UP
@riccardomurri
riccardomurri / TEST.in
Last active August 29, 2015 14:02
preprocess.cf -- Run external preprocessing commands from CFEngine.
Example processing using the `j2pp` preprocessor;
see: http://github.com/uzh/j2pp
Domain name: {{sys.domain}}
L2 addresses (list):
{% for hwaddr in sys.hardware_addresses -%}
* {{ hwaddr }}
{% endfor %}
#! /usr/bin/env python
import re
from markdown2 import markdown
link_patterns = [
# issueNNN --> /help/issueNNN
(re.compile(r'\b(issue)\s*(\d+)\b'), r'/help/\g<1>\g<2>'),