Skip to content

Instantly share code, notes, and snippets.

@fesor
fesor / labeling.py
Created February 23, 2014 22:46
Breadth First Search optimisation of recursive connected components labeling algorithm
import Image
import Queue
def select_label(used):
"""
:type used: set
:return: int
"""
prev = 0
@fesor
fesor / README.md
Last active August 29, 2015 13:57
Выделение связанных объектов с 4-х связностью, с последющим выделением признаков и класстеризацией

Connected components labeling and classification

Реализация выделения связанных объектов с 4-х связностью, последющим выделением признаков и класстеризацией.

Точка входа - main.py. Класстеризация - clustering.py поиск объектов и вычисление характеристик - connected_components.py работа с цветом - color.py

##Преимущества k-medoids относительно k-means

@fesor
fesor / controller_with_trait.php
Last active August 29, 2015 14:02
Bad and good examples of traits
<?php
trait Serialization
{
protected function serialize($data, $groups = null)
{
$context = new SerializationContext($groups);
return $this->serializer->serialize($data, $context);
}
@fesor
fesor / example.d
Last active August 29, 2015 14:03
Audio encoding/decoding
import audio;
auto soundDecoder = new Decoder(new BufferedFile("./mywave.mp3"));
// Decoder should implements opApply method;
// http://dlang.org/statement.html#opApply
foreach(ulong frameNumber, FrameInfo frame; soundDecoder) {
// so something usefull, FFT for example
doStuff(frame.data);
}
// or
@fesor
fesor / README.md
Last active August 29, 2015 14:03
Configurable class directive for angular

Configurable Classname Directives

Alternative for ng-class + something like $rootScope.bodyClass with more pretty implementation.

Example:

<div app-configurable-class>
    <!-- directive:app-set-class my-container-classname -->
 
app.factory('Slide', [ function () {
function Slide(blockData) {
this.data = angular.extend({}, blockData || {});
this.uploadInfo = {};
this.uploadOptions = {
fieldName: 'asset[attachment]' // может это дело в конструктор передавать? это ж настройки по идее...
change: angular.bind(this, this.cangeHandler)
};
@fesor
fesor / README.md
Last active August 29, 2015 14:05
Simple benchmark of array search methods

Простенький бенчмарк на коллекции эллементов в 1000 штук, обход делается 100 раз в рамках одного бенчмарка для большей точности, бенчмарк прогоняется 10 раз.

Результаты на моем не сильно мощном ноуте:

PHP 5.5.9 (cli)

Array filter with simple foreach:
-----------------
Average execution time: 2045 ns
@fesor
fesor / example.js
Last active August 29, 2015 14:07
ApiClientFactory PoC
angular.module('app', [])
.constant('server', {endpoint: 'http://test.com'})
.config(function(server, apiClientFactoryProvider) {
apiClientFactoryProvider.register({
'api': {
endpoint: server.endpoint, // will be concatinated with url
// global interceptors are bad, right? Heres a local one!
// Fully compatible with global interceptors
interceptors: ['myAuthInterceptor', 'noInternetConnectionInterceptor']
},
@fesor
fesor / bench.php
Created October 17, 2014 23:56
Experements...
<?php
define('REPEAT_BENCH', 4);
define('REPEAT_EXEC', 5);
function array_merge_sorted($first, $second)
{
$out = [];
for (
$f = 0, $s = 0,
.message,
.success,
.error,
.warning {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
border-color: green;