Skip to content

Instantly share code, notes, and snippets.

View vitkon's full-sized avatar
🎨
Building accessible UIs

Vitaly Kondratiev vitkon

🎨
Building accessible UIs
View GitHub Profile
@vitkon
vitkon / Pipe.js
Created May 9, 2017 07:30
Simple composition in ES6
const pipe = (...fns) => x => fns.reduce((acc, fn) => fn(acc), x);
pipe(g, f)(20); // 42
@vitkon
vitkon / WebSocketProvider.ts
Created April 28, 2017 00:24
WebSocket Provider (sockjs + stomp)
const wsUri = 'http://localhost:8080/websocket';
const webstomp = require('webstomp-client');
const SockJS = require('sockjs-client');
const TIMEOUT = 5000;
export enum SocketStatus {
CLOSED,
CONNECTING,
CONNECTED,
@vitkon
vitkon / tslint.json
Created March 21, 2017 13:34 — forked from piotrwitek/tslint.json
TSLint rules with ESLint/React extension based on airbnb style guide
{
"rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
],
"ban": false,
"class-name": true,
@vitkon
vitkon / deduplication.js
Created March 10, 2017 22:08
Array with unique elements (dedupication)
const unique = arr => arr.filter(
(el, index, self) => index === self.indexOf(el)
);
// create a new array of N elements filled with specific value
const isBusy = true;
const n = 12;
const schedule = [...Array(n).fill(isBusy)];
const rotateMatrix = arr => arr[0].map((col, i) => arr.map(row => row[i]));
@vitkon
vitkon / lastElement.js
Created August 8, 2016 11:08
last element in array
const arr = [1, 2, 3, 4, 5];
const last = [...arr].pop();
// or
const [last2, ...rest] = arr.reverse();
<h3>Choose a building</h3>
Current building: {{currentBuilding.name}}
<select>
{{#each buildings}}
<option value="{{_id}}" selected={{equals _id currentBuilding._id}}>{{name}}</option>
{{/each}}
</select>
@vitkon
vitkon / gist:0c2efb70103332715e44
Created November 17, 2014 16:27
Get url parameter by name
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@vitkon
vitkon / gist:0e3a5d4842475868b8e2
Created August 26, 2014 05:27
JavaScriptCore symlink for OSX
sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc