An api for accessing reddit information. Supports CORS. Doesn't require auth. Great for learning new frontend frameworks.
function nonBlocking(generator) { | |
return (...args) => { | |
var callback = args[args.length - 1]; | |
var iter = generator(...args); | |
function next() { | |
try { | |
var res = iter.next(); | |
} | |
catch (e) { | |
callback(e); |
Let's explore a few ways to do immutable updates in js. We'll start with this data:
var data = {
foo: {
bar: 1,
baz: 2,
}
};
function providesTimer(Component) { | |
return class Timer extends React.Component { | |
constructor(props) { | |
super(props); | |
this.timers = []; | |
this.setTimeout = this.setTimeout.bind(this); | |
} | |
setTimeout(callback, ms) { |
updateIfChanged
is a pattern that allows preventing updates based on a unique key.
It inverts control of updates from a dumb child to the smarter parent. It's particularly useful because
it can avoid the normal issue of children and callbacks causing a rerender when it's not truly required.
The alternative workaround is usually memoizing the children and callbacks which can be expensive, complicated, and leak memory.
import deepEqual from 'lodash/isEqual';
// src/models/types/kittyType.js | |
var mongoose = require('mongoose'); | |
var kittySchema = exports.schema = mongoose.Schema({ | |
name: String | |
}); | |
var Kitten = exports.model = mongoose.model('Kitten', kittySchema); |
import ObCache from 'obcache'; | |
var cache = new ObCache(); | |
cache.register('userInfo', ([id]) => functionThatReturnsAPromise(id)); | |
export default cache; |
Please follow these steps to set up your nick and configure your client. Check off each step to make sure it's been done:
Select a permanent, master nickname. If the nickname you want is registered but has expired, just ask a staffer and in most cases, we will be happy to drop it for you.
Please avoid using the name of a community project or trademarked entity, to avoid conflicts. Write down your password and be sure to keep the sheet of paper in a safe place.
Register your IRC nick:
UU supports many basic commands. Here are some. Writing UU scripts requires some knowledge but reading and modifying them should be easy for people familiar with english and one or more programming languages.
uu with "$path" split-on / get -1
echo foo 1 bar 2 baz | uu with-stdin spit-on ' ' match '\w+' print %s
echo '{"key": "value"}' | uu with-stdin json-get 'key' print %s
echo '{"key": "value"}' | uu with-stdin json-set 'key' 'value2' print %j
import Immutable from 'immutable'; | |
import {makeComponent} from 'r2d2'; | |
import TodoList from './TodoList.js'; | |
makeComponent('TodoList') | |
.state('items', Immutable.List([])) | |
.render(({state, utils}) => { | |
return ( | |
<div> | |
<h1>Todo</h1> |