Skip to content

Instantly share code, notes, and snippets.

View choonkending's full-sized avatar

Ken Ding choonkending

  • REA Group
  • Australia
View GitHub Profile
@choonkending
choonkending / Idea-Mapping-.markdown
Created October 17, 2013 15:59
A Pen by Choon Ken Ding.
@choonkending
choonkending / createMapFromPairs.js
Last active December 30, 2015 23:31
Mapping an array to an object
/*
* Given an array of pairs
* such as this
* `['a-b','b-c']`
*
* and we wish to convert to
* `{
* a: b,
* b: c
* }`
@choonkending
choonkending / osx-10.11-setup.md
Last active September 3, 2016 10:20 — forked from kevinelliott/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@choonkending
choonkending / deferredToPromise.js
Created January 18, 2016 01:17
New way to wrap jQuery deferred object if you have no choice
new Promise((resolve, reject) => {
existingAjaxLibraryWrapper.callAPI()
.done(res => {
resolve(res);
})
.fail(err => {
reject(new Error("Oops!"));
});
})
.then(res => {
const aAndB = ({ a, b }) => {
if (a && b) return 'A & B';
return null;
};
const onlyA = ({ a, b }) => {
if (a && !b) return 'Only A';
return null;
};
const wrapFadeInLetters = text =>
text.split('').map((letter, i) => <span className='simple-button__letters' key={i} style={{transition: `opacity 800ms ${i * 50}ms`}}>{letter}</span>);
import EnhancedComponent = enhance(Component);
render() {
return <EnhancedComponent />;
}
class MyComponent extends React.Component {
render() {
return (
<div>
{this.props.children('Cruisin down the street')}
</div>
);
}
}
<ToggleComponent>
<Title />
</ToggleComponent>
// User clicks on Title
<ToggleComponent>
<Title />
<Content />
import React, { Component } from 'react';
class ConcreteToggle extends Component {
constructor(props) {
super(props);
this.state = { isActive: false };
this.onToggle = this.onToggle.bind(this);
}
render() {