Skip to content

Instantly share code, notes, and snippets.


Chris Fritz chrisvfritz

  • Durham, NC, USA
View GitHub Profile
chrisvfritz / improved-createElement-interface.js
Last active August 29, 2015 14:23
An improved interface to React.DOM elements and React.createElement
View improved-createElement-interface.js
window.$ = function(element, propsOrChildren, childrenIfProps){
var props, children;
if ((propsOrChildren != null && propsOrChildren instanceof Array) || !(propsOrChildren instanceof Object)) {
props = null;
children = propsOrChildren;
} else {
props = propsOrChildren;
children = childrenIfProps;
return React.createElement(element, props, children);
$ Jumbotron, style: styles.welcome.base, [
$h2 'this is a catchy tagline'
$p 'here is a short mission statement, expanding on the tagline'
$a href: '/demo', [
$ Button,
bsStyle: 'primary'
bsSize: 'large'
'Try the demo'
window.$ = (element, propsOrChildren, childrenIfProps) ->
if (propsOrChildren? and propsOrChildren instanceof Array) or not (propsOrChildren instanceof Object)
props = null
children = propsOrChildren
props = propsOrChildren
children = childrenIfProps
React.createElement element, props, children
Object.keys(React.DOM).forEach (elementName) ->
chrisvfritz /
Created October 13, 2015 15:12

Keybase proof

I hereby claim:

  • I am chrisvfritz on github.
  • I am chrisvfritz ( on keybase.
  • I have a public key whose fingerprint is 6FC1 8F2B 9215 8472 0B80 D5FF AFB9 EFE0 F2BF 46CA

To claim this, I am signing this object:

chrisvfritz / simple_trending_example.rb
Last active December 22, 2015 06:39
This is an example implementation of a really simple algorithm in Ruby to identify trending words and phrases in a collection of posts. This was written in a single sitting, late at night, without research, so it's definitely not the most efficient way to tackle this problem. I haven't even tested it with real data to make sure that it works as …
View simple_trending_example.rb
chrisvfritz / docverter_error_20130918.html
Created September 18, 2013 23:36
Docverter error while trying to convert from Markdown to MOBI
View docverter_error_20130918.html
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>RuntimeError at &#x2F;convert</title>
<script type="text/javascript">
function toggle(id) {
var pre = document.getElementById("pre-" + id);
# Since React has made jQuery obsolete for me, I use $ to replace JSX.
window.$ = React.create-element
for key, value of React.DOM
window."$#key" = value
# And here's an example of a render function using this syntax.
render: ->
$ Jumbotron, style: styles.welcome.base, [
$h2 key: \tagline, 'this is a catchy tagline'
$p key: \mission, 'here is a short mission statement, expanding on the tagline'
View get-players.js
function getPlayers () {
var players = [
{ name: 'Alice', score: 99 },
{ name: 'Billy', score: 83 },
{ name: 'Cindy', score: 91 },
{ name: 'David', score: 96 },
{ name: 'Emily', score: 88 }
function randomIndex () {