Simple flat file NoSQL database.
$db = database('blog.json');| port = 3000 | |
| express = require 'express' | |
| serveStatic = require 'serve-static' | |
| serveIndex = require 'serve-index' | |
| router = require './router' | |
| express() | |
| .use router | |
| .use serveStatic('.') | |
| .use serveIndex('.') |
| <?php | |
| function kvstore ($file, $init = NULL) { | |
| static $stores = []; | |
| $store = @$stores[$file]; | |
| if (!$store) { | |
| $prev = @file_get_contents($file); | |
| if (!$prev) { | |
| if ($init) { | |
| $prev = json_encode((object) $init()); |
| package sketch; | |
| import java.awt.Rectangle; | |
| import java.util.HashMap; | |
| public class Ui { | |
| //////////////////////////////////// STATE ///////////////////////////////////// | |
| private static class State { |
| Alignment Formula: | |
| itemLocation = containerLocation + containerSize * alignmentFactor - itemSize * alignmentFactor | |
| item.x = container.x + container.width * alignment.x - item.width * alignment.x | |
| item.y = container.y + container.height * alignment.y - item.height * alignment.y |
| <canvas id="canvas" width="500" height="500"></canvas> | |
| <script> | |
| Object.assign(new Image(), { | |
| src: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAAXNSR0IArs4c6QAAADdJREFUCJlVzLENwCAMAMEjosL7D+DNzCRORUS+Pv3o7nYVESZUFchM8Byx9/70vMVprLV+T3gB2s0OUOHHM2YAAAAASUVORK5CYII=', | |
| onload: function () { | |
| var ctx = canvas.getContext('2d') | |
| ctx.fillStyle = '#a0a0a0' | |
| ctx.fillRect(0, 0, canvas.width, canvas.height) |
| public static int getInternalFormat(BufferedImage image) { | |
| switch (image.getType()) { | |
| case BufferedImage.TYPE_3BYTE_BGR: | |
| return GL_RGB; | |
| case BufferedImage.TYPE_4BYTE_ABGR: | |
| return GL_RGBA; | |
| default: | |
| throw new UnsupportedOperationException(); | |
| } | |
| } |
| function newBuckets (size) { | |
| let buckets = [] | |
| for (let i = 0; i < size; i++) { | |
| buckets.push(null) | |
| } | |
| return buckets | |
| } | |
| function getBucket (key, buckets) { | |
| return key.hashCode() % buckets.length |
| public class ByteBitmask { | |
| public static final byte MASK_0 = 1 << 0; | |
| public static final byte MASK_1 = 1 << 1; | |
| public static final byte MASK_2 = 1 << 2; | |
| public static final byte MASK_3 = 1 << 3; | |
| public static final byte MASK_4 = 1 << 4; | |
| public static final byte MASK_5 = 1 << 5; | |
| public static final byte MASK_6 = 1 << 6; | |
| public static final byte MASK_7 = (byte) (1 << 7); |
| public class Node { | |
| public Node getParentNode() { | |
| return parentNode; | |
| } | |
| public Node getPreviousSibling() { | |
| return previousSibling; | |
| } |