とりあえずmallocとfreeがあればokなんだが・・・。
- pros: 何も考えなくてもmallocとfreeが手に入る。
- cons: でかい。
(module | |
(import "js" "print" (func $print (param f64))) | |
(global $PI f64 (f64.const 3.141592653589793)) | |
(global $SOLAR_MASS f64 (f64.const 39.47841760435743)) | |
(global $DAYS_PER_YEAR f64 (f64.const 365.24)) | |
;; (global $size (mut i32) (i32.const 0)) | |
(memory $mem 1) | |
(func $createBody (param i32 f64 f64 f64 f64 f64 f64 f64) | |
(local $offset i32) |
とりあえずmallocとfreeがあればokなんだが・・・。
// https://ja.wikipedia.org/wiki/Adler-32 | |
#include <webassembly.h> | |
#define MOD_ADLER 65521 | |
uint32_t adler32(uint8_t *data, size_t len) { | |
uint32_t a = 1, b = 0; | |
while (len > 0) { |
const gmk = require('git-miru-kun'); | |
(async () => { | |
const gitDir = await gmk.readGitDir('.git'); | |
const parentHashDict = {}; | |
const targetBranch = await gitDir.readHead(); | |
const { branchName } = targetBranch; | |
const commits = (await gitDir.readBranches()) |
const fs = require('fs'); | |
const zlib = require('zlib'); | |
const path = require('path'); | |
const { parse } = require('./git-object-parser'); | |
const { Packfile } = require('./packfile'); | |
// hashからGitオブジェクトのパスを作る | |
function getObjectPath(sha1) { | |
return path.resolve( | |
process.cwd(), |
function isBlock(node) { | |
if (node.nodeType !== Node.ELEMENT_NODE) return false; | |
return /^(ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|CANVAS|DD|DIV|DL|DT|FIELDSET|FIGCAPTION|FIGURE|FOOTER|FORM|H1|H2|H3|H4|H5|H6|HEADER|HGROUP|HR|LI|MAIN|NAV|NOSCRIPT|OL|OUTPUT|P|PRE|SECTION|TABLE|TFOOT|UL|VIDEO)$/.test(node.nodeName); | |
} | |
function createPseudoParagraph(node) { | |
return { nodeName: "PSEUDO_PARAGRAPH", childNodes: [node] }; | |
} | |
function createBrBlock(nodes) { |
Install and Build and Screenshot.
git clone https://gist.github.com/906764beb36481301405c586abd81011.git
cd 906764beb36481301405c586abd81011
npm install
npm run build
npm run screenshot https://gist.github.com/ukyo/906764beb36481301405c586abd81011
open out.html
<canvas id="canvas" width="640" height="480"></canvas> | |
<script> | |
const img = new Image; | |
img.src = "lena.png"; | |
let ctx; | |
let arr; | |
img.onload = () => { | |
ctx = canvas.getContext("2d"); | |
ctx.drawImage(img, 0, 0); | |
arr = ctx.getImageData(0, 0, 640, 480).data; |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta | |
name="viewport" | |
content="width=device-width, initial-scale=1.0" | |
> | |
<meta |