Skip to content

Instantly share code, notes, and snippets.

@foolishway
foolishway / oo.js
Created Oct 22, 2021
javascript inherit
View oo.js
// OO - Class - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
// Based on http://ejohn.org/blog/simple-javascript-inheritance/
// which is based on implementations by Prototype / base2
;(function(){
var global = this, initialize = true
var referencesSuper = /xyz/.test(function(){ xyz }) ? /\b__super__\b/ : /.*/
/**
View future-mod.go
package main
import (
"fmt"
"time"
)
type Future struct {
C chan struct{}
}
View handleWriting.html
<html>
<head>
<title></title>
</head>
<body>
<div id="test1">
<div id="text"></div>
<canvas id="mycanvas" width="900px" height="800px"></canvas>
View ogg2mp3.sh
#!/bin/bash
for i in *.ogg;
do ffmpeg -i "$i" -f mp3 "${i%.*}.mp3";
done
rm *.ogg;
View learnFromBradfitz.go
package main
import (
"fmt"
)
var serverMap = map[int32]string{1: "server1", 2: "server2", 3: "server3"}
func main() {
var id int32 = 1
View channel.go
package main
import (
"fmt"
"time"
"log"
"os"
)
func main() {
View forEach.go
package main
import "fmt"
type CB func(int, interface{})
type Array []interface{}
func (arr *Array) forEach(callback CB) {
for index, item := range *arr {
View middleware.go
package main
import (
"log"
"net/http"
"os"
)
type Adapter func(http.Handler) http.Handler
View gist:1630080596f7b3888038c687fed77a92
package main
import (
"fmt"
"unsafe"
)
func main() {
b := []byte("some momery")
s := string(b)
View stack.go
package main
import (
"fmt"
"strconv"
)
type Istring interface {
string(string) string
}