Skip to content

Instantly share code, notes, and snippets.

View nkaretnikov's full-sized avatar

Nikita Karetnikov nkaretnikov

View GitHub Profile
@nkaretnikov
nkaretnikov / call.s
Created August 22, 2017 18:15
call fails in gdb
; test@test:~$ nasm -f elf64 -o call.o call.s
; test@test:~$ ld -o call call.o
; test@test:~$ ./call
; test@test:~$ echo $?
; 13
; test@test:~$
; test@test:~$ gdb -q call
; Reading symbols from call...(no debugging symbols found)...done.
; (gdb) b _start
; Breakpoint 1 at 0x400080
@nkaretnikov
nkaretnikov / break.py
Created August 19, 2017 11:00
IDAPython breakpoint hook
from idc import *
from idaapi import *
from idautils import *
counter = 0
lst = []
addr = 0x01073E62
# See idapython/src/examples/debughook.py
@nkaretnikov
nkaretnikov / test.c
Last active August 2, 2017 05:37
scanf read
#include <stdio.h>
#include <unistd.h>
int main()
{
int d = 0;
class ConsLub (h :: *) (t :: [*]) (l :: [*]) | h t -> l where
consLub :: h -> t -> l
{-
Data/HList/RecordAdv.hs:157:19:
Expected a type, but ‘t’ has kind ‘[*]’
In the type ‘h -> t -> l’
In the class declaration for ‘ConsLub’
-}
@nkaretnikov
nkaretnikov / build.sh
Created June 3, 2016 13:36
nix-build default.nix outside Nixpkgs
nix-build -E "let nixpkgs = import <nixpkgs> {}; f = import ./default.nix; in nixpkgs.pkgs.haskellPackages.callPackage f {}"
@nkaretnikov
nkaretnikov / Sets.agda
Last active April 24, 2016 18:43
Sets
module Sets where
-- Set.
-- A = {x : P(x)}
data PSet {A : Set} (P : A → Set) : Set where
pset : ∀ {x : A} → P x → PSet P
-- Set membership.
_∈_ : {A : Set} → A → (A → Set) → Set
x ∈ p = p x
@nkaretnikov
nkaretnikov / mul.hs
Created April 15, 2016 01:30
Mul group
-- might be wrong
f p b g n = forM_ [0..n] $ \x -> putStrLn $ mconcat [ "x:", show x, ", res1:", show (b^x `mod` p), ", res2:", show (((b^x `mod` p) * g) `mod` p) ]
f' p b g n = sort $ concat $ flip fmap [0..n] $ \x -> [ (b^x `mod` p),(((b^x `mod` p) * g) `mod` p) ]
f'' p b g n = flip fmap [0..n] $ \x -> (((b^x `mod` p) * g) `mod` p)
bin = \x -> showIntAtBase 2 $ intToDigit x ""
@nkaretnikov
nkaretnikov / PSet.agda
Created April 5, 2016 01:45
PSet.agda
-- Set.
-- A = {x : P(x)}
data PSet (A : Set) {P : A → Set} : Set where
pset : ∀ {x : A} → P x → PSet A
@nkaretnikov
nkaretnikov / and.agda
Created April 4, 2016 22:41
and.agda
{-
Inductive and (P Q : Prop) : Prop :=
conj : P -> Q -> (and P Q).
-}
data and {A : Set} {a : A} {P Q : A → Set} : P a → Q a → (A → Set) where
conj : P a → Q a → and (P a) (Q a)
{-
Sets.agda:4,27-30
Set₁ != Set
*-assoc : ∀ a b c → (a * b) * c ≡ a * (b * c)
*-assoc zero b c = refl
*-assoc (succ a) b c =
*+-dist b (a * b) c ~ cong (λ x → b * c + x) (*-assoc a b c)