Monday, February 20, 2017

Mithril

A simple application where we can list users from a server and edit them individually
http://mithril.js.org/simple-application.html

REM: REST API for Prototyping from Heroku

http://rem-rest-api.herokuapp.com/

REM is a REST API for prototyping. It accepts JSON requests, returns JSON responses and persists data between requests like a real API. But your test data is only visible to you. It's CORS enabled and no API key is required.

var xhr = new XMLHttpRequest()
xhr.open("GET", "http://rem-rest-api.herokuapp.com/api/users", true)
xhr.withCredentials = true
xhr.send()
xhr.onload = function() {
  var data = JSON.parse(xhr.responseText)
}

Friday, February 17, 2017

ES6 - Arrow Functions


https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/

Syntax

Basic Syntax

(param1, param2, …, paramN) => { statements }
(param1, param2, …, paramN) => expression
// equivalent to: (param1, param2, …, paramN) => { return expression; }

// Parentheses are optional when there's only one parameter:
(singleParam) => { statements }
singleParam => { statements }

// A function with no parameters requires parentheses:
() => { statements }
() => expression // equivalent to: () => { return expression; }

Advanced Syntax

// Parenthesize the body to return an object literal expression:
params => ({foo: bar})

// Rest parameters and default parameters are supported
(param1, param2, ...rest) => { statements }
(param1 = defaultValue1, param2, …, paramN = defaultValueN) => { statements }

// Destructuring within the parameter list is also supported
var f = ([a, b] = [1, 2], {x: c} = {x: a + b}) => a + b + c;
f();  // 6
Detailed syntax examples can be seen here.

Friday, February 10, 2017

Boiling React down to a few lines in jquery

CORS - Cross Origin Resource Sharing

Ajax and React


http://andrewhfarmer.com/react-ajax-best-practices/
https://daveceddia.com/ajax-requests-in-react/

Excerpt:
One of the first questions new React developers have is, “How do I do AJAX requests in React?”
          Here’s an answer to that question.
First: React itself doesn’t have any allegiance to any particular way of fetching data. In fact, as far as React is concerned, it doesn’t even know there’s a “server” in the picture at all.
          React simply renders components, using data from only two places: props and state.
So therefore, to use some data from the server, you need to get that data into your components’ props or state.
You can complicate this process with services and data models (er, “build abstractions”) as much as you desire, but ultimately it’s just components rendering props and state.

Installing VS Code on Ubuntu

http://askubuntu.com/a/767436

sudo dpkg -i vscode-amd64.deb

Sunday, February 5, 2017

Kweb

KWeb is a library for building rich interactive web applications in pure Kotlin that makes the distinction between web browser and server largely invisible to the programmer.
Kweb the new coroutines mechanism in upcoming Kotlin 1.1 to elegantly avoid callback hell.
Kweb also incorporates a simple DSL for manipulating the browser’s DOM, and plugins to allow you to use popular JavaScript frameworks like JQuery and Material Design Light. It’s also surprisingly easy to add your own plugin for your favorite library or tool.

Importance of hard work

http://www.usatoday.com/story/sports/nfl/patriots/2017/02/04/new-england-dynasty-super-bowl-xxxvi-rams-bill-belichick-tom-brady/97488880/

“Our standard is high. We always talk that whatever we achieve is going to be earned on the practice field and earned in a lot of different times throughout the course of the season when we may not have a crowd of people watching us.
"We try to pay for it in advance. Over the years, that hasn’t changed.”

Followers

Blog Archive