Skip to content

Instantly share code, notes, and snippets.

👨‍🍳
Cooking something new

Arunoda Susiripala arunoda

👨‍🍳
Cooking something new
View GitHub Profile
@arunoda
arunoda / README.md
Created Nov 16, 2017
Result: ESP 8266 Load Test
View README.md
@arunoda
arunoda / client.js
Created Nov 16, 2017
Node.js HTTP client for ESP8266 Load Test
View client.js
const http = require('http');
const printHeaders = (() => {
let printed = false
return () => {
if (printed) return
console.log('timestamp, kbps')
printed = true;
}
})();
View package.json
{
"scripts": {
"dev": "next",
"build": "next build",
"export": "next export"
}
}
@arunoda
arunoda / next.config.js
Created May 3, 2017
Stop uglifying in Next.js
View next.config.js
module.exports = {
webpack: function (cfg) {
cfg.plugins = cfg.plugins.filter(plugin => {
return plugin.constructor.name !== 'UglifyJsPlugin';
});
return plugin
}
}
View server.js
const express = require('express')
const next = require('next')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
const server = express()
View with-babelrc.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = require("/data/zeit/next.js/node_modules/babel-runtime/helpers/defineProperty");
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
View sysinfo_fragment.js
SysInfoComponent.fragment = SysInfoSchema.createFragment(`
fragment on SysInfo {
hostname,
memory,
uptime,
loadavg {
min1
}
}
`);
View sysinfo_react_component.js
SysInfoComponent = ({sysInfo}) => (
<div>
<h1>System Information</h1>
<ul>
<li>Hostname: {sysInfo.hostname}</li>
<li>Uptime: {sysInfo.uptime} seconds</li>
<li>Memory: {sysInfo.memory} MB</li>
<li>Load Average: {sysInfo.loadavg.min1} </li>
</ul>
</div>
View sysinfo.query.js
{
sysInfo {
memory,
uptime,
loadavg {
min1
}
}
}
View create-the-client.js
var Lokka = require('lokka').Lokka;
var Transport = require('lokka-transport-http').Transport;
// Create a lokka client against SWAPI GraphQL API
var client = new Lokka({
transport: new Transport('http://graphql-swapi.parseapp.com/')
});
You can’t perform that action at this time.