Skip to content

Instantly share code, notes, and snippets.

@tobia
tobia / TryCatchTagLib.groovy
Created July 2, 2015 12:56
Simple try & catch taglib for Grails GSP views.
// Simple try & catch for GSP views.
//
// Usage:
//
// <g:try>
// view snippet that needs to be checked
// </g:try>
// <g:catch>
// alternative view code in case of errors;
// the exception is available as ${exception}
@tobia
tobia / .ghci
Created May 31, 2016 23:39
Haskell configuration
:set prompt "\ESC[31;1m\STXλ>\ESC[m\STX "
:set -XOverloadedStrings
:set -XNegativeLiterals
:def pf \str -> return $ ":! pointfree '" ++ str ++ "'"
@tobia
tobia / doge.md
Created August 4, 2016 23:49 — forked from cpdean/doge.md
YOU'RE WELCOME, INTERNET. -- if you search for an ascii doge, you don't get anything great that you can copy paste. found a silly gif (http://cmang.org/ascii/cm-doge-bw.gif) and i have transcribed it for all of you

no clue who made this, but i have transcribed it here:

                Y.                      _   
                YiL                   .```.  
                Yii;                .; .;;`.    
                YY;ii._           .;`.;;;; :    
                iiYYYYYYiiiii;;;;i` ;;::;;;;    
            _.;YYYYYYiiiiiiYYYii  .;;.   ;;; 
 .YYYYYYYYYYiiYYYYYYYYYYYYii;` ;;;; 
@tobia
tobia / 8kzenrecover.py
Last active November 16, 2018 00:09 — forked from lkraav/8kzenrecover.py
8kzenrecover.py (Zen Vision M data recovery script) updated to work without LRU.py
#!/usr/bin/python
# Copyright 2007 by Tobia Conforto <tobia.conforto@gmail.com>
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
@tobia
tobia / feynman.ml
Created August 11, 2017 12:36
PBS SpaceTime Feynman Diagram Challenge
(*
Compute all possible Feynman diagrams with 1 el + 1 pos input,
1 el + 1 pos output, 4 nodes, and no self-energetic transitions.
*)
open Core.Std
type particle = Electron | Positron | Photon [@@deriving compare, sexp]
let inverse = function
| Photon -> Photon
@tobia
tobia / luminv.c
Created September 7, 2017 21:43
Fast luminance inversion (aka. color invert + hue rotate 180°)
// Fast luminance inversion.
int luminv(int rgb) {
int r = rgb >> 16,
g = rgb >> 8 & 0xff,
b = rgb & 0xff;
switch (((r > g) << 1 | (g > b)) << 1 | (b > r)) {
case 4: // r > b > g
case 3: // g > b > r
return rgb + (255 - r - g) * 0x10101;
case 2: // g > r > b
[{"week":"2007-12-31", "val":18848},
{"week":"2008-01-07", "val":18567},
{"week":"2008-01-14", "val":7916},
{"week":"2008-01-21", "val":7337},
{"week":"2008-01-28", "val":-1296},
{"week":"2008-02-04", "val":7038},
{"week":"2008-02-11", "val":3522},
{"week":"2008-02-18", "val":4957},
{"week":"2008-02-25", "val":-6891},
{"week":"2008-03-03", "val":10226},
@tobia
tobia / test_count.rs
Created April 12, 2019 17:38
Simple harness to measure macro expansion time
// #![recursion_limit="1003"]
// macro_rules! count {
// () => (0usize);
// ($x:tt $($xs:tt)*) => (1usize + count!($($xs)*));
// }
macro_rules! count {
() => (0usize);
($one:tt) => (1usize);
($($pairs:tt $_p:tt)*) => (count!($($pairs)*) << 1usize);
@tobia
tobia / gnome-terminal-bold-fonts.sh
Created June 9, 2019 14:04 — forked from arturfog/gnome-terminal-bold-fonts.sh
disable bold fonts in gnome terminal
dconf write /org/gnome/terminal/legacy/profiles:/:<id>/allow-bold false
@tobia
tobia / gist:1ee850f521963eb811e6ee2097afa5bd
Created November 16, 2019 10:06
Hide Google "People also search for" and other stuff
.s + div, .exp-outline, .kno-kp, .mnr-c, .g-blk, #extrares