Skip to content

Instantly share code, notes, and snippets.


Tom Smeding tomsmeding

View GitHub Profile
tomsmeding / A1.hs
Last active Aug 31, 2020
Unused import warning is order-dependent?
View A1.hs
module A1 (astuff) where
import C -- no warning!
import B
astuff :: Int
astuff = 10 + bstuff + cstuff
#!/usr/bin/env bash
# Written by Tom Smeding, released into the public domain.
# This produces the following directory structure:
# - $EXT/
# - stack/
# - stack # haskell stack executable
# - IHaskell/ # the IHaskell github repository clone
# - ihaskell # the ihaskell executable
#!/usr/bin/env python
import weechat
import re
"Tom Smeding",
"Reply helper for weechat-matrix buffers",
tomsmeding / Error.hs
Last active Jun 18, 2020
ghcide fails on this repository, because of the non-exported variable reference in a TH splice
View Error.hs
{-# LANGUAGE TemplateHaskell #-}
module Error ( somethfunc ) where
import Language.Haskell.TH hiding ( Unsafe )
somethfunc :: Q Exp
somethfunc = [| glorifiedID |]
glorifiedID :: a -> a
glorifiedID = id
View Main.hs
module Main where
import Submod
main :: IO ()
main = return ()
View thread-interference.cpp
#include <cstdio>
#include <thread>
#include <vector>
#include <algorithm>
#include <atomic>
using namespace std;
template <typename T>

For people who wonder even more about taking the maximum of two floats: let's compare fmax(a,b), fmaxf(a,b), std::max(a,b) and if (a < b) return b; else return a; in gcc, clang, icc and msvc.

Look at the assembler outputs here: gcc and clang (, icc and mscv (



tomsmeding / gist:ff4e77f181ff6d87c5bcf03531701435
Last active Oct 3, 2018
gcc bug priority_queue multiple files same struct name
View gist:ff4e77f181ff6d87c5bcf03531701435
$ valgrind ./ab
==13981== Memcheck, a memory error detector
==13981== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13981== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==13981== Command: ./ab
==13981== HEAP SUMMARY:
==13981== in use at exit: 0 bytes in 0 blocks
==13981== total heap usage: 2 allocs, 2 frees, 72,708 bytes allocated
View P.c
/// -------------------- STANDARD LIBRARY THINGS --------------------
#include <stdbool.h>
#define WASM_EXPORT __attribute__((visibility("default")))
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
View Makefile
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++11 -O2 -fwrapv -g
TARGET = hotpatcher
.PHONY: all clean
all: $(TARGET)
rm -r $(TARGET) *.o
You can’t perform that action at this time.