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
def collatz(start: Long) = { | |
def collatz_i(chain: List[Long]): List[Long] = { | |
if (chain.head == 1) chain | |
else if (chain.head % 2 == 0) collatz_i((chain.head / 2) :: chain) | |
else collatz_i((chain.head * 3 + 1) :: chain) | |
} | |
collatz_i(start :: Nil) | |
} | |
(2 until 1000000).foldLeft((1,collatz(1).size)){(acc,next) => | |
val chainSize = collatz(next).size |
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
./otp_build configure --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu --prefix=/opt/erlang erl_xcomp_sysroot=/opt/arm-2009q3 --disable-hipe --disable-threads --disable-smp --disable-megaco-flex-scanner-lineno --disable-megaco-reentrant-flex-scanner --disable-dynamic-ssl-lib --without-termcap --without-javac --without-ssl | |
./otp_build boot |
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
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
~/$ lein new ring-on-heroku | |
Created new project in: /home/jim/Development/ring-on-heroku | |
~/$ cd ring-on-heroku | |
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile | |
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj | |
(ns ring-on-heroku.core | |
(:use ring.util.response | |
ring.adapter.jetty)) | |
(defn app [req] |
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
/* | |
author: jbenet | |
os x, compile with: gcc -o testo test.c | |
linux, compile with: gcc -o testo test.c -lrt | |
*/ | |
#include <time.h> | |
#include <sys/time.h> | |
#include <stdio.h> |
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/bash | |
# | |
OTPVERUC=$(echo $1 || if=- conv=ucase) | |
OTPVERLC=$(echo $1 || if=- conv=lcase) | |
TARBALL=otp_src_$OTPVERUC.tar.gz | |
HTML=$PWD/otp_doc_html_$OTPVERUC.tar.gz | |
MAN=$PWD/otp_doc_man_$OTPVERUC.tar.gz | |
## Build-32-bit OSX | |
build_32 () |
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
%% @doc A small LRU list container. | |
%% @todo Add better documentation. | |
%% @todo Find edge case bugs in purging. | |
-module(lrulist). | |
-author("Nick Gerakines <nick@gerakines.net>"). | |
-export([new/0, new/1, get/2, insert/3, remove/2, purge/1, keys/1]). | |
-define(EXPIRE_RULES, [expire, slidingexpire]). | |
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
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages. | |
# ghc-pkg-clean -f cabal/dev/packages*.conf also works. | |
function ghc-pkg-clean() { | |
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |
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
# shove this in ~/.chef/bootstrap/joyent-smartos.erb | |
# run knife bootstrap <hostname> -d joyent-smartos | |
bash -c ' | |
if [ ! -f /opt/local/bin/chef-client ]; then | |
cd /tmp | |
pkgin install gcc-compiler gcc-runtime gcc-tools-0 ruby19 scmgit-base scmgit-docs gmake sun-jdk6 | |
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz | |
tar -xzf rubygems-1.8.10.tgz | |
cd rubygems-1.8.10 |
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;As shown in the presentation: http://blip.tv/clojure/clojure-concurrency-819147 |
OlderNewer