Skip to content

Instantly share code, notes, and snippets.

View np's full-sized avatar

Nicolas Pouillard np

View GitHub Profile
@np
np / gist:167685
Created August 14, 2009 07:11 — forked from avsm/gist:166441
(* defines the Ast.binding for a function of form:
let fun_name ?(opt_arg1) ?(opt_arg2) final_ident = function_body ...
XXX: figure out the quotation magic for this, if such exists
*)
let function_with_label_args _loc ~fun_name ~final_ident ~function_body ~return_type opt_args =
let opt_args = opt_args @ [ <:patt< $lid:final_ident$ >> ] in
let rec fn _loc = function
|hd::tl -> <:expr< function $hd$ -> $fn _loc tl$ >>
|[] -> <:expr< ( $function_body$ : $return_type$ ) >>
in
@np
np / email-reminder
Created October 1, 2009 19:49
email-reminder
#!/bin/bash -e
perr(){
echo "$@" > /dev/stderr
}
usage(){
perr "Usage: cat <email> | email-reminder <at(1)-arguments>*"
perr "$@"
exit 1
@np
np / gist:202950
Created October 6, 2009 11:59 — forked from kowey/gist:202581
#!/bin/bash
MSGID=$(grep 'Message-Id' | head -n 1 | sed 's/Message-Id: /:/')
hsgtd add "$@" "$MSGID"
#!/bin/sh
# LICENSE: Public Domain
ioreg -w0 -c AppleSmartBattery -r | # Getting the info
tail -n +2 | # Skipping the prelude
sed -e 's/" *=/": /g' | # Record field syntax
sed -e 's/\(": .*\)$/\1,/' | # Add commas
ruby -e 'puts STDIN.read.gsub(/,\s*\}/, "}")' | # Removing last extra comma
sed -e 's/Yes/true/g' | # Yes->true
sed -e 's/No/false/g' | # No->false
sed -e 's/(\(.*,.*\))/[\1]/' | # CellVoltage field
@np
np / json-pp
Created January 14, 2010 09:10
#!/usr/bin/env ruby
# LICENSE: Public Domain
require 'rubygems'
gem 'json'
require 'json'
puts JSON.pretty_generate(JSON.load(STDIN.read))
#!/bin/bash
# Copyright (c) 2010, Nicolas Pouillard
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
module Yi.Char.Unicode (greek, symbols, subscripts, superscripts, checkAmbs, disamb) where
import Data.List (isPrefixOf)
import Control.Applicative
greek :: [(String, String)]
greek = [(name, unicode) | (_,name,unicode) <- greekData] ++
[ ([leading,shorthand],unicode)
| (Just shorthand,_,unicode) <- greekData
, leading <- ['\'', 'g'] ]
@np
np / git-ignore.d
Created November 22, 2011 13:22
git-ignore.d
#!/bin/bash
# vim: ft=sh
###########################################################################
# Copyright (c) 2011, Nicolas Pouillard
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@np
np / cmdcheck
Created November 24, 2011 23:28
cmdcheck & cmdrecord
#!/bin/bash -e
# Current bashisms are:
# a=(foo bar baz)
# ${foo[@]}
# $(bar)
# local
# (( bar ))
# for i; do; ...; done is not a bashism, right?
@np
np / git-trash.sh
Created May 7, 2012 05:42
Move files to a trash branch
#!/bin/bash
set -e
error(){
echo "$@" >>/dev/stderr
exit 1
}
GIT_TRASH_FILE=.git/trash.idx
remotes=(origin)