Skip to content

Instantly share code, notes, and snippets.

View zudov's full-sized avatar

Konstantin Zudov zudov

View GitHub Profile
@zudov
zudov / Cropper.java
Last active October 21, 2018 14:46
Crop image using javacv.
import static com.googlecode.javacv.cpp.opencv_core.cvCopy;
import static com.googlecode.javacv.cpp.opencv_core.cvCreateImage;
import static com.googlecode.javacv.cpp.opencv_core.cvGetSize;
import static com.googlecode.javacv.cpp.opencv_core.cvSetImageROI;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;
import com.googlecode.javacv.cpp.opencv_core.CvRect;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
@zudov
zudov / BodyEditorLoader.java
Last active May 13, 2019 23:52
That is a version of loader for physic-body-editor that works with new JSON API from libgdx nightlies.
package aurelienribon.bodyeditor;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.JsonReader;
@zudov
zudov / minisodium_1.purs
Last active September 15, 2015 06:07
MiniSodium v1
module MiniSodium where
import Prelude
import Data.Maybe
import Control.Apply
import Control.Bind
data Stream m a = Stream { sample :: m (Maybe a) }
runStream (Stream s) = s
@zudov
zudov / Cycle-IO.md
Last active May 6, 2024 05:15
Cycle's approach to handling the IO

Cycle.js approach to handling IO looks similar to how it was done in earlier FRP implementations. That seems to be an independent discovery, and that's always even better.

Yampa provides a function reactimate:

:: IO a	-- ^ IO initialization action
-> (Bool -> IO (DTime, Maybe a)) -- ^ IO input sensing action
-> (Bool -> b -> IO Bool)        -- ^ IO actuaction (output processing) action
-> SF a b	-- ^ Signal function
@zudov
zudov / ConstraintFunctor.hs
Last active December 29, 2015 22:42
ConstraintKinds, Functor, Set
-- | https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/
{-# LANGUAGE ConstraintKinds, TypeFamilies #-}
import Prelude hiding (Functor(..))
import Data.Set (Set)
import qualified Data.Set as Set
import GHC.Exts (Constraint)
class Functor f where
type Object f a :: Constraint
@zudov
zudov / keybase.md
Created February 5, 2016 04:18
keybase.md

Keybase proof

I hereby claim:

  • I am zudov on github.
  • I am zudov (https://keybase.io/zudov) on keybase.
  • I have a public key ASBCMjt4P9UCqUn1lR9fvFcKdpAqNYRT5c1OX1ZdVmmh6Ao

To claim this, I am signing this object:

@zudov
zudov / AffEventuallyPromises.md
Last active June 17, 2016 12:04
Aff vs. Promises vs. Eventual values.

I recently read this interesting post about eventual values. One thing that struck me and which I failed to understand is:

  • Eventual Values can be interacted with like normal values.
  • If an Eventual Value is part of a simple value operation, then that expression resolves to a new Eventual > Value which resolves when all its Eventual Values are resolved.

If I understood the author correctly, that is supposed to be solving several problems:

  1. "I don’t know if this is a Promise or not" (I don't know if it's the resolved result of the action, or the action itself).
  2. "I’d really like to write code that interacts with values, and not Promises, and leave the machinery to the computer to work out".
@zudov
zudov / Main.purs
Last active October 10, 2016 22:58
having-effect, section 1, first-class-functions
-- | Some exercising for http://okmij.org/ftp/Computation/having-effect.html
module Main where
import Control.Monad.Eff.Console
import Control.Bind (bind)
import Data.Boolean (otherwise)
import Data.Eq ((==))
import Data.Semigroup ((<>))
@zudov
zudov / haskellx.org
Last active October 13, 2017 13:13
Attempt to take notes from Haskell eXchange talks

Alois Cochard :: Welcome to the Machines

History of data streaming

Problem

We want:

  • interleaving effects
  • constant space/time
  • strong compasability/reusability
  • We could try the List, but it doesn’t allow effects
  • We could interleave effects via monads (mapM etc), but no constant space/time then and/or lazy IO, meh