Skip to content

Instantly share code, notes, and snippets.

View thevangelist's full-sized avatar
馃寶
Living on planet earth...

thevangelist

馃寶
Living on planet earth...
  • Taitopilvi
  • 0.98327 - 1.017 AU
View GitHub Profile
@thevangelist
thevangelist / method-method.js
Created January 4, 2017 17:41
Douglas Crockford's method method
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
/*
http://stackoverflow.com/questions/3966936/method-method-in-crockfords-book-javascript-the-good-parts
*/
@thevangelist
thevangelist / index.html
Created January 7, 2017 13:43
Use :target for alternate layouts
<!DOCTYPE html>
<html lang="en" id="dark">
<head>
<meta charset="utf-8">
<title>:target for alternate layouts</title>
<style>
#dark:target body {
background: black;
color: white;
}
@thevangelist
thevangelist / redux-in-nutshell.js
Last active March 15, 2017 12:35
Redux stores initialization, dispatchers and reducer in a nutshell
const userReducer = (state={}, action) => {
switch(action.type) {
case 'CHANGE_NAME': {
// Immutable way
state = {...state, name: action.payload}
break;
}
case "CHANGE_AGE": {
state = {...state, age: action.payload}
break;
@thevangelist
thevangelist / tree.sh
Last active March 15, 2017 16:09
tree 3 levels without node_modules
tree -I 'node_modules' -L 3
/*
No need to use the ES5 version
(function () {
var tmp = 路路路;
路路路
}());
*/
@thevangelist
thevangelist / redux-tree-connector.js
Last active July 13, 2017 19:47
Redux Tree Query HOC with Fallback Values
import { connect } from 'react-redux';
import _ from 'lodash';
function reduxConnected(reduxTreeQuery, fallbackValue, propName) {
return connect(state => ({
[propName]: _.get(state, reduxTreeQuery, fallbackValue)
}));
}
export default reduxConnected;
@thevangelist
thevangelist / styled-components.jsx
Last active December 2, 2017 12:22
Styled Components (styled-components)
import React, { Component } from 'react';
import styled, { ThemeProvider } from 'styled-components';
import { modularScale } from 'polished';
const BASE = '#DBECF3';
const BRAND = '#062E40';
const BRAND_ALT = '#34A5B6';
const ATTENTION = '#F94253';
const UNIT = 1;
@thevangelist
thevangelist / ttl-debug.md
Last active November 2, 2017 13:11
DNS record TTL test

dig thevangelist.github.io |awk '$2 ~ "[0-9]+"' |col

// More details: watch -d dig thevangelist.github.io

@thevangelist
thevangelist / git-diff-exclude-stats.md
Last active April 24, 2025 13:25
Git diff --stat with exclude files

// Just the exclude diff lines changed

git log --author="$(git config user.email)" --pretty=tformat: --numstat -- ':!package-lock.json' |
awk '
  NF == 3 {
    inserted += $1;
    deleted += $2;
  }
 END {