Skip to content

Instantly share code, notes, and snippets.

View pxqr's full-sized avatar
💭
how many letters i can put here?

Samvel Truzyan pxqr

💭
how many letters i can put here?
View GitHub Profile
@pxqr
pxqr / movarec.hs
Created September 4, 2014 04:34
movarec corner detection in accelerate
module Moravec where
import Data.Array.Accelerate as A
import Data.Array.Accelerate.Interpreter as A
import Data.Array.Accelerate.IO as IO
moravec :: Exp DIM2 -- ^ neighbor region size;
-> Exp DIM2 -- ^ patch sizes;
-> Acc (Array DIM2 Float) -- ^ a grayscale image;
-> Acc (Array DIM2 Float) -- ^ corner intensities.
moravec n p i = fold2 min (1/0) $ A.map unzero
-- | Linear feedback shift registers.
--
-- a good table of taps:
-- http://home1.gte.net/res0658s/electronics/LFSRtaps.html
--
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DefaultSignatures #-}
module Data.LFSR where
import Data.Bits
@pxqr
pxqr / lambda
Created June 9, 2014 12:05
outputs svg lambda in grayscale
{-# LANGUAGE NoMonomorphismRestriction #-}
module Main (main) where
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
lambda :: Diagram B R2
lambda = fromVertices
[ 0 ^& 0, 0.4 ^& 0.6
, 0.2 ^& 1.0, 0.4 ^& 1.0
, 1.0 ^& 0, 0.8 ^& 0
@pxqr
pxqr / solarized.scss
Created June 3, 2014 22:46
Solarized pallette for Kate HTML formatter.
/* solarized pallette: http://ethanschoonover.com/solarized */
$base03 : #002b36; /* optional emphasized content */
$base02 : #073642; /* body text / default code / primary content */
$base01 : #586e75;
$base00 : #657b83;
$base0 : #839496;
$base1 : #93a1a1; /* comments / secondary content */
$base2 : #eee8d5; /* background highlights */
$base3 : #fdf6e3; /* background */
@pxqr
pxqr / kmeans.hs
Created April 18, 2014 18:52
gpu k-means
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TypeOperators #-}
module Data.Clustering.KMeans
( -- * Types
Points
, Centroids
, ClusterIx
@pxqr
pxqr / Bloom.hs
Created March 29, 2014 17:59
bloom filters
module Data.Filter.Bloom
( Bloom(..), HashFun
-- ^ Construction
, empty
-- ^ Query
, member, notMember
-- ^ Combine
, intersection, union
-- ^ Conversion
, freeze, thaw, unsafeFreeze, unsafeThaw
@pxqr
pxqr / Bin.hs
Created March 29, 2014 17:50
parsing and pretty printing of some quantities with units by introducing newtype wrappers. Despite of pretty printing, Read/Show instances obey standart rules. This might be useful in some CLI programs and options parsing.
-- SI binary prefixes of positive power.
--
-- > http://physics.nist.gov/cuu/Units/binary.html
--
{-# LANGUAGE Safe #-}
module Data.Unit.Bin
( Unit(..)
, prefix, fromPrefix, multiplier
, unit, formatS
) where
@pxqr
pxqr / dataset.m
Created March 15, 2014 18:51
backup (very) old stuff
// datasets of 2D points:
// http://people.sc.fsu.edu/~jburkardt/datasets/spaeth/spaeth.html
// tr '\n' ';'
// small clouds are consist from 2d points
points = [41 45; 39 44; 42 43; 44 43; 10 42; 38 42; 8 41; 41 41;
13 40; 45 40; 7 39; 38 39; 42 39; 9 38; 12 38; 19 38;
25 38; 6 37; 13 35; 9 34; 12 34; 32 27; 26 25; 39 24;
34 23; 37 23; 22 22; 38 21; 35 20; 31 18; 26 16; 38 13;
29 11; 34 11; 37 10; 40 9; 42 9];
{-# LANGUAGE ExistentialQuantification, DefaultSignatures #-}
module Control.Parallel.CL.Kernel.Arg where
import Control.Parallel.OpenCL
import Control.Monad.CL
import Foreign
data ArgW a = Arg a => MkArg a
@pxqr
pxqr / Tracker.hs
Created March 3, 2014 13:46
skeleton of tracker
-- |
-- Copyright : (c) Sam Truzjan 2013
-- License : BSD3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
-- BitTorrent tracker WAI application.
--
{-# LANGUAGE RecordWildCards #-}