Skip to content

Instantly share code, notes, and snippets.

View James-E-Adams's full-sized avatar
Powered by cold brew and stress.

James Adams James-E-Adams

Powered by cold brew and stress.
View GitHub Profile
@James-E-Adams
James-E-Adams / a.diff
Created November 28, 2018 08:03
css diff
124,126c120,121
< -webkit-box-sizing: content-box;
< box-sizing: content-box;
< background-color: transparent;
---
> box-sizing: initial;
> background-color: initial;
@James-E-Adams
James-E-Adams / withStateOfTypeSet.js
Created October 22, 2018 20:49
Functional React Article Snippet #4
import withState from 'recompose/withState'
import compose from 'recompose/compose'
import withHandlers from 'recompose/withHandlers'
import stringCapitalize from 'somewhere'
const addToSetFactory = (stateName, stateUpdaterName) => props => item =>
props[stateUpdaterName](new Set(props[stateName]).add(item))
const removeFromSetFactory = (stateName, stateUpdaterName) => props => item =>
@James-E-Adams
James-E-Adams / Farm.js
Last active October 23, 2018 05:13
Functional React Article Snippet #3
// Or better:
// same imports as before plus...
import compose from 'recompose/compose'
const Farm = compose(
withState("tools", "setTools", ["hammer", "scythe", "sickle"]),
lifecycle({ didMount }),
branch(shouldNotRender, renderNothing),
@James-E-Adams
James-E-Adams / Farm.js
Last active October 22, 2018 20:21
Functional React Article Snippet #2
import branch from 'recompose/branch'
import withState from 'recompose/withState'
import renderNothing from 'recompose/renderNothing'
import onlyUpdateForKeys from 'recompose/onlyUpdateForKeys'
import lifecycle from 'out-of-scope-for-this-article-but-serves-same-purpose-as-recompose-lifecycle'
// And now the exact same thing, written functionally.
//---------------------------------------------------------------//
// Only the 'view' logic.
@James-E-Adams
James-E-Adams / Farm.js
Last active October 22, 2018 20:10
Functional React Article Snippet #1
//------------------Written as a class---------------------//
class Farm extends React.Component {
constructor(props) {
super(props)
this.state = {
tools: ["hammer", "scythe", "sickle"]
}
}
componentDidMount() {
@James-E-Adams
James-E-Adams / yolo
Last active February 8, 2018 03:58
Git yolo (safe-ish)
Bash: alias git yolo='git push --force-with-lease'
'use strict'
declare var require: any
import VueComponent from 'vue-class-component'
@VueComponent({
template: require('./Tabs.html')
})
export default class {
var url = "http://free.rome2rio.com/api/1.4/json/Search?";
function runner(long,lati) {
//get the response with given long lat:
var data = {
key: destination.key,
dPos: destination.position,
//regex object which has a regex string for match checking and an array of params that looks like:
//params = [null,param1,param2,..,param(n)[
//method for creating a reg ex object (as described in the use case constructor), from a given resource path.
function create_reg(resource) {
var folders = resource.split('/');
var reg_string = '^';
var reg_obj={};
var params=[null];
for (var i = 0; i < folders.length; i++) {