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 | |
eratosthenesS :: [Int] -> [Int] | |
eratosthenesS (x:xs) = x : (eratosthenesS $ filter (\e -> not ( 0 == mod e x)) xs) | |
primes :: [Int] | |
primes = (eratosthenesS [2..]) | |
isPrime' :: [Int] -> Int -> Int -> Bool | |
isPrime' (p:ps) xSqrt x | p > xSqrt = 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
main = do | |
xStr <- getLine | |
if 42 /= read xStr | |
then do | |
putStrLn xStr | |
main | |
else return () |
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
#!/usr/bin/perl -w | |
use strict; | |
my $ape_fname = $ARGV[0] or die "Usage: $0 file.ape [file.cue]\n"; | |
$ape_fname =~ /^(.*)\.ape$/ or die "$ape_fname - not an .ape file\n"; | |
my $base_fname = $1; | |
my $cue_fname = $ARGV[1] || $base_fname.'.cue'; | |
my $wav_fname = $base_fname.'.wav'; | |
my $mp3_fname = $base_fname.'.mp3'; | |
system mac => $ape_fname, $wav_fname, '-d'; |
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
#!/usr/bin/perl -w | |
use strict; | |
use AnyEvent::HTTP; | |
use Time::HiRes qw/time/; | |
use constant LOGGER_INTERVAL => 1; | |
use constant USAGE => "$0 [requests_count] [threads_count] [url]\n"; | |
my ( $max_requests, $max_threads, $url ) = @ARGV; | |
die USAGE unless $max_requests && $max_threads && $url; |
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 Text.Printf | |
data Triangle = Triangle Double Double Double | |
heron :: Triangle -> Double | |
heron (Triangle a b c) = sqrt( p * (p- c) * (p - b) * (p - a) ) | |
where p = (a + b + c) / 2 | |
height1 :: Triangle -> Double |
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
ERLDIRS = %w{ | |
elibs | |
elibs/balancer | |
elibs/config | |
elibs/convert | |
elibs/driver | |
elibs/handler | |
elibs/helper | |
elibs/mysql | |
elibs/tcp |
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
#!/usr/bin/perl -w | |
use strict; | |
use Redis; | |
use Data::Dumper; | |
use Digest::MD5 qw/md5/; | |
my ($key_count, $dump_period) = @ARGV; | |
my $r = Redis->new(); | |
sub key($) {unpack("H*", md5(shift))} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<items> | |
<item> | |
<TmpId>1</TmpId> | |
<Id>123</Id> | |
</item> | |
<item> | |
<TmpId>1</TmpId> | |
<Id>124</Id> | |
</item> |
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
#!/usr/bin/perl -w | |
use strict; | |
use Benchmark; | |
my $h = { map { $_, $_ } 1..10000 }; | |
timethese( 1000, { | |
each => sub{ my $i = 0; while( my ($k, $v) = each %$h ) { $i++ } }, |
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
#include <X11/Xlib.h> | |
void move(int dx, int dy) { | |
Display* d; | |
d = XOpenDisplay(0); | |
XWarpPointer(d,0,0,0,0,0,0,dx,dy); | |
XCloseDisplay(d); | |
} | |
int main(void) { |