This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Knapsack where | |
import Control.Monad | |
import Data.Array | |
import Data.List | |
data Item a = Item { item :: a, | |
itemValue :: Int, | |
itemSize :: Int } | |
deriving (Eq, Show, Ord) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- numbertheoryfundamentals.hs | |
module NumberTheoryFundamentals where | |
-- Ch 1 of Cohen, A Course in Computational Algebraic Number Theory | |
import Bits (shiftL, shiftR) | |
import RandomGenerator (randomInteger) -- for sqrts mod p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def enc(s): | |
n = 0 | |
for c in s: | |
n = (n<<1)+random.randint(0, 1) | |
n = (n<<8)+ord(c) | |
return -1 * (~(n<<4)) | |
def dec(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
how was the trip back? | |
Jasmine Keene | |
lmao | |
you wouldn't believe | |
our bus broke down on the NJ turnpike | |
[email protected] | |
haha | |
that suuuuuuuuuuuuucks | |
Jasmine Keene | |
yea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PS1="\W \A \`if [ \$? == 0 ]; then echo \┬\─\┬ノ\(\º\_\º\ノ\); else echo \(\╯\°\□\°\)\╯\︵ \┻\━\┻\ ; fi\` " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns algos.dijkstra | |
(use '[clojure.contrib.incubator]) | |
) | |
(declare dijkstra build-path add-rdist update-rdists take-minnode) | |
(defn shortest-path | |
([net root nodedst children distance] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/zsh | |
TIME=$1 | |
FNAME=$2 | |
#if [[ $# != 3]] then; | |
# echo "USAGE: $0 time_interval filename" | |
# exit 2 | |
#fi | |
if [[ -f $FNAME ]]; then; | |
echo "filename taken!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Datomic example code | |
;; demonstrates various update scenarios, using a news database | |
;; that contains stories, users, and upvotes | |
;; grab an in memory database | |
(use '[datomic.api :only (q db) :as d]) | |
(def uri "datomic:mem://foo") | |
(d/create-database uri) | |
(def conn (d/connect uri)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = """ | |
(lambda fc=( | |
lambda n: [ | |
c for c in | |
().__class__.__bases__[0].__subclasses__() | |
if c.__name__ == n | |
][0] | |
): | |
fc("function")( | |
fc("code")( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Compile with the `-b -c` flags to the coffee-script compiler | |
# `String.prototype.score` | |
# ------------------------ | |
String::score = (abbreviation) -> | |
# **Size optimization notes**: | |
# Declaring `string` before checking for an exact match | |
# does not affect the speed and reduces size because `this` | |
# occurs only once in the code as a result. | |
string = this |