This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCanvas() { | |
const newWindow = window.open(''); | |
const link = newWindow.document.createElement('link'); | |
link.rel = 'stylesheet'; | |
link.href = 'https://fonts.googleapis.com/css?family=Poor+Story'; | |
link.onload = function () { | |
const newCanvas = newWindow.document.createElement('canvas'); | |
const newContext = newCanvas.getContext('2d'); | |
newWindow.document.body.appendChild(newCanvas); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a simple example of web worker | |
* Background task is a class which creates a new thread. | |
* 'fn' is a heavy CPU utilization function | |
* 'start' method accepts only one argument (a message for web worker) | |
* Restrictions: | |
* - fn must be a pure function. It does not have an access to any outer scope vars. | |
* - fn must not be native function. | |
* - fn must not be bound to any 'this' | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Creates an array of truthy elements | |
const joinTruthy = (glue, ...args) => args.filter(arg => arg).join(glue); | |
// Simple bem function | |
export const bemUnbound = (blockName, elementName, options = {}) => [ | |
joinTruthy('__', blockName, elementName), | |
...Object | |
.entries(options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [1, 3, 5, 7, 8, 11, 12, 13, 20] -> 1,3,5,7-8,11-13,20 | |
function short(arr) { | |
var sorted = arr.sort(function (a, b) { | |
if (a < b) { return -1; } | |
else if (a > b) { return 1; } | |
else { return 0; } | |
}); | |
function add(res, newValue) { | |
var last = res[res.length-1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal" | |
android:clickable="true" | |
android:focusable="true" | |
android:layout_weight="1" | |
android:background="?android:attr/selectableItemBackground"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const braces = '(())'; | |
const checkConsistance = (str) => { | |
const res = str | |
.split('') | |
.reduce( | |
(acc, current) => ({ | |
'(': () => { ++acc['(']; return acc; }, | |
')': () => { ++acc[')']; return acc; } | |
})[current](), { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function load () { | |
for (var i=0; i<60000; ++i) { | |
for (var j=60000; j>=0; --j) { | |
a = i*j; | |
} | |
} | |
} | |
function cpuConsume(count, cpuLoadFunc) { | |
var num = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style> | |
.list { | |
width : 250px; | |
} | |
.list table tbody tr td:first-child { | |
min-width: 250px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
*, html, body { | |
margin: 0px; | |
padding: 0px; | |
} | |
table { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ru"> | |
<head> | |
<title>Format Date</title> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
input { | |
display : block; | |
} | |
</style> |
NewerOlder