This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From A to Server Rendering, 2018 edition | |
-- How do I do this again? | |
Another year, another React app to add server-side rendering support to. For the | |
uninitiated, Server-Side-Rendering in the context of React is the term used to | |
describe the use of React itself to do the first render pass of a web-app on the | |
server and send that to the browser just before it gets the (rather large) JavaScript | |
bundle for your React App. The browser can display the server-rendered page immediately and then continue running your App once it is done with the bundle. | |
Server rendering really is one of those things where its great in theory, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2018 Your name | |
* | |
* {{project}} is free software: you can redistribute it and/or | |
* modify it under the terms of the GNU Lesser General Public License as | |
* published by the Free Software Foundation, either version 2.1 of the | |
* License, or (at your option) any later version. | |
* | |
* {{project}} is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto translationMat = glm::translate ( | |
glm::mat4 (1.0), | |
glm::vec3 (agd::get <0> (translation), | |
agd::get <1> (translation), | |
0.0) | |
); | |
auto invCenterMat = glm::translate ( | |
glm::mat4 (1.0), | |
glm::vec3 (-1 * agd::get <0> (intendedCenter), | |
-1 * agd::get <1> (intendedCenter), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M /metadata | |
M /files/manifest.json | |
M /files/lib/libcontentfeed-0.so.0.0.0 | |
M /files/lib/libeknr-0.so.0.0.0 | |
M /files/lib/libendless-0.so.0.500.0 | |
M /files/lib/libeoscompanion-1.so.0.0.0 | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/__init__.cpython-35.opt-1.pyc | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/applications_query.cpython-35.opt-1.pyc | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/constants.cpython-35.opt-1.pyc | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/content_streaming.cpython-35.opt-1.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# So generally speaking, if you want to be opening files with Python | |
# its better to observe the "Easier to ask for forgiveness than permission" | |
# principle (EAFP) where just blindly try to open the file as though it | |
# existed and then handle exceptions where it does not: | |
# | |
# The reason why you should do this is two fold: | |
# (1) Checking first always imposes a performance cost due | |
# to the extra system call overhead. | |
# (1.1) Unlike languages like C++, you always pay the | |
# cost of exception paths in Python, so it makes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def random_search(array, iterations, objective, *args): | |
"""Do a random search over the array for :iterations:.""" | |
best = array[0] | |
best_value = objective(best, *args) | |
for i in range(iterations): | |
candidate = random.sample(best, len(best)) | |
value = objective(candidate, *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def both_objectives(layout, columns, *args): | |
return (frequency_objective(layout,*args), | |
similarity_objective(layout,*args)) | |
def random_evaluated_design(seed_design, objective_function, *args): | |
"""Return a new random design, evaluated by objective_function""" | |
candidate = random.sample(seed_design, len(seed_design)) | |
return (candidate, *objective_function(candidate, *args)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def both_objectives(layout, columns, *args): | |
return (frequency_objective(layout,*args), | |
similarity_objective(layout,*args)) | |
def random_evaluated_design(seed_design, objective_function, *args): | |
"""Return a new random design, evaluated by objective_function""" | |
candidate = random.sample(seed_design, len(seed_design)) | |
return (candidate, *objective_function(candidate, *args)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def both_objectives(layout, columns, *args): | |
return (frequency_objective(layout,*args), | |
similarity_objective(layout,*args)) | |
def random_evaluated_design(seed_design, objective_function, *args): | |
"""Return a new random design, evaluated by objective_function""" | |
candidate = random.sample(seed_design, len(seed_design)) | |
return (candidate, *objective_function(candidate, *args)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
function oldStyleAsynchronousFunction(callback) { | |
fs.readFile('somefile.txt', 'utf8', function(err, result) { | |
if (err) { | |
callback(err, null); | |
return; | |
} | |
callback(result); |