Skip to content

Instantly share code, notes, and snippets.

View bsh314's full-sized avatar
🇺🇦

Bohdan Shcherbak bsh314

🇺🇦
  • Cocomore
  • Seville, Spain
View GitHub Profile
@bsh314
bsh314 / rx-sheduler.ts
Created March 6, 2019 10:41
Provides scheduled execution with some extras for rxjs.Observable objects
import { delay } from "rxjs/operators/delay";
import { Observable } from "rxjs/Observable";
import { Subject } from "rxjs/Subject";
import { Subscription } from "rxjs/Subscription";
import { v4 as uuid } from 'uuid';
/**
* Default scheduler task interface
*
* @export
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Url Spectrum</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script>
const chars = ["⡀", "⢠", "⢰", "⢸"];
@bsh314
bsh314 / JS Objects Deep Clone
Created November 14, 2018 11:48
Javascript objects deep clone with types preservation
function deepClone(obj) {
var copy;
// Handle the 3 simple types, and null or undefined
if (null == obj || "object" != typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
copy.setTime(obj.getTime());
private getAverageRGB(imgEl) {
const blockSize = 5; // only visit every 5 pixels
const defaultRGB = { r: 0, g: 0, b: 0 }; // for non-supporting envs
const canvas = document.createElement('canvas');
const context = canvas.getContext && canvas.getContext('2d');
const rgb = { r: 0, g: 0, b: 0 };
let data, width, height;
let i = -4;
let length;
let count = 0;