Skip to content

Instantly share code, notes, and snippets.

View kevroletin's full-sized avatar
🌴
Riding a scooter

Vasiliy Kevroletin kevroletin

🌴
Riding a scooter
View GitHub Profile
@kevroletin
kevroletin / stream-reorderer.hs
Last active April 2, 2018 01:14
Stateful stream transformation using lazy lists, Conduit and Streamly
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
module Main where
import Conduit
import Control.Monad.State
import Streamly
import qualified Streamly.Prelude as S
-- | reorder takes each N elements from a list and reverses them, e.g.
Кирилл InOutВася InOutМиша InOutВитя InOutАндрей InOut
Пивко+311-965+311+311-280+311
Пиццы+332+332-1660+332+332+332
Банька+1600-5000+1600+1600+1600-1000+1600-2000
Аэрохоккей+40+40+40-50+40-150+40
Такси+242-250+242-250+242+242-470
1972-50002525-28752525-3002525-14302525-2470
@kevroletin
kevroletin / dynamic-cpp-root-loader.el
Last active December 1, 2015 03:07
Sample code of dynamic cpp-root project loader (for ede project manager)
(require 'projectile)
(require 'dash)
(require 'ede)
;; TODO: create weigh function which considers length of path and
;; amount of names like "inc", "include", "sdk", "lib" etc
(defun my-best-match (dir file-name)
(let* ((default-directory dir)
(all-files (projectile-current-project-files))
(good-files (--filter (string-match file-name it) all-files)))
@kevroletin
kevroletin / emacs-theme-cycler.el
Created July 27, 2015 13:52
Sample code to cycle through themes from several packages from melpa. Requires starter-kit-install-if-needed from Emacs Starter Kit
(require 'dash)
(defun sk-theme-chooser--get-theme-package (theme)
(if (consp theme) (plist-get theme :package)
(intern (concat (symbol-name theme) "-theme"))))
(defun sk-theme-chooser--get-theme-list (theme)
(if (consp theme) (plist-get theme :themes)
(list theme)))
package rxtest;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import rx.Observable;
import rx.subjects.PublishSubject;
public class RxTest {
/**
class MapOnce<T, R> {
private final PublishSubject<R> subject = PublishSubject.create();
private MapOnce(Observable<T> source, Function<T, R> func) {
source.subscribe((T data) -> {
R result = func.apply(data);
subject.onNext(result);
});
}
program Simple; {$APPTYPE CONSOLE}
type TProc = reference to Procedure;
var i: Integer;
arr: array[1..5] of TProc;
begin
for i := 1 to 5 do
arr[i] :=
procedure begin
end;
program capture_by_value;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
@kevroletin
kevroletin / gist:5070644
Last active December 14, 2015 10:18
Explore how many memory Delphi allocates for FrameObjects.
program frameobj_alloc;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
const
@kevroletin
kevroletin / gist:5069653
Last active December 14, 2015 10:09
Test where Delphi allocates local variables of anonymous methods
program inner_var;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type