Skip to content

Instantly share code, notes, and snippets.

@kgadek
kgadek / background_tasks_example.lua
Last active January 3, 2016 12:29
Projekt Sauron: interfejs i przykładowy kod zadania typu `background_tasks`.
-- ---------------------------------------------------------------------------------------------------------------------
-- MOCK INTERFEJSU DOSTĘPNEGO NA APPCE
-- ---------------------------------------------------------------------------------------------------------------------
os = require "os"
local android = {}
function android.send(self, x)
print("ANDROID:SEND:", x)
end
function android.sleep(self, t)
print("ANDROID:SLEEP:", t)
@kgadek
kgadek / mergesort.lua
Created January 22, 2014 01:24
Projekt Sauron: kod zadania map-reduce: merge-sort.
-- =====================================================================================================================
-- MOCK INTERFEJSU DOSTĘPNEGO NA APPCE
-- Dzięki temu można "ot tak" wrzucić kod w interpreter i będzie działać
-- ---------------------------------------------------------------------------------------------------------------------
local android = {}
function android.send(self, x)
print("ANDROID:SEND:", x)
end
function android.sleep(self, t)
print("ANDROID:SLEEP:", t)
@kgadek
kgadek / parser.py
Created January 22, 2014 22:05
Current state of mrwhite::parser.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import lxml
import lxml.html
from itertools import count
def clipboard_to_cells():
@kgadek
kgadek / scrapemeagainimnotdeadyet.py
Created January 25, 2014 01:43
'Tallica: Seek and buy
#!/usr/bin/env python
# coding=utf-8
import os
from bs4 import BeautifulSoup
import requests
import time
import itertools
url = ("http://www.eventim.pl/Bilety-sonisphere-warszawa.html?affiliate=LNP&fun=evdetail"
@kgadek
kgadek / turbodynochecker.py
Created January 29, 2014 01:55
TurboDynoChecker - checking types in runtime via type annotations (PEP-3107)
from contextlib import contextmanager
from functools import wraps
from inspect import signature
from itertools import chain
class TypoDynoMismatch(Exception):
pass
@kgadek
kgadek / bench-core.hs
Last active August 29, 2015 13:57
Comparing fast & slow factorials
[1 of 1] Compiling Main ( bench.hs, bench.o )
==================== Tidy Core ====================
Result size of Tidy Core = {terms: 85, types: 57, coercions: 30}
lvl_r2PK :: Type.Integer
lvl_r2PK = __integer 0
main11 :: Type.Integer
@kgadek
kgadek / gist:9512169
Created March 12, 2014 17:43
I can into simple Lenses!
{-# LANGUAGE ExistentialQuantification #-}
data Point = Point { x :: Int, y :: Int } deriving (Show)
data Rect = Rect { a :: Point, b :: Point, c :: Point, d :: Point } deriving (Show)
data Lens s a = Lens { get :: s -> a, set :: s -> a -> s}
@kgadek
kgadek / gist:9515128
Created March 12, 2014 20:00
I can into lenses! (pt. 2)
{-# LANGUAGE RankNTypes #-}
import Data.Functor.Identity
import Control.Applicative
data Point = Point { _x :: Int, _y :: Int } deriving (Show)
data Rect = Rect { _a :: Point, _b :: Point, _c :: Point, _d :: Point} deriving (Show)
type Lens s a = forall f. Functor f => (a -> f a) -> s -> f s
@kgadek
kgadek / example.erl
Created March 28, 2014 17:19
sweet two bugs :D
-module(example).
-export(sort/1).
-export(spawnedsort/3, merge/3). % publishing internal funs
% only for debugging
sort(X) ->
ChunkLen = length(X) div 2,
{L1, L2} = lists:split(ChunkLen, X), % pattern matching example 1
@kgadek
kgadek / tmp.py
Last active August 29, 2015 13:58
Remote debuggging dla Piotrka-Zimnioka
#!/usr/bin/env python
class CQ(object):
bla = None
"""CQ Instance Object"""
def __init__(self, port, path, init):
self.port = port
self.path = path
self.init = init