Skip to content

Instantly share code, notes, and snippets.

import React, { Component, PropTypes } from 'react';
import { Footer, Header } from 'components/index';
import styles from './FAQPage.scss';
function highlightWord(root, word) {
/* eslint-disable no-shadow, no-cond-assign */
function textNodesUnder(root) {
const walk = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false);
@itrelease
itrelease / pn.js
Created February 20, 2016 14:51
pn.js
/* eslint-disable no-console */
import React, { PropTypes, Component } from 'react';
import getClassName from '../../utils/getClassName';
const bem = getClassName('TriggerPushNotification');
export default class TriggerPushNotification extends Component {
static get propTypes() {
return {
@import '~constants';
.stamp-Video {
position: relative;
background-color: @blackColor;
cursor: pointer;
}
.stamp-Video-box {
color: @lightColor;
@itrelease
itrelease / delayed.js
Last active August 29, 2015 14:25
Delayed redux action
export default function delay({ dispatch, getState }) {
const delayed = {};
return (next) => {
return (action) => {
const actionIndex = (delayed[action.type] || []).indexOf(action.delay);
if (delayed[action.type] && actionIndex > -1) {
const delayedActionCreator = delayed[action.type][actionIndex];
@itrelease
itrelease / bloop.js
Last active August 29, 2015 14:25 — forked from jlongster/bloop.js
(function() {
// Do not use this library. This is just a fun example to prove a
// point.
var Bloop = window.Bloop = {};
var mountId = 0;
function newMountId() {
return mountId++;
}
/* @flow */
type State = Object
type Action = {type: string | void}
type AsyncAction = (performAction: FluxPerformFunction, state: State) => void
type ActionCreator = () => Action | AsyncAction
type StoreFunction = (state: State, action: Action) => State
@itrelease
itrelease / transd.js
Created July 5, 2015 14:03
Transducers difference?
/* NINJA FP */
function mapping(transform) {
return function (reduce) {
return function (result, input) {
return reduce(result, transform(input));
};
};
}
/**
* Stores are just seed + reduce function.
* Notice they are plain objects and don't own the state.
*/
const countUpStore = {
seed: {
counter: 0
},
reduce(state, action) {
@itrelease
itrelease / pu.js
Last active August 29, 2015 14:20
pack-unpack
function serialize(root) {
if (root == null)
return "- ";
else {
return root.value + " " + serialize(root.node.left) + serialize(root.node.right);
}
}
function deserialize(string) {
var tokens = string.trim().split(' ');
function sort(arr) {
var tmp = [];
var sorted = [];
var i, l;
var ii, ll;
for (i=0, l=arr.length; i<l; i++) {
var value = arr[i];
if (!tmp[value]) {