Skip to content

Instantly share code, notes, and snippets.

View killerswan's full-sized avatar

Kevin Cantú killerswan

View GitHub Profile
[~/Desktop]$ aptitude moo
There are no Easter Eggs in this program.
[~/Desktop]$ aptitude moo -vv
Didn't I already tell you that there are no Easter Eggs in this program?
[~/Desktop]$ aptitude moo -vvv
Stop it!
[~/Desktop]$ aptitude moo -vvvv
Okay, okay, if I give you an Easter Egg, will you go away?
@killerswan
killerswan / gist:941923
Created April 26, 2011 07:04 — forked from mneedham/gist:941892
Purely Functional Data Structures - Chris Okasaki
(* This uses the @ operator (aka List.append) which is not tail recursive *)
let suffixes list =
let rec loop l acc =
match l with
| [] -> acc
| x::xs -> loop xs (acc @ [xs]) in
loop list [list]
(* This uses an operator @+ constructed from two tail recursive methods... :P *)
@killerswan
killerswan / gist:942108
Created April 26, 2011 10:53 — forked from mneedham/gist:941867
Purely Functional Data Structures - Chris Okasaki
(* Brian McNamara's approach isn't actually that bad, unless List had an efficient append. But simplify it like so... *)
let suffixesTR3 list =
let rec loop l acc =
match l with
| [] -> acc
| _::xs -> loop xs (xs :: acc) in
List.rev (loop list [list])
@killerswan
killerswan / gist:943878
Created April 27, 2011 07:53
display palindromes, F#
let subs (s:string) =
let lim = s.Length - 1
[ for ii in [0..lim] do
for jj in [0..lim] do // can these two be combined?
if ii < jj then
yield s.[ii..jj] ]
let isPalindrome s =
let s' = Array.ofSeq s
@killerswan
killerswan / centered_triangle.html
Created May 3, 2011 06:26 — forked from romannurik/centered_triangle.html
A simple CSS trick to create a horizontally- or vertically-centered 'selected' callout triangle using zero images.
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 40px;
}
a {
display: inline-block;
@killerswan
killerswan / search.fsx
Created September 8, 2011 20:39
filtering a large file with a list of things
open System
open System.IO
// use an @ string
let list = @"C:\list.txt"
// initialize a reader
let reader = new StreamReader(list)
// create a list of lines
@killerswan
killerswan / runfsi.fsx
Created September 8, 2011 20:41
run fsharp/F# in Cygwin
#!/usr/bin/bash
FSI="/cygdrive/c/fsharp/FSharp-2.0.0.0/bin/fsi.exe"
FLAGS="--nologo"
if [[ $# -eq 0 ]]
then
exec "$FSI" "$FLAGS"
@killerswan
killerswan / args2.fs
Created September 10, 2011 06:24
args for both interactive and compiled F#
// Copyright © 2011, Kevin Cantu, [email protected]
//
// Usage: runfsi --nologo --exec args2.fs -- $@
module Simple
open System
open System.IO
@killerswan
killerswan / testingTreeView.cs
Created September 22, 2011 23:01
A messy example showing use of the GTK# TreeView
using System;
using System.IO;
using Gtk;
namespace DemoII
{
public class FruitTreePiece
{
public string name;
public string description;
fn f(s : option::t<str>) {
let r = alt s {
some(ss) { { x: 123, y: ss } }
none. { fail }
};
}