Skip to content

Instantly share code, notes, and snippets.

View bennofs's full-sized avatar
🎯
Focusing

Benno Fünfstück bennofs

🎯
Focusing
View GitHub Profile
@bennofs
bennofs / example.cpp
Created August 6, 2015 17:33
Extract template from type
struct SampleData {
Container<float> totalradiance;
Container<int> lightcutSize;
template <class T>
struct decl_sampledata_from_container {};
template <template <class, class...> class C, class T>
struct decl_sampledata_from_container<C<T>> {
typedef SampleData<C> type;
@bennofs
bennofs / main.cpp
Created August 12, 2015 10:46
Qt QML context object garbage collected
#include <QQmlEngine>
#include <QObject>
#include <QGuiApplication>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQuickWindow>
#include <QDebug>
class App : public QObject
{
$ nix-instantiate haskell-rethinkdb.nix --indirect --add-root $PWD/shell.drv --show-trace
@bennofs
bennofs / default.nix
Created August 19, 2015 17:23
Use this as a default.nix in the root servant folder to aggregate all dependencies
# This is a function: we take `haskellPackages` as an argument so that it can be overriden,
# but supply `nixpkgs.haskellPackages` as a default value if no value is explictly given.
{ haskellPackages ? (import <nixpkgs> {}).haskellPackages }:
let
# Build our own haskell package set with all the packages added that we want
myHaskellPackages = haskellPackages.override {
# super refers to the "previous" haskell package set (the one we extend)
# self refers to the final haskell package set, after our customizations have been
@bennofs
bennofs / example.nix
Created October 17, 2015 22:52
default to different mtl + explicit override
let
# First, let's get a haskellPackages set to play around with
haskellPackages = (import <nixpkgs> {}).haskellPackages;
# Change the default mtl
haskellPackagesMtl = haskellPackages.override {
overrides = self: super: {
mtl = super.mtl_2_1_3_1;
};
};
@bennofs
bennofs / reflex.org
Created October 28, 2015 17:03
reflex notes

Module overview

Reflex.Class: generic definition of FRP, operations on Events / Behaviors

provides functions for working with events and behaviors

should be imported by users of an FRP-based framework

does not deal with connecting to the outside world, for example creating events from external sources

Reflex.Dynamic: discrete behaviors

Provides the Dynamic data type, a combination of Behavior and Event

Behavior always contains the current value, Event is fired whenever current value changes

-> Behavior is only updated at the end of the current frame, after event propagation

Reflex.Host.Class: generic framework implementation support

@bennofs
bennofs / acme-year-2014.nix
Created November 12, 2015 16:13
haskell package overriding
{ mkDerivation, base, stdenv, time }:
mkDerivation {
pname = "acme-year";
version = "2014";
sha256 = "0zml370s8zv9y60hggv0hlwb3rhmixhdp37cz496dbpffdkw70my";
libraryHaskellDepends = [ base ];
testHaskellDepends = [ base time ];
homepage = "http://github.com/joeyadams/hs-acme-year";
description = "Get the current year";
license = stdenv.lib.licenses.publicDomain;
module Main where
import Control.Monad
import Data.List (find)
import Data.Maybe
import Data.Text.Encoding
import Data.ByteString (ByteString)
import Data.Maybe
import Network.URI (parseURI, URI)
import Network.HTTP
@bennofs
bennofs / Error message
Created July 12, 2013 10:18
Template Haskell: Generate unique data type names
ghci -ddump-splices test2.hs 12:17:44
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 2] Compiling THTest ( THTest.hs, interpreted )
[2 of 2] Compiling Test ( test2.hs, interpreted )
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
@bennofs
bennofs / gist:6663255
Created September 22, 2013 20:02
emacs config
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; environment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(add-to-list 'load-path "~/.emacs.d/plugins")
(require 'sticky-windows)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;