Skip to content

Instantly share code, notes, and snippets.

@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;
<?php
/**
--
-- Table structure for table `adjacent_table`
--
DROP TABLE IF EXISTS `adjacent_table`;
@fesor
fesor / example.js
Created January 4, 2015 19:02
js-model example
angular.module('js-model', [])
.provider('jsModel', jsModelProvider)
.config(function (jsModelProvider) {
jsModelProvider
.register('Photo')
.register('User', function (Photo) {
return {
Feature: Authentification and Authorization
In order to use app
As a user
I should successfully sign in into my account
Background: Users registered in the system
Given users registered:
| name | email | password |
| Sergey | qa1@example.com | qa1pass |
Given i on login screen