Skip to content

Instantly share code, notes, and snippets.

View syronz's full-sized avatar
🎩
Coding

Diako Sharifi syronz

🎩
Coding
View GitHub Profile
@richard-flosi
richard-flosi / star-wars-planets.html
Last active January 17, 2024 07:58
Web Component using Custom Element, Shadow DOM, fetch, async/await, and the Star Wars API
<html>
<head>
<script>
customElements.define("star-wars-planets", class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
static get observedAttributes() { return ["loading", "planets"]; }
@robertknight
robertknight / info.md
Last active March 4, 2022 05:59
Promises + IndexedDB Test

This gist demonstrates a problem with IndexedDB & Promises in Firefox which makes using IndexedDB very unergonomic in some cases in Firefox.

The test below reads, updates & writes a counter value to an IndexedDB database 10 times in the same transaction and then prints the result. To make the code easier to read, it uses async + await, which requires converting the IndexedDB requests (IDBRequest objects) to promises with a simple helper.

In Chrome, multiple promise callbacks can be executed with auto-committing an IDB transaction, allowing read-modify-write steps to work. In Firefox however, the IDB transaction gets auto-committed before the promise callback is fired, which means that read-modify-write operations have to use callbacks rather than promises.

@sayden
sayden / ObserverDesignPattern.go
Created December 14, 2015 22:45
Observer Pattern in Golang
package main
import "fmt"
//Listener is a
type Listener struct {
ID int
}
//ListenerInterface is an
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@vaskoz
vaskoz / builder.go
Last active January 22, 2024 10:54
Golang Builder pattern
package main
import "strconv"
import "fmt"
type Color string
type Make string
type Model string
const (