Skip to content

Instantly share code, notes, and snippets.

@Israel-Miles
Israel-Miles / hello-wasm.go
Last active October 25, 2020 23:41
hello webassembly with go
package main
import "fmt"
func main() {
fmt.Println("Hello, WebAssembly!")
}
@Israel-Miles
Israel-Miles / index.html
Last active October 26, 2020 00:07
webassembly index page
<html>
<head>
<meta charset="utf-8"/>
<title>WebAssembly with Go</title>
<body>
<h1>You've compiled Go for WebAssembly, Congratulations!</h1>
<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(
@Israel-Miles
Israel-Miles / http.go
Created October 26, 2020 00:12
basic go server
// A basic HTTP server.
// By default, it serves the current working directory on port 8080.
package main
import (
"flag"
"log"
"net/http"
)
@Israel-Miles
Israel-Miles / aes.js
Created October 31, 2020 21:10
aes service
import { Injectable } from '@angular/core';
import * as CryptoJS from 'crypto-js';
@Injectable({
providedIn: 'root'
})
export class EncryptionService {
secretKey = "A secret key 123!";
constructor() { }
@Israel-Miles
Israel-Miles / aes-spec.js
Created October 31, 2020 21:15
aes-spec
import { TestBed } from '@angular/core/testing';
import { EncryptionService } from './encryption.service';
describe('EncryptionService', () => {
let service: EncryptionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(EncryptionService);
@Israel-Miles
Israel-Miles / device.go
Created November 11, 2020 19:51
command-pattern
package main
type device interface {
on()
off()
increaseVolume()
decreaseVolume()
}
@Israel-Miles
Israel-Miles / command.go
Created November 11, 2020 19:52
command-pattern
package main
type command interface {
execute()
}
@Israel-Miles
Israel-Miles / onCommand.go
Created November 11, 2020 19:56
command-pattern
package main
type onCommand struct {
device device
}
func (c *onCommand) execute() {
c.device.on()
}
@Israel-Miles
Israel-Miles / offCommand.go
Created November 11, 2020 20:00
command-pattern
package main
type offCommand struct {
device device
}
func (c *offCommand) execute() {
c.device.off()
}
package main
type increaseVolumeCommand struct {
device device
}
func (c *increaseVolumeCommand) execute() {
c.device.increaseVolume()
}