Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/make -f
CFLAGS = -O3
.PHONY: all clean
all: main
main: main.c hoge.o
cc $(CFLAGS) -o $@ $^
@naohaq
naohaq / ps-mode.el
Created April 3, 2015 05:26
Emacs lisp for semi-automatic update of "CreationDate" comment on a postscript file
(defun format-time-string-with-locale-c (fmt)
(let ((system-time-locale "C")) (format-time-string fmt)))
(require 'ps-mode)
(defun ps-mode-update-creationdate ()
(interactive nil)
(save-excursion
(goto-char (point-min))
(and
(re-search-forward "^%%CreationDate: " nil t)
#!/usr/bin/tail -1
55
#!/bin/sh
echo -n 'aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghij' | wc -c
@naohaq
naohaq / summation_next.sh
Created May 14, 2015 03:44
Sum of 1 to 10
#!/bin/sh
fn=`mktemp`
echo -n 'a' >> $fn
echo -n 'aa' >> $fn
echo -n 'aaa' >> $fn
echo -n 'aaaa' >> $fn
echo -n 'aaaaa' >> $fn
echo -n 'aaaaaa' >> $fn
@naohaq
naohaq / summation_third.sh
Created May 14, 2015 04:00
Sum of 1 to 10
#!/bin/sh
cnt=`mktemp`
acc=`mktemp`
for c in a b c d e f g h i j ; do
echo -n $c >> $cnt ; cat $cnt >> $acc
done
wc -c < $acc
@naohaq
naohaq / sum_sed.sh
Created May 14, 2015 04:36
Sum of 1 to 10
#!/bin/sh
cmd=$(cat <<EOF)
s/j/.i/g
s/i/.h/g
s/h/.g/g
s/g/.f/g
s/f/.e/g
s/e/.d/g
s/d/.c/g
@naohaq
naohaq / skapplicative.hs
Created July 15, 2015 04:08
Combinators defined under Applicative.
module Main where
import Control.Applicative
newtype A = A Integer deriving Show
newtype B = B Integer deriving Show
newtype C = C Integer deriving Show
k :: Applicative f => a -> f a
k = pure
%!PS-Adobe-3.0
%%BoundingBox: 0 0 280 36
%%HiResBoundingBox: 0.0 0.0 280.0 36.0
%%CreationDate: Fri Jul 31 14:07:27 2015
%%BeginProlog
/! { load def } def
/M/moveto !/RM/rmoveto !/G/glyphshow !
%%EndProlog
%%BeginPageSetup
<</PageSize [280 36] /Margins [0 0] /PageOffset [0 0] /Orientation 0 >> setpagedevice
@naohaq
naohaq / bar.rb
Created May 29, 2012 02:41
Top level local variable in Ruby
load "foo.rb"
puts a # Error!