Skip to content

Instantly share code, notes, and snippets.

@vonwao
vonwao / gist:2305906
Created April 4, 2012 21:40
kotlin extension function
fun List<Int>.swap(x : Int, y : Int) {
val tmp = this[x] // 'this' corresponds to the list
this[x] = this[y]
this[y] = tmp
}
/** @jsx React.DOM */
var BootstrapModalMixin = function() {
var handlerProps =
['handleShow', 'handleShown', 'handleHide', 'handleHidden']
var bsModalEvents = {
handleShow: 'show.bs.modal'
, handleShown: 'shown.bs.modal'
, handleHide: 'hide.bs.modal'
/** @jsx React.DOM */
'use strict';
// Components wrapping Twitter Bootstrap stuff
//
var BSNames = {
// This isn't exhaustive. Need to think through what should go here. Should
// be exclusive.
bsClass: {'column': 'col', 'button': 'btn', 'btn-group': 'btn-group', 'label': 'label',
@vonwao
vonwao / routes.jsx
Created January 29, 2016 21:48
mantra sample
import React from 'react';
import {FlowRouter} from 'meteor/kadira:flow-router';
import {mount} from 'react-mounter';
import MainLayout from '/client/modules/core/components/layout.main.jsx';
import PostList from '/client/modules/core/containers/postlist';
import Post from '/client/modules/core/containers/post';
import NewPost from '/client/modules/core/containers/newpost';
export default function (injectDeps) {
import React from 'react';
const PostList = ({posts}) => (
<div>
<ul>
{posts.map(post => (
<li key={post._id}>
<a href={`/post/${post._id}`}>{post.title}</a>
</li>
))}

Styled component use case

Styled component as standard react component

avoid creating middleware react component

before

const StyledIcon = styled(Icon)``;
export const HomeIcon = () => <StyledIcon uri="icn-home.svg" />;
import React from 'react';
import PropTypes from 'prop-types';
import debounce from 'lodash/debounce';
class OnChangeDebounce extends React.Component{
constructor(props){
super(props);
this.isValueSourceProps = this.props.hasOwnProperty(this.props.valueProperty);
this._createDebounceFunction(props);
import React from 'react';
import * as N from 'react-native';
import styled from 'styled-components';
import {
compose,
space,
color,
layout,
typography,
flexbox,