Skip to content

Instantly share code, notes, and snippets.

View ischenkodv's full-sized avatar

Dmitri Ischenko ischenkodv

  • Ukraine, Kryvyi Rih
View GitHub Profile
function calculate_median($arr) {
$count = count($arr); //total numbers in array
$middleval = floor(($count-1)/2); // find the middle value, or the lowest middle value
if($count % 2) { // odd number, middle is the median
$median = $arr[$middleval];
} else { // even number, calculate avg of 2 medians
$low = $arr[$middleval];
$high = $arr[$middleval+1];
$median = (($low+$high)/2);
}
@ischenkodv
ischenkodv / RAFPlugin.js
Created February 28, 2015 20:24
Jasmine plugin to test functions with requestAnimationFrame.
/**
* Jasmine RequestAnimationFrame: a set of helpers for testing funcionality
* that uses requestAnimationFrame under the Jasmine BDD framework for JavaScript.
*/
;(function() {
var index = 0,
callbacks = {};
function MockRAF(global) {
@ischenkodv
ischenkodv / -
Created February 7, 2018 13:39 — forked from anonymous/-
System: Host: dima-System-Product-Name Kernel: 4.10.0-42-generic x86_64 (64 bit gcc: 5.4.0)
Desktop: Cinnamon 3.4.4 (Gtk 2.24.30) dm: mdm Distro: Linux Mint 18.2 Sonya
Machine: Mobo: ASUSTeK model: M4A785T-M v: Rev X.0x Bios: American Megatrends v: 0801 date: 10/14/2009
CPU: Dual core AMD Phenom II X2 550 (-MCP-) cache: 1024 KB
flags: (lm nx sse sse2 sse3 sse4a svm) bmips: 12455
clock speeds: min/max: 800/3100 MHz 1: 1900 MHz 2: 1900 MHz
Graphics: Card: Advanced Micro Devices [AMD/ATI] Redwood XT [Radeon HD 5670/5690/5730]
bus-ID: 01:00.0 chip-ID: 1002:68d8
Display Server: X.Org 1.18.4 drivers: ati,radeon (unloaded: fbdev,vesa)
Resolution: 1920x1080@60.00hz
@ischenkodv
ischenkodv / .block
Last active January 10, 2018 17:27 — forked from jasondavies/.block
Parallel Coordinates
license: gpl-3.0
@ischenkodv
ischenkodv / AsyncQueue.js
Created February 28, 2015 20:17
Asynchronous queue implementation. Functions could be added to queue and executed one by one immediately, or with intervals or in the next frame (using requestAnimationFrame).
;(function(window) {
'use strict';
/**
* AsyncQueue allows you to create a queue of function to be executed via
* setTimout that guaranteed to run in order. This can enable to run
* process-intensive operations without locking up UI.
*
* @constructor
@ischenkodv
ischenkodv / writable_stream.js
Created March 18, 2017 21:54
Example of writable stream in NodeJS.
const stream = require('stream');
const fs = require('fs');
class EchoStream extends stream.Writable {
_write(chunk, enc, next) {
console.log(chunk.toString());
next();
}
}
module.controller('CtrlImplAdvanced', ['$scope', '$controller', function ($scope, $controller) {
// Initialize the super class and extend it.
angular.extend(this, $controller('CtrlImpl', {$scope: $scope}));
// … Additional extensions to create a mixin.
}]);
var fs = require('fs');
var files = ['foo.txt', 'bar.txt', 'baz.txt'];
var promises = [];
for (var i = 0; i < files.length; i++) {
promises.push(readFile(files[i]));
}
@ischenkodv
ischenkodv / gist:7006705
Created October 16, 2013 12:09
Usage of SymbolPath as a google maps marker icon.
// Usage of SymbolPath as a marker icon
var marker = new google.maps.Marker({
position: new google.maps.LatLng(-122.5,47.5),
icon: {
path: google.maps.SymbolPath.CIRCLE,
fillOpacity: 0.5,
fillColor: 'ff0000',
strokeOpacity: 1.0,
strokeColor: 'fff000',
strokeWeight: 3.0,
@ischenkodv
ischenkodv / gist:6091581
Created July 26, 2013 19:27
CSS rotate element 5 degrees in IE
/* 5 degree */
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.99, M12=-0.08, M21=0.08, M22=0.99, SizingMethod="auto expand");
/*
m11 = sin (5 * pi / 180)
m12 = cos (5 * pi / 180)
m21 = cos (5 * pi/ 180)
m22 = sin (5 * pi / 180)
*/