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 static spark.Spark.*; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
get("/hello", (req, res) -> "Hello World"); | |
} | |
} |
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
-- Parallelized version of the unix "du" command that shows only the size of current *subdirectories. | |
-- pdu launches a new thread for each subdirectory, using the neat independence of subfolders. | |
-- (c) ane <ane@iki.fi> | |
-- license: BSDv3 | |
module Main where | |
import System | |
import System.IO | |
import System.Directory |
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
userRights = self.conn.search("member="+username) | |
apps = [app for app in userRights if 'groupOfNames' in | |
app['objectClass'] and | |
(app['cn'][0].startswith(prefix))] |
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
static IEnumerable<IEnumerable<T>> Permute<T>(IEnumerable<T> collection) | |
{ | |
// Initialize | |
int length = collection.Count(); | |
int[] b = Enumerable.Range(0, length).ToArray(); | |
// Set all in c to zero. | |
int[] c = Enumerable.Range(0, length + 1).Select(x => 0).ToArray(); | |
// Create a temporary copy. | |
List<T> set = collection.Select(x => x).ToList(); | |
while (true) |
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
static IEnumerable<IEnumerable<T>> Permute<T>(IEnumerable<T> collection) | |
{ | |
// Initialize | |
int length = collection.Count(); | |
int[] b = Enumerable.Range(0, length).ToArray(); | |
// Set all in c to zero. | |
int[] c = Enumerable.Range(0, length + 1).Select(x => 0).ToArray(); | |
// Create a temporary copy. | |
List<T> set = collection.Select(x => x).ToList(); | |
while (true) |
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
// Geneerisiä C++-toteutuksia Haskellin (2-)tuplafunktioista, ks. | |
// http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Prelude.html#19 | |
// uuden C++ 2011 -standardin ominaisuuksista osaa käyttäen. | |
// | |
// Kääntyy GCC 4.5.1 vivulla -std=c++0x | |
// ja VS2010 sellaisenaan. | |
// | |
// (c) ane 2011 <ane@iki.fi> (lisenssi: bsd v3) | |
#include <iostream> |
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
// Geneerisiä toteutuksia Haskellin (2-)tuplafunktioista, ks. | |
// http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Prelude.html#19 | |
// | |
// KÄä | |
// | |
// (c) ane 2011 <ane@iki.fi> (lisenssi: bsd v3) | |
#include <iostream> | |
#include <vector> | |
#include <iterator> |
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
ane@hyperion:~$ tracert helsinki.fi | |
Tracing route to helsinki.fi [128.214.222.4] | |
over a maximum of 30 hops: | |
1 <1 ms 1 ms <1 ms 192.168.100.1 | |
2 1 ms 1 ms 1 ms ananas-gw-alue1.kortex.jyu.fi [130.234.176.2] | |
3 1 ms 1 ms 1 ms 130.234.253.161 | |
4 1 ms <1 ms 1 ms jyu-funet.core.jyu.fi [130.234.254.92] | |
5 4 ms 4 ms 4 ms csc6-rtr.core.jyu.fi [130.234.254.6] |
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 Main where | |
import Data.List | |
magic :: Int -> Int -> Int | |
magic end c = foldr1 (+) (counted [1 .. end]) | |
where | |
counted list = map findN list | |
findN x = length . filter (\l -> length l == c) . group . sort . filter (/= 0) . map (\z -> z `mod` 10) . take 5 . iterate (\y -> y `div` 10) $ x |
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
-- in Stats.hs | |
processMessages :: Log -> [(S.ByteString, Int, Int)] | |
processMessages log = map fmt $ M.toList $ mapReduce rwhnf (foldl' update M.empty) | |
rwhnf (M.unionsWith (+)) ([msgs log]) | |
where | |
-- Increments the user (word count discardedfor now) line count by 1. | |
update map (Message _ nick _) = M.insertWith (+) nick 1 map | |
msgs = filter isMessage | |
-- FIXME: adds a word count of 1 to the (Nick, LineCount) pairs from M.toList | |
-- add wordcount! |
NewerOlder