Skip to content

Instantly share code, notes, and snippets.

View Tarrasch's full-sized avatar
💭
I may be slow to respond.

Arash Rouhani Tarrasch

💭
I may be slow to respond.
View GitHub Profile
From 8016ef549062e6622a6acece5499501999c58994 Mon Sep 17 00:00:00 2001
From: Arash Rouhani <[email protected]>
Date: Mon, 13 Jan 2014 14:53:53 +0100
Subject: [PATCH] Make CAFs backtraceable for stack tracing
Before:
0: stg_bh_upd_frame_ret (at rts/Updates.cmm:86:1-91:2)
1: crashSelf (at my/Main.hs:23:15-23:40)
2: + (at libraries/base/GHC/Num.lhs:86:19-86:30)
3: crashSelf (at my/Main.hs:23:15-23:40)
@Tarrasch
Tarrasch / test-bib.py
Created December 16, 2013 08:31
Test if your bibtex file is valid
# I used this to get https://github.com/termoshtt/unite-bibtex working
from pybtex import errors
from pybtex.database.input import bibtex
errors.enable_strict_mode()
parser = bibtex.Parser()
path = '/home/YOUR_NAME/your/path/to/bibtex/file.bib'
parser.parse_file(path)
@Tarrasch
Tarrasch / desc.org
Created November 18, 2013 16:13
Ideal (but unrealizeible) API for haskell stack traces

Haskell API for stack traces

– what we have:

catch# :: (State# RealWorld -> (# State# RealWorld, a #) ) -> (b -> ByteArray# -> State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #)

dumpStack :: ByteArray# -> State# RealWorld -> State# RealWorld

@Tarrasch
Tarrasch / InsideNew.hs
Created November 12, 2013 22:05
Haskell exception handling - Throwing a different exception from what you caught inside the handler
{-# LANGUAGE DeriveDataTypeable #-}
module InsideNew where
import Control.Exception
import Data.Typeable
data MyException = MyException
deriving (Show, Typeable)
instance Exception MyException
@Tarrasch
Tarrasch / InOut.java
Last active December 28, 2015 02:59
Throwing in java - When is it a re-throw?
public class InOut {
public static void main(String[] args) {
insideSame();
insideNew();
outsideSame();
outsideNew();
}
public static abstract class CatchPrint {
public abstract void body() throws Exception;
@Tarrasch
Tarrasch / Main.java
Created November 8, 2013 13:59
Example where exception values can escape their handlers in java
public class Main {
public static void main(String[] args) {
Exception e2 = new Exception();
try {
test();
}
catch (Exception e) {
e2 = e;
}
e2.printStackTrace(); // The exception value is used outside of it's handler
@Tarrasch
Tarrasch / ReifyMini.hs
Created October 24, 2013 15:14
reifyStack() seems to not be idempotent when called from same context.
{-# LANGUAGE MagicHash #-}
module Main where
import GHC.IO (reifyStack, MyArray(..))
import GHC.Prim
import GHC.Exts
import Unsafe.Coerce
import Data.Primitive.ByteArray
import Data.Primitive.Types
import System.Mem
@Tarrasch
Tarrasch / Test.hs
Created October 24, 2013 14:45
Stack Traces, why you such a *****?
-- version 1:
e = do print 1002
ba <- reifyStack'
print $ sizeofByteArray ba
printStackTrace ba
print $ 1 `div` 0
print 2002
-- gives:
@Tarrasch
Tarrasch / test.tex
Created October 13, 2013 10:13
justwannadiff
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[pdfpagelabels]{hyperref}
\title{[Title]}
\author{N.N.}
\begin{document}
\pagenumbering{Alph}
@Tarrasch
Tarrasch / LiveBordShuffler.cpp
Created September 29, 2013 08:30
Hosting a tournament with Electronic Chessboards? Do you only have a few of them, but still want all contestants to get to play on them at least once? Then try this program! :)
// LiveBordShuffler.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;