Skip to content

Instantly share code, notes, and snippets.

@jlhernando
jlhernando / decode URL Apps Script
Created April 6, 2022 10:21
Decode URLs in Google Sheets creating a custom fucntion in Apps Script
/* Both these funcitons will work fine */
// As a function declaration
function DECODE(url) {
return decodeURI(url)
}
// Or as an arrow function
const DECODEURL = (url) => decodeURI(url)

This post presents an interesting way to make error handling more brief in Golang 1.18

One of the downsides to this approach is that defer functions and catching panics can be generally more expensive than using if/return for error handling. I decided to benchmark to see how significant the penalty turns out to be.

For some boilerplate, we have a giveError function:

func giveError(b bool) (int, error) {
  if b {
    return 0, fmt.Errorf("given error")
@CertainLach
CertainLach / benchmark.md
Last active July 10, 2022 12:00
Jrsonnet performance

Benchmark results

large_string_join

Command Mean [ms] Min [ms] Max [ms] Relative
jrsonnet large_string_join.jsonnet 16.5 ± 0.5 16.1 19.6 1.00
gojsonnet large_string_join.jsonnet 90.7 ± 3.8 85.6 104.0 5.49 ± 0.29
jsonnet large_string_join.jsonnet 69.5 ± 2.4 68.2 78.1 4.20 ± 0.20
sjsonnet large_string_join.jsonnet 760.6 ± 12.7 739.9 787.2 46.00 ± 1.67
@bjeanes
bjeanes / AAA_uuid_generate_v6mc.sql
Last active June 20, 2024 17:24
Postgres UUIDv6 (non-standard)
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- My port of https://github.com/kurttheviking/uuid-with-v6-js
-- A hacky translation of:
-- - http://gh.peabody.io/uuidv6/
-- - https://tools.ietf.org/html/draft-peabody-dispatch-new-uuid-format
CREATE OR REPLACE FUNCTION uuid_v1_to_v6(v1 uuid)
RETURNS uuid AS $$
DECLARE
v6 text;
@fabiolimace
fabiolimace / UUIDv6.sql
Last active April 2, 2025 00:39
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@katallaxie
katallaxie / main.go
Last active May 7, 2023 04:56
Server in Go with multiple listeners and signals.
package server
import (
"context"
"os"
"os/signal"
"syscall"
"time"
"golang.org/x/sync/errgroup"
@miguelmota
miguelmota / interface_to_bytes.go
Last active February 24, 2024 00:07
Golang interface to bytes using gob encoder
package main
import (
"encoding/gob"
"bytes"
)
func GetBytes(key interface{}) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
@olivere
olivere / elastic_v6_getting_started.go
Created March 1, 2018 07:27
Getting started with Elastic v6
package main
import (
"context"
"encoding/json"
"fmt"
"reflect"
"github.com/olivere/elastic"
)
@Gomah
Gomah / Dockerfile
Last active March 23, 2021 14:33
Nuxt.js Dockerfile :: Now.sh
FROM node:10-alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/
RUN yarn install
@hamishrouse
hamishrouse / README.md
Last active March 14, 2025 15:41
Typescript, React and Video.js (VideoJS)