Skip to content

Instantly share code, notes, and snippets.

View rogerwelin's full-sized avatar
:shipit:
Gopher

Roger Welin rogerwelin

:shipit:
Gopher
View GitHub Profile
@rogerwelin
rogerwelin / anime.json
Created September 19, 2017 19:57
anime-recommendation
This file has been truncated, but you can view the full file.
{"id":"anime_id","name":"name","genre":"genre","type":"type","episodes":"episodes","rating":"rating","members":"members"}
{"id":"32281","name":"Kimi no Na wa.","genre":"Drama","type":"Romance","episodes":"School","rating":"Supernatural","members":"Movie"}
{"id":"5114","name":"Fullmetal Alchemist: Brotherhood","genre":"Action","type":"Adventure","episodes":"Drama","rating":"Fantasy","members":"Magic"}
{"id":"28977","name":"Gintama°","genre":"Action","type":"Comedy","episodes":"Historical","rating":"Parody","members":"Samurai"}
{"id":"9253","name":"Steins;Gate","genre":"Sci-Fi","type":"Thriller","episodes":"TV","rating":"24","members":"9.17"}
{"id":"9969","name":"Gintama'","genre":"Action","type":"Comedy","episodes":"Historical","rating":"Parody","members":"Samurai"}
{"id":"32935","name":"Haikyuu!!: Karasuno Koukou VS Shiratorizawa Gakuen Koukou","genre":"Comedy","type":"Drama","episodes":"School","rating":"Shounen","members":"Sports"}
{"id":"11061","name":"Hunter x Hunter (2011)","genre":"Action","type":"
@rogerwelin
rogerwelin / filter1.js
Created December 7, 2017 17:59
fun-fun-function-filter-1
// we want to filter out all dogs
var animals = [
{ name: 'fluffykins', species: 'rabbit' },
{ name: 'caro', species: 'dog' },
{ name: 'jimmy', species: 'fish' },
{ name: 'ursula', species: 'cat' },
{ name: 'hamilton', species: 'dog' }
]
@rogerwelin
rogerwelin / map1.js
Created December 7, 2017 18:01
fun-fun-function-map-2
// we want to filter out all names
var animals = [
{ name: 'fluffykins', species: 'rabbit' },
{ name: 'caro', species: 'dog' },
{ name: 'jimmy', species: 'fish' },
{ name: 'ursula', species: 'cat' },
{ name: 'hamilton', species: 'dog' }
]
@rogerwelin
rogerwelin / reduce1.js
Created December 7, 2017 18:02
fun-fun-function-reduce-3
// mission: summarize the amount
// reduce is multi tool on list transformation
var orders = [
{amount: 250},
{amount: 400},
{amount: 100},
{amount: 325}
]
@rogerwelin
rogerwelin / reduce2.js
Created December 7, 2017 18:04
fun-fun-function-reduce-4
/* file we're processing
random name,waffle iron,80,2
random name,blender,200,1
random name,knife,10,4
hulk hogan,waffle iron,80,1
hulk hogan,blender,180,3
hulk hogan,pot,90,3
*/
const fs = require('fs')
@rogerwelin
rogerwelin / dep-inject.go
Last active December 28, 2017 22:02
go-dependency-inject1
package main
import (
"flag"
"fmt"
"io/ioutil"
"net/http"
)
var (
@rogerwelin
rogerwelin / go-dependency-inject-mock.go
Last active December 28, 2017 22:12
dependency injection mocking
package main
import (
"bytes"
"io/ioutil"
"net/http"
"testing"
)
type MockHttpClient struct{}
@rogerwelin
rogerwelin / websocketgorilla.go
Last active September 27, 2022 13:20
websocket gorilla
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
@rogerwelin
rogerwelin / websocketjs.html
Created March 13, 2018 22:42
websocket html
<html>
<head>
</head>
<body>
<h1>Long/lat:</h1>
<!-- 1 -->
<div id="long"></div>
<div id="lat"></div>
<script type="text/javascript">
var long = document.getElementById("long");
@rogerwelin
rogerwelin / key-value.go
Last active May 16, 2018 19:45
key-value.go
package main
import (
"bufio"
"encoding/gob"
"fmt"
"os"
"strings"
)