Skip to content

Instantly share code, notes, and snippets.

@andrewhavck
andrewhavck / logger.rb
Created January 14, 2010 14:53
Auto log script for senior project website
We couldn’t find that file to show.
#
# GENERIC -- Generic kernel configuration file for FreeBSD/i386
#
# For more information on this file, please read the config(5) manual page,
# and/or the handbook section on Kernel Configuration Files:
#
# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
#
# The handbook is also available locally in /usr/share/doc/handbook
# if you've installed the doc distribution, otherwise always see the
-- file: ch03/Palindrome.hs
palindrome :: [a] -> [a]
palindrome [] = []
palindrome xs = xs ++ myReverse xs
where myReverse (x:xs) = myReverse xs ++ [x]
myReverse [] = []
interpret = fizzbuzz [1..100]
fizzbuzz [] = []
fizzbuzz (x:xs) = checknum(x) ++ fizzbuzz(xs)
checknum x | both x = "FizzBuzz"
| three x = "Fizz"
| five x = "Buzz"
| otherwise = show x
where both x = three x && five x
three x = (x `mod` 3) == 0
five x = (x `mod` 5) == 0
-- file:HuffmanEncoding/Frequency.hs
module Frequency where
import Data.List(nub,foldl')
frequencies :: (Eq a) => [a] -> [(a, Double)]
frequencies s = zip (nub s) (map divide qset)
where divide (_,d) = (d / (total qset))
qset = quantities (nub s) s
(defn factorial [n]
(loop [iter n, res 1]
(cond
(zero? iter) res
:else (recur (dec iter) (* res iter)))))
(defn combination [n k]
(/ (factorial n) (* (factorial (- n k)) (factorial k))))
(comment k = number of hot dogs)
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
int clearBitsMSBthroughI(int num, int i) {
int mask = (1 << (i + 1)) - 1;
return num & mask;
}
@andrewhavck
andrewhavck / index.html
Created December 13, 2012 16:33
Force directed network graph of #dwolla
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
@andrewhavck
andrewhavck / index.html
Created December 13, 2012 16:36
No labels
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}