Skip to content

Instantly share code, notes, and snippets.

View khanghoang's full-sized avatar
😬

Khang Hoang khanghoang

😬
  • Dropbox
  • San Jose, CA
  • 04:56 (UTC -06:00)
  • X @khanght
View GitHub Profile
@khanghoang
khanghoang / .xvimrc
Last active January 29, 2016 13:46
xCode custom binding key
:imap jk <Esc>
map <D-k> 5k
map <D-j> 5j
let waitsInProgress = [];
let message = `Timeout, it seems we don have the response from the async function`;
let waitFor = (testFunc, done, timeLeft = 2000) => {
waitsInProgress.push(setTimeout(() => {
if (timeLeft <= 0) {
done(new Error(message));
} else if (testFunc()) {
done();
} else {
waitFor(testFunc, done, timeLeft - 10);
class ListCommentsContainer extends Component {
constructor(props) {
super(props);
this.state = {
comments: [],
isLoading: true
}
}
describe('<ListCommentsContainer />', () => {
it('render enought list items', (done) => {
let listCommentsContainer = mount(<ListCommentsContainer />);
waitFor(() => {
return listCommentsContainer.find('li').length === 5;
}, done);
});
});
import React, {Component} from 'react';
import CommentItemComponent from './CommentItemComponent.js'
class ListCommentsComponent extends Component {
render() {
let comments = this.props.comments.map(c => <CommentItemComponent comment={c} />)
return (
<ul>
{comments}
</ul>
import React, {Component} from 'react';
class CommentItemComponent extends Component {
render() {
return (
<li>{this.props.comment}</li>
);
}
}
@khanghoang
khanghoang / changes.md
Last active January 13, 2016 10:26
changes

####Breaking changes:

  • Change how we import files (from global variables using <script />in index.html to webpack modules import).
  • Now the ENV variables by passing them from gulp to webpack (check the webpack.config.js).
  • Change the command to run in native from gulp build-SG-en --config native to gulp build-SG-en --type native.

Why? To use the webpack ENV variable

####Improve:

  • Console log will show you where the data comes from (Mock Data vs Mock Server). Log
@khanghoang
khanghoang / squirrel.js
Created December 30, 2015 03:40
squirrel's business
function isInt(n){
return Number(n) === n && n % 1 === 0;
}
function test(x) {
// x is the number that the last squirrel takes
return x * 5 + 1;
}
function thePreviousNuts(x) {
// The car interface
inteface Vehicle
- (void)run
// class Car conforms `Vehicle` interface
class Car conforms Vehicle {
// override run method
- (void)run() {
console.log("Car is running");
}
@khanghoang
khanghoang / Mock.md
Last active January 11, 2016 08:55
Mock

Mock

Why you don't use ZhenLing mock server?

  • We still use it, but not all the dev time.
  • Every time we want to code, test we need to open simulator, so it will be hard for us if we want to use any automation tests later on.
  • if (env === "DEV") {} is everywhere, we need to do it just in one place.

New way to mock

Mock

Extra benefits