Skip to content

Instantly share code, notes, and snippets.

@up1
up1 / 1.txt
Last active December 18, 2024 15:15
Go :: fieldalignment
$go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
$fieldalignment -fix <package or filename>
@joshnuss
joshnuss / httpStore.js
Last active October 11, 2023 11:29
A Svelte store backed by HTTP
import { writable } from 'svelte/store'
// returns a store with HTTP access functions for get, post, patch, delete
// anytime an HTTP request is made, the store is updated and all subscribers are notified.
export default function(initial) {
// create the underlying store
const store = writable(initial)
// define a request function that will do `fetch` and update store when request finishes
store.request = async (method, url, params=null) => {
package main
import (
"encoding/json"
"fmt"
)
func main() {
b := []byte(`{"key":"value"}`)
@artisanalcode
artisanalcode / focus-blur-debugger.js
Created August 17, 2016 16:21
Little script to help debug focus/blur events on Chrome.
/**
* Little script to help debug focus/blur events on Chrome.
* @note Since ChromeDev tools takes focus it creates an Observer Effect @see (https://en.wikipedia.org/wiki/Observer_effect_(physics).
* @author http://stackoverflow.com/users/2122682/aminimalanimal (Found in StackOverflow)
* @see http://stackoverflow.com/questions/8978039/debugging-onfocus-event-using-chrome-developer-tools-cant-return-focus-after-b
*/
$('*').on(
'focus blur',
function(event) {
console.log(event.type + " to:");