Skip to content

Instantly share code, notes, and snippets.

View dmitriz's full-sized avatar

Dmitri Zaitsev dmitriz

View GitHub Profile
@shellkore
shellkore / squah.md
Created January 18, 2019 17:54
squash your commits

SQUASH

Whenever you want to squash last commits in a single commit:-

first check your log

git log

CASE 1: your head is at the commit in which you want others to be squashed

@dmitriz
dmitriz / style_guide.md
Created April 19, 2018 16:39 — forked from dominictarr/style_guide.md
style guide

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@dmitriz
dmitriz / db-alt.js
Created May 13, 2017 06:47 — forked from i-am-tom/db-alt.js
Database failover modelled with the `alt` typeclass.
const Task = require('data.task')
Task.prototype.alt = function (that) {
return new Task((rej, res) =>
this.fork(_ => that.fork(rej, res), res))
}
const hosts = [
[ 'db1.mysite.com', 'user', 'password' ],
[ 'db2.mysite.com', 'user', 'password' ],
@i-am-tom
i-am-tom / db-alt.js
Last active February 20, 2020 03:01
Database failover modelled with the `alt` typeclass.
const Task = require('data.task')
Task.prototype.alt = function (that) {
return new Task((rej, res) =>
this.fork(_ => that.fork(rej, res), res))
}
const hosts = [
[ 'db1.mysite.com', 'user', 'password' ],
[ 'db2.mysite.com', 'user', 'password' ],
// my initial code from https://github.com/bevry/outpatient/blob/455fd3a32791259931e0fa4e3b9b3b7d1dc26d8b/source/block.js#L55-L75
'use strict'
const h = require('hyperscript')
module.exports = function (opts = {}) {
// Prepare
const { document, content } = this
const {
permalink = document.url,
@jaymcgavren
jaymcgavren / home_dir_homebrew.sh
Last active July 27, 2022 23:56
Install Homebrew to your home directory. Great for running Homebrew as a guest user on a Mac.
git clone https://github.com/Homebrew/brew.git
export PATH=${HOME}/brew/bin:${PATH}

These examples are presented in an attempt to show how each coding styles attempts to or does not attempt to isolate side-effects. There are only 2 semantic elements in a barebone "Hello World" implementation:

  • Invocation of console.log
  • Declaration of HELLO_WORLD

Since every coding style can abstract away data into a parameter or variable, there is no point for us to show that. All implementations assume HELLO_WORLD is a constant that is always inlined. This way it reduces the variations we need to present. (To make an anology, if we were to implement incrementByOne, would we need to inline the number 1 or pass it in as parameter?)

CAVEAT/LIMITATION: All implementations also assume console is static global. In case of functional programming, console.log is asumed to be a function that can be passed around without further modification. (This is not the case in the browser, but that can be resolved with console.log.bind(console))

Declarative

@DrBoolean
DrBoolean / coyo_uses.js
Created February 26, 2016 15:40
Coyoneda Uses in JS
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
//===============Define Coyoneda=========
const Coyoneda = daggy.tagged('x', 'f')
Coyoneda.prototype.map = function(f) {
return Coyoneda(this.x, compose(f, this.f))
}
@dmitriz
dmitriz / .jshintrc.js
Created January 25, 2016 21:35 — forked from connor/.jshintrc.js
jshintrc example
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.