Skip to content

Instantly share code, notes, and snippets.

@kfish
kfish / arbitrary-variant.hpp
Created August 11, 2018 04:49
Rapidcheck(C++) Arbitrary instance for `std::variant`
// An Arbitrary instance generator for std::variant, for
// Rapidcheck: https://github.com/emil-e/rapidcheck
#include <variant>
namespace rc {
template<>
struct Arbitrary<std::monostate> {
static Gen<std::monostate> arbitrary() {
git log --date=local --format="%cD" --stat --no-merges
@kfish
kfish / cherrypy-websockets-monitor.py
Last active March 8, 2019 23:37
A cherrypy websockets server to broadcast, eg. for system monitoring
# To use this, you need to implement some class with a read() method, eg.
#
# class MyReader(object):
# def __init__(self, path):
# self.path = path
#
# def read(self):
# with open(self.path, 'r') as f:
# return f.read()
# ...
@kfish
kfish / gist:42526e58badd63a75154
Last active February 26, 2021 01:54
How to monitor a logrotated file
(Read the comments)
@kfish
kfish / ci
Last active August 29, 2015 14:21
ci: Continuously invoke a command when input files change
#!/bin/sh
#
# ci: Continuously invoke a command when input files change
#
# Requires inotifywait, from inotify-tools:
# # apt-get install inotify-tools
# # yum install inotify-tools
#
# Conrad Parker 2015
@kfish
kfish / cdd.sh
Created October 1, 2014 01:27
cdu, cdd: cd up/down lots of empty directories, useful for navigating Java, Scala etc. code trees
function cd_down_rec () {
case $(find ./* -maxdepth 0 -type d -not -name ".*" | wc -l) in
1)
cd *
cd_down_rec
;;
*)
;;
esac
@kfish
kfish / apply-patch.sh
Created November 12, 2013 03:59
Apply a patch file that was produced with "git format-patch" using the patch command, and commit it using the message from the original commit.
#!/bin/bash
apply () {
filename=$1
shift
patch_args=$*
gotSubject=no
msg=""
@kfish
kfish / gist:6991070
Created October 15, 2013 12:46
builds ...
diff --git a/src/Fay/Compiler.hs b/src/Fay/Compiler.hs
index 8de77fc..ed388d5 100644
--- a/src/Fay/Compiler.hs
+++ b/src/Fay/Compiler.hs
@@ -81,24 +81,27 @@ compileToplevelModule filein mod@Module{} = do
either throwError warn res
initialPass filein
-- Reset imports after initialPass so the modules can be imported during code generation.
- startCompile compileFileWithSource filein
+ (hstmts, fstmts) <- startCompile compileFileWithSource filein
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RebindableSyntax #-}
module TodoFay (
Todo(..)
, TodoState(..)
, initialState
, remaining
, addTodo
, archive
@kfish
kfish / FieldNames.hs
Created November 15, 2012 02:49
Data constructor field names as [String] using Template Haskell
{-# LANGUAGE TemplateHaskell #-}
module FieldNames (
fieldNames
) where
import Data.List (nub)
import Language.Haskell.TH
-- | Generate a list of all field names used in the constructors