Skip to content

Instantly share code, notes, and snippets.

View unders's full-sized avatar

Anders Törnqvist unders

  • Functionbox
  • Göteborg, Sweden
View GitHub Profile
@unders
unders / svelte-summit-2020-summary.md
Created October 23, 2020 16:01 — forked from vedam/svelte-summit-2020-summary.md
links and ressources from the svelte-summit-2020 talks

You'll find the talks here


Morgan Williams @mrgnw

The Zen of Svelte

Approaching frontend as a backend developer, Svelte feels surprisingly pythonic. Let's take a quick look at what's familiar, what's foreign, and how to explore the gap.

@unders
unders / JavaScript.js
Last active February 16, 2020 05:36
JavaScript Recipes
// Try sign-in with AJAX
fetch('/signin', {
method: 'POST',
body: new FormData(e.target),
credentials: 'include'
})

Challanges

Metrics

It goes like this: “Once upon a time…something bad happened. The end.” How do you like this story?

Metrics, or stats, are numerical measures recorded by the application, such as counters, gauges, or timers. Metrics are very cheap to collect, since numeric values can be easily aggregated to reduce the overhead of transmitting that data to the monitoring system. They are also fairly accurate, which is why they are very useful for the actual monitoring (as the dictionary defines it) and alerting.

Yet the same capacity for aggregation is what makes metrics ill-suited for explaining the pathological behavior of the application. By aggregating data, we are throwing away all the context we had about the individual transactions.

Logs

@unders
unders / simple-http-server.md
Last active August 18, 2022 08:24
Simple HTTP Server

A server struct

A single server structure that usually ends up looking something like this:

type server struct {
    db     *someDatabase
    router *someRouter
    email  EmailSender
}

Shared dependencies are fields of the structure

@unders
unders / simple-go-handler.md
Last active November 17, 2018 15:45
Simple Go handler
func productHandler(w http.ResponseWriter, r *http.Request) {
        key := r.URL.Path[len("/products/"):]
        switch r.Method {
        case "GET":
            // do GET stuff
        case "POST":
            // Fo POST stuff
        default:
            http.Error(w, "Method Not Allowed", 405)
@unders
unders / tester.js
Created November 3, 2018 18:43 — forked from freedmand/tester.js
JavaScript unit testing in under 30 lines
const PASS = ['32']; // green
const FAIL = ['31', '1']; // red, bold
function logStyle(ansiEscapeCodes, text) {
console.log(`\x1b[${ansiEscapeCodes.join(';')}m${text}\x1b[0m`);
}
class Tester {
constructor() {}
@unders
unders / crypto_news.json
Created July 19, 2018 09:16 — forked from stungeye/crypto_news.json
News Site RSS Feeds
[
{
"url": "http://money.cnn.com",
"rss": "http://rss.cnn.com/rss/money_topstories.rss"
},
{
"url": "http://thehill.com",
"rss": "http://thehill.com/rss/syndicator/19110"
},
{
// This function works
export const appV1 = functions.https.onRequest(app);
// This function is not called when a new user is created
export const createUserProfile = functions.auth.user().onCreate( async (event) => {
console.log("createUserProfile: ", event.data);
});
func (d *Datastore) GetStuff(userKey, currentAccountKey, defaultAccountKey *cdatastore.Key) (*data.User, error) {
errCh := make(chan error, 3)
retCh := make(chan bool, 2)
done := make(chan bool)
u := &dbdata.User{}
a := &data.Account{}
// Fetch user
go func() {

Keybase proof

I hereby claim:

  • I am unders on github.
  • I am unders (https://keybase.io/unders) on keybase.
  • I have a public key ASBhDnFpgq4R7T7x1wVLY0IM_DgJyL8oYCEmRVgyYwFMzAo

To claim this, I am signing this object: