Skip to content

Instantly share code, notes, and snippets.

@kfish
kfish / watch-read.hs
Created February 15, 2011 02:01
Haskell inotify example: monitor file modifications
{-# OPTIONS -Wall #-}
module Main where
import Control.Concurrent (threadDelay)
import System.Environment (getArgs)
import System.INotify
main :: IO ()
main = do
@kfish
kfish / EuphoriaTutorial.hs
Created September 15, 2012 12:23 — forked from maoe/EuphoriaTutorial.hs
elereaのチュートリアルをeuphoriaで
module Main where
import Control.Arrow
import Control.Applicative
import Control.Monad
import Data.Maybe
import FRP.Euphoria.Collection
import FRP.Euphoria.Event
import FRP.Euphoria.Signal
@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
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RebindableSyntax #-}
module TodoFay (
Todo(..)
, TodoState(..)
, initialState
, remaining
, addTodo
, archive
@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
@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 / 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 / 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 / gist:42526e58badd63a75154
Last active February 26, 2021 01:54
How to monitor a logrotated file
(Read the comments)
@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()
# ...