Minimal Node Servers
A collection of code snippets that create servers in as few steps as possible.
Minimal HTTP Server
// setup (61 bytes):
const http = require('http');
/** | |
* Parses the JSON returned by a network request | |
* | |
* @param {object} response A response from a network request | |
* | |
* @return {object} The parsed JSON, status from the response | |
*/ | |
function parseJSON(response) { | |
return new Promise(resolve => | |
response.json().then(json => |
--[[ | |
lua readonly module | |
2013 (c) nyaocat | |
this program is licensed under NYSL( http://www.kmonos.net/nysl/ ) | |
lua5.1 and lua5.2 | |
]] | |
local newproxy = newproxy or require("newproxy") -- for Lua5.2 | |
local type, getmetatable, pairs, assert, error = type, getmetatable, pairs, assert, error |
/** | |
* @author yomboprime https://github.com/yomboprime | |
* | |
* GPUComputationRenderer, based on SimulationRenderer by zz85 | |
* | |
* The GPUComputationRenderer uses the concept of variables. These variables are RGBA float textures that hold 4 floats | |
* for each compute element (texel) | |
* | |
* Each variable has a fragment shader that defines the computation made to obtain the variable in question. | |
* You can use as many variables you need, and make dependencies so you can use textures of other variables in the shader |
function commitAllWork(fiber) { | |
fiber.effects.forEach(f => { | |
commitWork(f); | |
}); | |
fiber.stateNode._rootContainerFiber = fiber; | |
nextUnitOfWork = null; | |
pendingCommit = null; | |
} | |
function commitWork(fiber) { |
A collection of code snippets that create servers in as few steps as possible.
// setup (61 bytes):
const http = require('http');
pcall(require,"socket") | |
local coroutine_scheduler = { | |
_NAME = "coroutine_scheduler.lua" | |
_VERSION = "1.0.0", | |
} | |
local Scheduler | |
do Scheduler = setmetatable({}, { | |
__call = function(class) |
var text by mutableStateOf("") | |
val charCount: Int get() = text.length | |
val todoList = mutableStateListOf<Item>(emptyList()) | |
val filteredTodoList get() = when (todoListFilter) { | |
Filter.Completed -> todoList.filter { it.isComplete } | |
Filter.Uncompleted -> todoList.filter { !it.isComplete } | |
Filter.All -> todoList | |
} | |
@Composable fun Example() { |
# Copyright (c) 2015 Tony Garnock-Jones <tonyg@leastfixedpoint.com> | |
# | |
# Permission is hereby granted, free of charge, to any person | |
# obtaining a copy of this software and associated documentation files | |
# (the "Software"), to deal in the Software without restriction, | |
# including without limitation the rights to use, copy, modify, merge, | |
# publish, distribute, sublicense, and/or sell copies of the Software, | |
# and to permit persons to whom the Software is furnished to do so, | |
# subject to the following conditions: | |
# |
This is flow used by apps on Apple TV / Roku. However, it is also useful for CLIs.
Here is my rundown. Please correct me in comments if something is wrong or if there is a better way to do this.
Device pings the server to begin activation process
/* ----------------------------------------- * | |
Lazy List Implementation | |
* ----------------------------------------- */ | |
// Haskell-like infinite List, implemented with es6 generators | |
// Lazyness lets you do crazy stuff like | |
List.range(0, Infinity) | |
.drop(1000) | |
.map(n => -n) |