Skip to content

Instantly share code, notes, and snippets.

View pokatomnik's full-sized avatar
💡
A man of idea

Danilian Akhmedzianov pokatomnik

💡
A man of idea
View GitHub Profile
@pokatomnik
pokatomnik / circle.js
Last active April 12, 2016 10:43
PhaserJS drawing circle example
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { create: create });
function create() {
var graphics = game.add.graphics(100, 100);
// draw a circle
graphics.lineStyle(2, 0x0000FF, 1);
graphics.beginFill(0xFFFF0B, 0.5);
graphics.drawCircle(470, 200, 200);
@pokatomnik
pokatomnik / perforated-polygons.js
Last active April 18, 2016 05:50
phaserjs perforated polygons
var polygons = [ // A
[ // B
[ // C
[200, 100], // D
[350, 100],
[375, 200],
[150, 200],
],
[
/* [210, 110], */ //[250, 110],
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Format Date</title>
<meta charset="utf-8">
<style type="text/css">
input {
display : block;
}
</style>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
*, html, body {
margin: 0px;
padding: 0px;
}
table {
<!doctype html>
<html>
<head>
<style>
.list {
width : 250px;
}
.list table tbody tr td:first-child {
min-width: 250px;
}
@pokatomnik
pokatomnik / node-cpu.js
Created August 28, 2017 01:15
This very simple example demonstrates why heavy CPU tasks is really bad idea for node.js (and browser javascript VM, of course)
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;
const braces = '(())';
const checkConsistance = (str) => {
const res = str
.split('')
.reduce(
(acc, current) => ({
'(': () => { ++acc['(']; return acc; },
')': () => { ++acc[')']; return acc; }
})[current](), {
<?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">
@pokatomnik
pokatomnik / Yandex_task.js
Created February 9, 2018 23:35
Yandex interview tasks
// [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];
@pokatomnik
pokatomnik / bem.js
Created June 23, 2018 23:24
Bem utils for Javascript/Typescript
'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)