Skip to content

Instantly share code, notes, and snippets.

View savonarola's full-sized avatar
🏠
Working from home

Ilia Averianov savonarola

🏠
Working from home
View GitHub Profile
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
main = do
xStr <- getLine
if 42 /= read xStr
then do
putStrLn xStr
main
else return ()
#!/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';
#!/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;
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
ERLDIRS = %w{
elibs
elibs/balancer
elibs/config
elibs/convert
elibs/driver
elibs/handler
elibs/helper
elibs/mysql
elibs/tcp
#!/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))}
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<TmpId>1</TmpId>
<Id>123</Id>
</item>
<item>
<TmpId>1</TmpId>
<Id>124</Id>
</item>
@savonarola
savonarola / b.pl
Created July 26, 2010 11:03 — forked from anonymous/b.pl
#!/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++ } },
#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) {