Skip to content

Instantly share code, notes, and snippets.

View funrep's full-sized avatar

Karl-Oskar Rikås funrep

View GitHub Profile
lastButOne :: [a] -> a
lastButOne xs =
if xs == [] then "Empty list :P"
if (length xs) == 1 then "You need more items in your list :P"
else last (init xs)
-- file: ch04/InteractWith.hs
-- Save this in a source file, e.g. Interact.hs
import System.Environment (getArgs)
interactWith function inputFile outputFile = do
input <- readFile inputFile
writeFile outputFile (function input)
main = mainWith myFunction
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain arch
::1 localhost.localdomain localhost
# End of file
klr@(none):~/tmp $ cat test.c
#include <stdio.h>
main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
#!/usr/bin/env python2.7
import os, sys, getopt
def main():
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
for o, a in opts:
output = a
@funrep
funrep / posty
Created November 1, 2012 16:16
blablabla
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
### config ###
title = 'Blah blah blah!'
theme = '#000066'
font = ('Arial', '14px')
colors = (
'#EEEEEE', # Background
# this code:
import argparse
parser = argparse.ArgumentParser(prog='cat.py')
parser.add_argument('file', help='file to print and catenate')
main():
args = parser.parse_args()
file = open(args.file, 'r').read()
# cat.py
import argparse
parser = argparse.ArgumentParser(prog='cat.py')
parser.add_argument('file', nargs='+', help='file(s) to print and catenate')
def main():
args = parser.parse_args()
files = open(args.file, 'r').read()
print files
(require-extension lowdown)
(markdown->html current-input-port)
(require-extension lowdown)
(markdown->htm)
$ ./main test.md
Error: unbound variable: markdown->htm
Call history: