Skip to content

Instantly share code, notes, and snippets.

View smspillaz's full-sized avatar
💥
mindblown

Sam Spilsbury smspillaz

💥
mindblown
View GitHub Profile
/* 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
# 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,
|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|
00 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
01 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
02 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
03 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
04 |@@|..|..|..|..|..|..|..|..|..|..|..|..|@@|@@|..|..|..|..|..|..|..|..|..|..|..|..|@@|
05 |@@|..|@@|@@|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|@@|@@|..|@@|
06 |@@|..|@@|@@|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|@@|@@|..|@@|
07 |@@|..|@@|@@|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|@@|@@|..|@@|
08 |@@|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|@@|
game_map = list()
for i in range(0, 28):
sub = []
for j in range(0, 36):
sub.append(False)
game_map.append(sub)
for i in range(0, 28):
@parameterized.expand(_KNOWN_STYLES)
def test_suggest_correction_docstring(self, style):
"""Correct slplling errors inside docstring."""
def get_replacement():
self._spellcheck_lint("{s}{e}\n\"\"\"splelling mistake\"\"\")\n",
style)
exception = self.assertRaises(LinterFailure, get_replacement)
self.assertEqual(replacement(exception),
(2,
@smspillaz
smspillaz / serialization
Created January 16, 2015 13:55
Coverage Serialization
static unsigned int COVERAGE_STATISTICS_CACHE_MAGIC = 0xC0432463;
static GjsCoverageCacheHeader *
create_coverage_statistics_cache(GjsCoverage *coverage)
{
GjsCoveragePrivate *priv = (GjsCoveragePrivate *) gjs_coverage_get_instance_private(coverage);
gsize allocation_len = calculate_coverage_statistics_cache_len(file_statistics_array);
void *allocation = g_malloc(allocation_len);
void *allocation_index = allocation;
@smspillaz
smspillaz / designer.html
Created August 12, 2014 03:49
designer
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@smspillaz
smspillaz / gist:e393e46b41ed40e0c239
Created July 25, 2014 13:45
Iterator Invalidation in C++
#include <boost/container/stable_vector.hpp>
#include <boost/timer/timer.hpp>
#include <vector>
#include <cstring>
#include <sys/time.h>
#include <iostream>
#include <cstdlib>
template <typename Container>
void randomize (Container &container)
@smspillaz
smspillaz / gist:8138673
Created December 26, 2013 21:03
G_FILE_CREATE_REPLACE_DESTINATION
static void
test_coverage_data_file_is_overwritten_completely(gpointer fixture_data,
gconstpointer user_data)
{
GjsDebugCoverageToSingleOutputFileFixture *fixture = (GjsDebugCoverageToSingleOutputFileFixture *) fixture_data;
/* Write the string "existing contents" about one hundred times to the file
* and check that the new file does not contain any string matching it */
const gchar *existing_contents = "existing_contents\n";
guint i = 0;
typedef struct _ChangeDebugModeData
{
guint flags;
gboolean enabled;
} ChangeDebugModeData;
typedef void (*LockAction) (JSContext *context,
gpointer user_data);
static void