Skip to content

Instantly share code, notes, and snippets.

View halfzebra's full-sized avatar

Eduard Kyvenko halfzebra

View GitHub Profile
console.clear()
function isBalanced(input) {
let stack = []
const length = input.length
for (let i = 0; i < length; i++) {
if (input[i] === '(') {
stack.push('(')
} else {
@halfzebra
halfzebra / .gitconfig
Last active January 5, 2019 11:52
Simple Git Config
[user]
name = Your Name
email = your@email.com
[core]
autocrlf = true
safecrlf = false
ignorecase = false
excludesfile = ~/.gitignore
[branch]
autosetuprebase = never
@halfzebra
halfzebra / index.js
Last active December 28, 2018 12:12
State Machine with Async Transitions
// Async Generator for implementing State Machines with asynchronous transitions.
//
// Try online: https://jsfiddle.net/ecf1bho9/
console.clear()
async function* state() {
let state = 0
let action
while (true) {
function powerOf10LessThan(number) {
return Math.floor(Math.log10(number))
}
function step(number) {
return value + (10 ** powerOf10LessThan(number))
}
function stepMany(number, steps) {
let res = value
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@halfzebra
halfzebra / PROPOSAL.md
Last active March 23, 2018 17:12
How Create React App changed the way I work

This gist is a proposal for lightning talk at Reactive Conf 2017

Like the idea? Give me a 🌟 and see you in Bratislava!

How Create React App changed the way I work

Hello, my name is Eduard!

I'm the maintainer of Create Elm App and contributor to Create React App and Webpack

@halfzebra
halfzebra / handlebars-template-name-comment.js
Created August 30, 2016 11:08
Print HTML comment with template name
Handlebars.templates = new Proxy(Handlebars.templates, {
get: function (target, property) {
var TEMPLATE_KEY = '<!-- TEMPLATE: Teamplates/' + property + '.handlebars -->\n'
var method = target[ property ];
if (typeof target[ property ] === 'function') {
return new Proxy(method, {
apply: function (target, thisArg, argumentsList) {
return TEMPLATE_KEY + target.apply(thisArg, argumentsList) + TEMPLATE_KEY;
@halfzebra
halfzebra / requirejs.logger.js
Created August 29, 2016 10:17
Intercept requirejs calls and output info to console
// Alternative https://gist.github.com/nantunes/c4eb68c32843ccd43c7b
window.require = new Proxy(window.require, {
apply: function (target, thisArg, argumentsList) {
console.log('require call to \n ' + argumentsList[ 0 ].join('\n ') + '\n\n');
return target.apply(thisArg, argumentsList);
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
#input {
border: 0;
clip: rect(0 0 0 0);