Skip to content

Instantly share code, notes, and snippets.

import Control.Applicative (Applicative(..))
import Control.Monad (ap)
data MyIO a = Return a
| Get (String -> MyIO a)
| Put String (MyIO a)
instance Functor MyIO where
fmap f (Return a) = Return (f a)
fmap f (Get g) = Get (fmap f . g)
Index: awk.1
===================================================================
--- awk.1 (revision 270781)
+++ awk.1 (working copy)
@@ -208,7 +208,7 @@
if no argument.
.TP
.B rand
-random number on (0,1)
+random number on [0,1)
module Main (main) where
-- http://tools.ietf.org/html/rfc5952
import Data.Word (Word64)
import Data.Bits ((.|.), (.&.), shiftL, shiftR)
import Data.Maybe (listToMaybe)
import Numeric (showHex)
import Data.List (intercalate, isInfixOf)
import Data.List.Split (splitOn)
import java.util.function.*;
import java.util.stream.*;
public class Test {
public static void main(String[] args) {
Supplier<Integer> times = () -> 3;
Function<Integer, String> dotimes = x -> {
String val;
switch(x) {
case 1: val = "once";
@horus
horus / pam_script.c.patch
Created January 31, 2015 02:26
avoiding ECHILD
--- pam_script/pam_script.c 2014-06-27 03:39:02.000000000 +0800
+++ pam_script/pam_script.c 2015-01-31 10:15:21.000000000 +0800
@@ -24,6 +24,9 @@
#include <sys/wait.h> /* wait */
#include <unistd.h> /* stat, fork, execve, **environ */
#include <stdlib.h> /* calloc, setenv, putenv */
+#include <signal.h> /* signal, SIGCHLD, SIG_DFL, SIG_ERR */
+
+typedef void (*sighandler_t)(int);
(in-package :cl-user)
(defun md5-sum (file &rest args)
(capi:display-message "~S"
(ironclad:byte-array-to-hex-string (ironclad:digest-file :md5 file))))
(capi:contain (make-instance 'capi:text-input-pane
:callback 'md5-sum
:buttons
(list :cancel t
# shell prompt
PS1='\[\e[1m\][\u@\h \w]\[\e[0m\]$ '
# terminal title
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# environment variables
export HISTSIZE=1000
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export EDITOR=ee
;; get some random elements from a list
;; i know it's dumb
(defparameter *data* '(192 123 34 23 67 3 45 342))
(defun get-and-remove ()
(let ((one (nth (random (length *data*)) *data*)))
(setf *data* (remove one *data*))
one))
[horus@campus ~/.cpanm/plugins]$ cpanm Test::Class
Test::Class: rated 4.6 based on 8 review(s)
Fetching http://cpan.sarang.net//authors/id/A/AD/ADAMK/Test-Class-0.33.tar.gz ... OK
Configuring Test-Class-0.33 ... OK
... ...
[horus@campus ~/.cpanm/plugins]$ cpanm Net::Twitter::Lite
Net::Twitter::Lite: rated 5.0 based on 2 review(s)
Fetching http://cpan.sarang.net//authors/id/M/MM/MMIMS/Net-Twitter-Lite-0.08006.tar.gz ... OK
Configuring Net-Twitter-Lite-0.08006 ... OK
[horus@campus ~]$ PERL_CPANM_DEV=1 cpanm WWW::Mechanize
WWW::Mechanize: rated 4.7 based on 16 review(s)
Fetching http://cpan.sarang.net//authors/id/P/PE/PETDANCE/WWW-Mechanize-1.60.tar.gz ... OK
Configuring WWW-Mechanize-1.60 ... OK
Building and testing WWW-Mechanize-1.60 for WWW::Mechanize ... FAIL
! Installing WWW::Mechanize failed. See /Users/horus/.cpanm/build.log for details.
Running autolook requested by module WWW::Mechanize
Looking into /Users/horus/.cpanm/work/1267368220.2321/WWW-Mechanize-1.60...
bash-3.2$ pwd
/Users/horus/.cpanm/work/1267368220.2321/WWW-Mechanize-1.60