Skip to content

Instantly share code, notes, and snippets.

View simov's full-sized avatar

simo simov

View GitHub Profile
@simov
simov / html-toc.js
Created January 22, 2017 10:57
Generate Table of Contents (TOC) from rendered HTML document's header tags
// extract all headers
var headers = []
function walk (nodes) {
nodes.forEach((node) => {
var sub = Array.from(node.childNodes)
if (sub.length) {
walk(sub)
@simov
simov / basic.js
Last active June 20, 2016 10:33
Conditional (ternary) Operator
var func = function (arg) {
if (arg.yes) {
return 'yes'
}
else if (arg.no) {
return 'no'
}
else if (arg.probably) {
return 'probably'
}
@simov
simov / context-retain.js
Created June 17, 2016 15:57
Mithril.js persist dom elements on route change
// The `ul` element *is blinking*
var Navigation = {
controller: function () {
return {
config: (element, initialized, context) => {
context.retain = true
console.log(initialized)
}
}
},
@simov
simov / memes.css
Created March 11, 2016 15:09
Meme that GitHub reaction!
.comment-reactions-options g-emoji { color: transparent; }
.comment-reactions .reaction-summary-item { background-repeat: no-repeat !important; background-position: 0 10px !important; }
.comment-reactions-options button[value^="+1"] { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AMLDi8gad15XAAAAl1JREFUOMuVkb9LG2Ecxp97c8ndm7TcJRDS4OApUjThFuNa+gc0dCokQ0FCqa7+AYXOknAEB6eS4GIgQ5ZgQKji5KKSoINojNhBAqf2yMVAcrn4dmkOU2/pM70P7/t5vj9eDn91dnYGVVVRKBTCx8fHb1VV/aIoyodgMEhN02SmaXpt2/6WTqe1k5MTJBIJuCqfz+tXV1fMMAz2r46OjnoXFxcZNwgHBwfS5ubmsN/vW8+hy8tLZprm2Fqapo00TYs58NraGgBgY2Pj1LbtF1VLpRKrVCpOSL/fZ9lstj3m+UwmE1FVtRiPx1WPxzPRGWMMvV4P6XQa+/v7iEQiiMfjEEXxDWOMcBz3hFwu977RaDA3DYdDtr6+7vjHx0fGGGM3NzejYrH4EwCIJEk/Zmdn0Ww2sbOzM9EBz/NYWVlxfCAQAABMT0+Tdrv9rlwuxwghJEopxf39PRRFwdbWFra3tx1IluWJkcZKJpO+0Wj0ie92u35CCERRhCzLWF5exmAwcP3iVqsFSimmpqYwMzODw8PDz0QQBAYA8/PzCAaDAABBEFwD5ubmsLe354yn6/oT4TiOEEJAKYXf73cFu92uc354eAAAeL1eLCwsvOYp

Request Next

![request-next]

Zero abstraction that leads to minimalistic code base. Which is fine, but refactoring is needed on each stage of the software development, otherwise it turns into a giant mess of entangled [quick fixes, instead of having real features][quickfixes-vs-features].

Adding features requires more time, but even more importantly, it requires someone (or a group of people) to watch for and enforce the design goals. Without such people and a clear design on each stage of the development, that software project inevitably slows its growth and ultimately dies. Well, in the case of request it's still going to be used for a long time ahead, but no one wants to support it anymore.

Another negative impact of not having leadership is that the project's code base grows unproportionally in size and complexity, without its design evolving into a smaller and simpler components. The result is a huge chunk of code that no one have the time, energy and dedication to rewrite.

@simov
simov / authorize.html
Created December 6, 2015 09:38
Server Side Explicit OAuth Flow automation with NodeJS, NWjs and Grant
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Client Side Implicit OAuth Flow</title>
<script type="text/javascript" charset="utf-8">
var config = {
username: '[USERNAME]',
password: '[PASSWORD]'
}
@simov
simov / authorize.html
Created December 5, 2015 15:40
Client Side Implicit OAuth Flow automation with NodeJS and NWjs
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Client Side Implicit OAuth Flow</title>
<script type="text/javascript" charset="utf-8">
var config = {
client_id: '[CLIENT_ID]',
redirect_uri: '[REDIRECT_URL]',
username: '[USERNAME]',
@simov
simov / gulpfile.js
Created October 16, 2015 16:52
Gulpfile + Babel + Sourcemaps
var path = require('path')
var gulp = require('gulp')
var sourcemaps = require('gulp-sourcemaps')
var babel = require('gulp-babel')
var paths = {
es6: ['**/*.js', '!gulpfile.js', '!build/**/*.*'],
es5: 'build',
// must be absolute or relative to source map
@simov
simov / parser.js
Created May 30, 2015 14:46
tape + tap-reporter = wrong events order
var parser = require('tap-parser') // 1.1.4
var p = parser()
process.stdin.pipe(p)
p.on('extra', function (line) {
console.log('extra', line)
})
@simov
simov / readdirr.js
Last active August 29, 2015 14:21
Recursive asynchronous streaming of directory
import fs from 'fs'
import path from 'path'
import stream from 'stream'
import bluebird from 'bluebird'
bluebird.promisifyAll(fs)
class Readdirr extends stream.Readable {
constructor(root) {