In this tutorial we're going to build a set of parser combinators.
We'll answer the above question in 2 steps.
- What is a parser?
- and, what is a parser combinator?
So first question: What is parser?
import Reconciler from 'react-reconciler' | |
import omit from 'lodash/omit' | |
import capitalize from 'lodash/capitalize' | |
import { actions as elementActions } from './store/elements' | |
import * as Elements from './elements' | |
const roots = new Map() | |
const emptyObject = {} | |
const Renderer = Reconciler({ |
How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?
These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.
By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.
#!/usr/bin/env bash | |
find node_modules -name 'build.gradle' -print -exec sed -i.bak -E 's/compileSdkVersion[[:space:]]+23/compileSdkVersion 25/g' {} \; | |
find node_modules -name 'build.gradle' -print -exec sed -i.bak -E 's/buildToolsVersion[[:space:]]+"23.0.1"/buildToolsVersion "25.0.1"/g' {} \; |
#include <GLFW/glfw3.h> | |
#include <yoga/Yoga.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
GLFWwindow* window; | |
/* Initialize the library */ | |
if (!glfwInit()) |
// Here is a function that I use all the time when creating public | |
// async APIs in JavaScript: | |
const resolvePromise = (promise, callback) => { | |
if (callback) | |
promise.then(value => callback(null, value), callback) | |
return promise | |
} | |
// Sometimes I like to use callbacks, but other times a promise is |
/** | |
* Returns true if the device is locked or screen turned off (in case password not set) | |
*/ | |
public static boolean isDeviceLocked(Context context) { | |
boolean isLocked = false; | |
// First we check the locked state | |
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); | |
boolean inKeyguardRestrictedInputMode = keyguardManager.inKeyguardRestrictedInputMode(); |
import { find, findIndex, pullAt } from 'lodash' | |
import { actionTypes as appActionTypes } from 'reducers/appReducer' | |
export const actionTypes = { | |
CREATE_MENU_ENTRY_REQUEST: 'MENU/CREATE_MENU_ENTRY_REQUEST', | |
CREATE_MENU_ENTRY_SUCCESS: 'MENU/CREATE_MENU_ENTRY_SUCCESS', | |
CREATE_MENU_ENTRY_FAILURE: 'MENU/CREATE_MENU_ENTRY_FAILURE', | |
UPDATE_MENU_ENTRY_REQUEST: 'MENU/UPDATE_MENU_ENTRY_REQUEST', | |
UPDATE_MENU_ENTRY_SUCCESS: 'MENU/UPDATE_MENU_ENTRY_SUCCESS', | |
UPDATE_MENU_ENTRY_FAILURE: 'MENU/UPDATE_MENU_ENTRY_FAILURE', |
// ACTIONCREATORS USAGE EXAMPLE 1 | |
// When the action needed are all in a single duck (in this case authReducer) | |
import React, { Component, PropTypes } from 'react' | |
import { connect } from 'react-redux' | |
import { bindActionCreators } from 'redux' | |
import { actionCreators } from '../reducers/authReducer' | |
const mapStateToProps = (state, ownProps) => ({ | |
// blablabla | |
}) |
const io = new WebSocket('ws://yourdomain:port/socket.io/?transport=websocket') | |
io.onclose = e => console.log('onclose', e.code, e.reason) | |
io.onerror = e => console.log('onerror', e.message) | |
io.onopen = () => console.log('connected !') |