Skip to content

Instantly share code, notes, and snippets.

View rehno-lindeque's full-sized avatar

Rehno Lindeque rehno-lindeque

View GitHub Profile
@pguillory
pguillory / gist:729616
Created December 5, 2010 23:51
Hooking into Node.js stdout
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
@jadell
jadell / socket_file.sh
Created March 15, 2011 21:22
Read and write to a socket using only Bash
#!/bin/bash
#
# Bash must have been compiled with this ability: --enable-net-redirections
# The device files below do not actually exist.
# Use /dev/udp for UDP sockets
exec 3<>/dev/tcp/host/port
# Write to the socket as with any file descriptor
echo "Write this to the socket" >&3
@danielwaterworth
danielwaterworth / STM.hs
Created December 10, 2011 12:03
Alternative STM implementation for Haskell
{-# LANGUAGE ExistentialQuantification #-}
{-
The idea is that each variable is an IORef that is either in a stable state
or is being transformed. If it is being transformed then the IORef contains a
MidChange value. The first argument of the constructor is the state before
the modification, the second argument is the state afterwards and the third
argument is an IORef that says whether the transaction has completed.
-}
@nishimura
nishimura / Reload.hs
Created March 8, 2012 02:48
Reloading feature copied from yesod.
{-# LANGUAGE ScopedTypeVariables #-}
--
-- Copied from Yesod
-- see http://www.yesodweb.com/
--
module Reload (main, develLoop) where
-- reload
import Control.Concurrent (forkIO, threadDelay)
import qualified Control.Exception as Ex
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveDataTypeable #-}
module AlphaHeavy.Exception
( setDefaultUncaughtExceptionHandler
, lastException
, uncaughtExceptionHandler
) where
import Control.Exception (Exception(..), SomeException(..))
@postmodern
postmodern / Makefile
Last active March 4, 2024 14:42
A generic Makefile for building/signing/install bash scripts
NAME=project
VERSION=0.0.1
DIRS=etc lib bin sbin share
INSTALL_DIRS=`find $(DIRS) -type d 2>/dev/null`
INSTALL_FILES=`find $(DIRS) -type f 2>/dev/null`
DOC_FILES=*.md *.txt
PKG_DIR=pkg
PKG_NAME=$(NAME)-$(VERSION)
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@lynaghk
lynaghk / 0-update.md
Last active July 5, 2022 13:33
Angular.js from ClojureScript
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@roman
roman / throttle.hs
Last active December 7, 2017 05:50
Implementation of throttle in Conduit 0.5.x
import Control.Concurrent (forkIO, killThread,
threadDelay, newEmptyMVar,
tryTakeMVar, putMVar)
import Control.Monad (void, forever)
import Control.Concurrent.STM (atomically)
import Control.Monad.Trans (MonadIO(..))
import Control.Monad.Trans.Resource (MonadResource, allocate)
import Data.Conduit (GInfConduit, awaitE)
throttle :: (MonadResource m) => Int -> GInfConduit a m a