Skip to content

Instantly share code, notes, and snippets.

View lanqy's full-sized avatar
🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
  • Shenzhen,China
View GitHub Profile
@lanqy
lanqy / index.js
Created August 27, 2016 04:09 — forked from gaearon/index.js
Breaking out of Redux paradigm to isolate apps
import React, { Component } from 'react'
import Subapp from './subapp/Root'
class BigApp extends Component {
render() {
return (
<div>
<Subapp />
<Subapp />
<Subapp />
@lanqy
lanqy / connect.js
Created August 27, 2016 04:02 — forked from gaearon/connect.js
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@lanqy
lanqy / reducers.js
Created August 27, 2016 03:57 — forked from gaearon/reducers.js
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
@lanqy
lanqy / Child.js
Created August 24, 2016 03:14 — forked from eyesofkids/Child.js
Simple React Lifecycle methods test
import React from 'react'
var Child = React.createClass({
getInitialState: function(){
console.log('Child getInitialState');
return { value: 'start'}
},
getDefaultProps: function(){
console.log('Child getDefaultProps');
@lanqy
lanqy / redux-form-tut.js
Created August 22, 2016 02:04 — forked from dmeents/redux-form-tut.js
The source code for the redux form tutorial on davidmeents.com
import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import * as actions from '../../actions';
const form = reduxForm({
form: 'ReduxFormTutorial',
validate
});
@lanqy
lanqy / .babelrc
Created July 24, 2016 04:16 — forked from thaerlabs/.babelrc
React hello world is not hard
{
"presets": ["es2015", "react"]
}
@lanqy
lanqy / gist:a6a9b1c411320de046a4
Last active September 4, 2015 03:00 — forked from shannoga/gist:1008678
Get fonts family and font names list on iOS
// List all fonts on iPhone
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
//
// ViewController.swift
// TestSwift
//
// Created by Jameson Quave on 6/2/14.
// Copyright (c) 2014 JQ Software LLC. All rights reserved.
//
import UIKit
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
@lanqy
lanqy / gist:8523817
Last active January 3, 2016 21:48
通过索引选中table cell
//select first row of first section
// from http://stackoverflow.com/questions/5918309/how-to-programmatically-tap-a-uitableview-cell
// from http://stackoverflow.com/questions/6118071/how-to-set-row-selected-by-default-in-uitableview
NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:selectedCellIndexPath animated:false scrollPosition:UITableViewScrollPositionMiddle];