Skip to content

Instantly share code, notes, and snippets.

@japesinator
japesinator / gist:8845678
Last active August 29, 2015 13:56
Stream Cipher Presentation for ISUSEC
XOR, Stream Ciphers, and Crib dragging
Boolean Logic
```
AND OR XOR
---- ---- ----
TT|T TT|T TT|F
TF|F TF|T TF|T
import Data.Ratio
import Data.Complex
import Data.Array
data LispNumber = Complex (Complex Double)
| Rational (Ratio Integer)
| Float Double
| Integer Integer
lispMath :: (Num a) => (a -> a -> a) -> LispNumber -> LispNumber -> LispNumber
module Clustering
import Data.Floats
-- Feature Normalization
-- {{{
foldl1List : (a -> a -> a) -> List a -> a
foldl1List func (x :: xs) =
case xs of
[] => x
Warning: haddock-interfaces: /Library/Haskell/ghc-7.6.3/lib/haskell-platform-2013.2.0.0/doc/html/haskell-platform.haddock doesn't exist or isn't a file
Warning: haddock-html: /Library/Haskell/ghc-7.6.3/lib/haskell-platform-2013.2.0.0/doc/html doesn't exist or isn't a directory
-- Does not work (in any reasonable amount of time)
allHasCount : Vect n (a, Nat) -> Nat -> Bool
allHasCount [] n = True
allHasCount ((a, b) :: xs) n = b == n && allHasCount xs n
addCount : (a -> a -> a) -> (a, Nat) -> (a, Nat) -> (a, Nat)
addCount f (a, n) (b, m) = (f a b, n + m + 1)
foldrHomoByte : (a:Vect 5 (b,Nat)) -> (f:b -> b -> b) -> (p:allHasCount a 1 = True) -> toIntegerNat (snd (foldr1 (addCount f) a)) = 9
@japesinator
japesinator / AT&T
Created October 28, 2014 19:02
Are these the same?
MOV $23133,%ebx
MOV $12733,%eax
MOV $27798,%ecx
CMP %eax,%ebx
JL L1
JMP L2
L1:
IMUL %eax,%ebx
ADD %eax,%ebx
MOV %ebx,%eax
@japesinator
japesinator / ...JS Out
Created November 26, 2014 21:45
#Web 2.0
/** @constructor */
var i$VM = function() {
this.valstack = [];
this.valstack_top = 0;
this.valstack_base = 0;
this.ret = null;
this.callstack = [];
}
Programming_Misc/Haskell/integral » ghc-pkg list | head
/usr/local/Cellar/ghc/7.8.3/lib/ghc-7.8.3/package.conf.d:
Cabal-1.18.1.4
array-0.5.0.0
base-4.7.0.1
bin-package-db-0.0.0.0
binary-0.7.1.0
rts-1.0
bytestring-0.10.4.0
containers-0.5.5.1
Programming_Misc/Haskell/integral » cabal exec runhaskell Main.hs
benchmarking integral/mine
time 49.60 ns (48.52 ns .. 50.70 ns)
0.996 R² (0.994 R² .. 0.998 R²)
mean 50.25 ns (49.22 ns .. 51.44 ns)
std dev 3.635 ns (2.956 ns .. 4.986 ns)
variance introduced by outliers: 85% (severely inflated)
benchmarking integral/not mine
time 50.62 ns (49.77 ns .. 51.62 ns)
Programming_Misc/Haskell/integral » cabal build && cabal install && .cabal-sandbox/bin/integralbench
Building integralbench-0.1.0.0...
Preprocessing executable 'integralbench' for integralbench-0.1.0.0...
[1 of 1] Compiling Main ( Main.hs, dist/build/integralbench/integralbench-tmp/Main.o )
Linking dist/build/integralbench/integralbench ...
Resolving dependencies...
Notice: installing into a sandbox located at
/Users/jp/Programming_Misc/Haskell/integral/.cabal-sandbox
Configuring integralbench-0.1.0.0...
Building integralbench-0.1.0.0...