Skip to content

Instantly share code, notes, and snippets.

@mijia
mijia / mdl-react.js
Last active September 15, 2016 08:36
Hook up the mdl componentHandler with React Router
let MDLUpgrade = function(Component) {
const MDLComponent = React.createClass({
componentDidUpdate() {
componentHandler.upgradeDom();
},
render() {
return <Component {...this.props} />;
},
@mijia
mijia / Refreshable.js
Created April 17, 2015 04:37
Pull-to-refreshable list view and scroll view using a mixin
"use strict";
var React = require("react-native");
var {ListView, ScrollView, ActivityIndicatorIOS, View, Text} = React;
var TimerMixin = require("react-timer-mixin");
var kPulldownDistance = 60;
// Working with the TimerMixin, e.g.
// mixins: [TimerMinx, RefreshableMixin]
@mijia
mijia / modal.coffee
Created September 2, 2014 11:55
Wrap Bootstrap Modal dialog into React component
define ["jquery", "react"], ($, React) ->
{div, button, a, p, span} = React.DOM
ModalHeader = React.createClass
render: ->
(div {className: "modal-header"}, [
(button { type: "button", className: "close", "data-dismiss": "modal"}, [
(span { "aria-hidden": "true"}, "×")
(span { className: "sr-only"}, "关闭")
@mijia
mijia / SparkLocalLDA.scala
Created December 6, 2012 13:30
Running lda on Spark platform but in local mode
// Referring to the great open source lib of ompi-lda
// http://code.google.com/p/ompi-lda/
// I only experimented running this is the local mode and don't
// know if this will be working in other deployment mode.
import spark.broadcast._
import spark.SparkContext
import spark.SparkContext._
import spark.RDD
import spark.storage.StorageLevel