Skip to content

Instantly share code, notes, and snippets.

View dijs's full-sized avatar
🏠
Working from home

Richard van der Dys dijs

🏠
Working from home
View GitHub Profile
@dijs
dijs / one-line-jsx.md
Created October 26, 2015 13:37
What is One Line JSX?

JSX can get messy fast.

I was recently introduced to writing smart and dumb components when using react. As an extension to keeping the presentation code strictly within dumb components, I try to write one line JSX.

Original JSX (NOT ONE LINE JSX):

class SomeListComponent {
  render() {
 let names = this.props.names.map(({first, last}) => {
@dijs
dijs / destructing-lesson.md
Created October 26, 2015 17:58
Don't destruct stateful methods

Here is my simple example:

class Speaker {
  constructor(name) {
   this.name = name 
  }  
  say(msg) {
    console.log(`${this.name}: ${msg}`)
 }
@dijs
dijs / bond.js
Created November 16, 2015 19:58
Spying on James Bond
import 'babel-polyfill'
import Wiki from './dist/wiki'
import Knwl from 'knwl.js'
let knwlInstance = new Knwl('english')
knwlInstance.register('dates', require('./node_modules/knwl.js/default_plugins/places'));
let wiki = new Wiki({
uri: 'http://jamesbond.wikia.com/api.php'
})
@dijs
dijs / thursday-talk_11-11-2015.md
Last active November 19, 2015 20:00
Continuous Improvement: Development with ES(6-7), React and Redux

Continuous Improvement: Development with ES(6-7) / React / Redux

ES(6-7)

  • Adopt on the technology radar from Thoughtworks
  • More functional, easier to follow techniques (async/await)
  • No more waiting for new code features with Babel.io
  • New techniques promote better predictability and reusable code
  • Demo
  • All features https://ponyfoo.com/articles/es6
@dijs
dijs / gist:2ae366f4948177b3fdb6
Created November 30, 2015 03:04
Link Grammar configure output
link-grammar-5.3.1 build configuration settings
prefix: /usr/local
C compiler: gcc -DUSE_SAT_SOLVER=1 -DHAVE_SQLITE=1 -g -O2 -O3 -std=c99 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -D_DEFAULT_SOURCE -arch x86_64
C++ compiler: g++ -DUSE_SAT_SOLVER=1 -DHAVE_SQLITE=1 -g -O2 -O3 -Wall -std=c++03
autopackage relocatable binary: no
Posix threads: no
Editline command-line history: no
UTF8 editline support: no
Java libraries: no
@dijs
dijs / gist:4f93be50064c9f326c3c
Created November 30, 2015 03:07
Link Grammar Make Error
Undefined symbols for architecture x86_64:
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
std::__1::vector<int, std::__1::allocator<int> >::__append(unsigned long) in libsat-solver.a(sat-encoder.o)
void std::__1::vector<PositionConnector*, std::__1::allocator<PositionConnector*> >::__push_back_slow_path<PositionConnector* const>(PositionConnector* const&) in libsat-solver.a(sat-encoder.o)
void std::__1::vector<std::__1::pair<PositionConnector const*, PositionConnector const*>, std::__1::allocator<std::__1::pair<PositionConnector const*, PositionConnector const*> > >::__push_back_slow_path<std::__1::pair<PositionConnector const*, PositionConnector const*> const>(std::__1::pair<PositionConnector const*, PositionConnector const*> const&) in libsat-solver.a(sat-encoder.o)
void std::__1::vector<WordTag, std::__1::allocator<WordTag> >::__push_back_slow_path<WordTag const>(WordTag const&) in libsat-solver.a(sat-encoder.o)
WordTag::WordTag(WordTa
@dijs
dijs / react-containers-and-components.md
Created January 4, 2016 17:22
React Containers and Components

Redux is done a bit differently...

Containers

  • Fetch data
  • Manage data
  • Show fetching errors, loading, and UI
  • Compose these

Components (Dumb)

  • Only use props for data
@dijs
dijs / async-for-each.md
Created October 27, 2015 19:58
Async/await do for each ideas

ES7's async/await is awesome!

But, in order to use it well, you need to think in promises.

First thought:

async function something() => {
  let state = []
 await [1, 2, 3].forEach(async(n) =&gt; {
@dijs
dijs / Conditional Chains.carbide.md
Last active February 21, 2017 17:55
Conditional Chains

Conditional Chains

This Gist was automatically created by Carbide, a free online programming environme

@dijs
dijs / get.js
Created April 16, 2017 08:16
Get implementation
function get(obj, path, def) {
const parts = path.split('.');
const [first,] = parts;
const value = obj[first];
if (parts.length === 1) {
return value || def;
}
return get(value, parts.slice(1).join('.'), def);
}