Skip to content

Instantly share code, notes, and snippets.

import React from 'react';
// import {} from 'lodash';
// import { PropTypes } from 'helpers/react';
// const {} = PropTypes;
export default class $NAME$ extends React.Component {
static propTypes = {};
static defaultProps = {};
import { createReducer } from 'helpers/redux';
// import { } from 'lodash';
export const namespace = '$NS$';
const ACTION = 'nc/$NS$/ACTION';
const defaultState = {
};
import React from 'react';
// import { } from 'lodash';
// import { PropTypes } from 'helpers/react';
// const { } = PropTypes;
const $NAME$ = ({
fields
} = {}) => (WrappedComponent) => {
class Wrapped$NAME$ extends React.Component {

Keybase proof

I hereby claim:

  • I am olslash on github.
  • I am olslash (https://keybase.io/olslash) on keybase.
  • I have a public key whose fingerprint is 88CA 494E 18E4 88BF E1FD EC81 6E73 C114 5978 E765

To claim this, I am signing this object:

@olslash
olslash / gist:3b5fb7d3edf43ec0b9b2
Last active August 29, 2015 14:05
T9 blogpost - 7
function getDeeperSuggestions(root, maxDepth) {
// We traverse down every possible branch from the result node (the node
// corresponding to the keypad entry), saving words we see as we go and
// stopping when we reach the specified depth.sug
// deepSuggestions is an array with (maxDepth) subarrays.
// Each of the subarrays will be one depth level's suggestions.
var deepSuggestions = [];
while(deepSuggestions.length < maxDepth) {
deepSuggestions.push([]);
@olslash
olslash / gist:2f372184e78d0ddb48fe
Last active August 29, 2015 14:05
T9 blogpost - 6
Trie.prototype.getSuggestions = function(keyString, suggestionDepth) {
// Traverse the tree based on the key digits in keyString, to find the
// node where relevant words are stored.
var result = [];
var node = this;
for(var i = 0; i < keyString.length; i++) {
var thisKey = keyString[i];
if(!node.children.hasOwnProperty(thisKey)) { break; }
node = node.children[thisKey];
@olslash
olslash / gist:1c1b057264874378d225
Last active August 29, 2015 14:05
T9 blogpost - 5
function insertWordIntoListByFrequency(list, word, useFrequency) {
var wordToInsert = [word, useFrequency]; // Store word in a tuple.
var wordsLength = list.length;
if(wordsLength === 0) {
// Handle the case where this node has no words yet
list.push(wordToInsert);
} else {
// Find where to insert this word among others, based on its
// frequency property.
@olslash
olslash / gist:edcc6902c80ecb09008d
Last active August 29, 2015 14:05
T9 blogpost - 4
function traverseAddingNodes(node) {
var i = 0, len = word.length;
// Traverse the tree's existing nodes as far as possible.
for(i, len; i < len; i++) {
var thisLetter = word[i];
var thisKey = keys[thisLetter];
if(node.children.hasOwnProperty(thisKey)) {
node = node.children[thisKey];
} else { break; }
@olslash
olslash / gist:6cc6859e53d19a45e174
Last active August 29, 2015 14:05
T9 blogpost - 3
Trie.prototype.insert = function(word, useFrequency) {
// Traverse the tree to the node where the word should be inserted. If any
// needed nodes do not exist along the way, they are created.
var nodeToAddWord = traverseAddingNodes(this);
// Insert the word into the wordlist of the node returned above. Use the
// data provided (frequency of use in English text) to place the word in
// the correct position, so that we can recommend more common words first.
insertWordIntoListByFrequency(nodeToAddWord.words, word, useFrequency);
@olslash
olslash / gist:96b7fa4440072c925100
Last active August 29, 2015 14:05
T9 blogpost - 2
var Trie = function() {
this.children = {}; // Like {'2': <ref to Trie instance>, '3': ...}
this.words = []; // Like [['award', 10764], ['aware', 6625]]
};