Skip to content

Instantly share code, notes, and snippets.

Avatar

VB vaibhav-kumar-tokyo

  • Tokyo
View GitHub Profile
View factorial-wasm-js-glue-code.js
fetch('factorial.wasm')
//getting WASM Module from response
.then(response => response.arrayBuffer())
//instantiating WASM instance from WASM Module
.then(bytes => WebAssembly.instantiate(bytes))
//using exported factorial fn from WASM Instance
.then(results => {
console.log(results.instance.exports.factorial(12))
})
View factorial.c
int factorial(int n)
{
if(n > 1)
return n * factorial(n - 1);
else
return 1;
}
View squareMe.c
int squareMe (int n) {
return n * n;
}
View squareMe.wat
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "squareMe" (func $squareMe))
(func $squareMe (; 0 ;) (param $0 i32) (result i32)
(i32.mul
(get_local $0)
(get_local $0)
)
View factorial.wat
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "factorial" (func $factorial))
(func $factorial (; 0 ;) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(set_local $2
(i32.const 1)
View fancy-af-button-stencil-generated-wc.js
import { r as registerInstance, h } from './core-957b5e39.js';
const FancyAFButton = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.clickedCount = 0;
}
handleClick() {
this.clickedCount += 1;
}
View fancy-af-button-stencil.tsx
import { Component, Prop, h, Listen, State } from "@stencil/core";
@Component({
tag: "fancy-af-button",
styleUrl: "fancy-af-button.css",
shadow: true
})
export class FancyAFButton {
@State() clickedCount: number = 0;
View fancy-af-button-snippet.js
customElements.define( // registering our custom-element to CustomElementRegistry
"fancy-af-button",
class extends HTMLElement { // defining our custom-element
constructor() {
// always call super() first in the constructor.
super();
// reading custom-element's template
const template = document.getElementById("fancy-af-button-template");
const templateContent = template.content;
View fancy-af-button-snippet.html
<template id="fancy-af-button-template">
<button>
<slot />
<!-- placeholder inside a WC to be replaced by markups attached at run-time -->
</button>
</template>
<fancy-af-button>
<span>I'm fancy!</span> <!-- will replace <slot /> -->
</fancy-af-button>
View resume.json
{
"basics": {
"name": "Vaibhav Kumar",
"label": "Web Developer",
"summary": "I’m a full stack web developer who loves working with open source technology. I work best at planning the architecture of web applications and their development life cycles. I also love to get the community involved and have had much experience with building and organizing large open source groups. Specialties: React, Redux, Javascript - Full stack developer with lots of experience in lots of stuff.",
"website": "https://vaibhavkumar.me",
"email": "vaibhav.iiitj@gmail.com",
"location": {
"city": "Tokyo",
"countryCode": "JP"
You can’t perform that action at this time.