Skip to content

Instantly share code, notes, and snippets.

@tkh44
tkh44 / index.js
Last active September 17, 2017 02:28 — forked from VictorCoding/index.js
working with search/filtering items
import React from 'react'
import { Div } from 'glamorous'
const filterPosts = (posts, term) => posts.filter(item => item.includes(term))
function List({ items }) {
return <ul>{items.map((p, i) => <li key={i}>{p}</li>)}</ul>
}
class Index extends React.Component {
class MatchWhenAuthorized extends Component {
constructor(props) {
super(props);
this.state = {
authInProgress: true,
isAuthenticated: false,
}
}
componentWillMount = () {
@tkh44
tkh44 / ClientApp.jsx
Created March 6, 2016 23:26 — forked from btholt/ClientApp.jsx
react-router server-side rendering
const React = require('react')
const Landing = require('./Landing')
const Search = require('./Search')
const Layout = require('./Layout')
const Details = require('./Details')
const ReactRouter = require('react-router')
const data = require('../public/data')
const { Router, Route, hashHistory, IndexRoute } = ReactRouter
const Store = require('./Store')
const { store } = Store
// graph nodes
var a = {label:"a"}, b = {label:"b"}, c = {label:"c"},
d = {label:"d"}, e = {label:"e"}, f = {label:"f"},
g = {label:"g"}, h = {label:"h"}, i = {label:"i"};
// setup dependency hierarchy (directed graph node edges)
a.children = [b,c,d,e];
c.children = [e,f];
d.children = [e,c];
h.children = [a,i,g];
const combine = (...arrays)
=> [].concat(...arrays);
const compact = arr
=> arr.filter(el => el);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
)();
#!/usr/bin/env node
// This plugin replaces text in a file with the app version from config.xml.
var wwwFileToReplace = "js/build.js";
var fs = require('fs');
var path = require('path');
var rootdir = process.argv[2];
@tkh44
tkh44 / .gitignore
Last active August 29, 2015 14:02 — forked from rjmunro/.gitignore
.gitignore for cordova >3.4
#platform agnostic
platforms/*/assets/www
# Android
platforms/android/assets/www
platforms/android/bin/
platforms/android/gen/
platforms/android/res/xml/config.xml
platforms/android/ant-build
platforms/android/ant-gen
function randomString(length) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
if (! length) {
length = Math.floor(Math.random() * chars.length);
}
var str = '';
for (var i = 0; i < length; i++) {
str += chars[Math.floor(Math.random() * chars.length)];