Skip to content

Instantly share code, notes, and snippets.

@0sc
0sc / jsonapi_with_primitives.rb
Created April 21, 2024 22:47
Sample snippets for using jsonapi-rb with primitive types.
module IdGenerator
# some basic unique id generator
SEQ = (1..).to_enum
# id field is required by the JSONAPI spec and must be unique in an array
def self.included(klass) = klass.id { "_#{SEQ.next}" }
end
# ---
@0sc
0sc / mov.lua
Created April 30, 2023 22:05
Basic LUA script for selectively moving elements from one Redis list to another.
-- Original use case was a quick and dirty migration of some overbloated repeated jobs
-- from a sidekiq job queue to another/temporary redis list
-- as part of an incident mitigation.
--
-- usage example:
-- redis.eval("return { KEYS, ARGV }", :keys => ["k1", "k2"], :argv => ["a1", "a2"])
-- EVAL "return ARGV[1]" 2 sidekiq:default moved:default "{\"class\":\"Something\"}"
--
-- KEY[1] is the original list to remove elements from
-- KEY[2] is the other list to move the removed elements to
@0sc
0sc / list.md
Created June 13, 2022 07:43 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@0sc
0sc / .env.sample
Created January 4, 2022 19:03
Code snippets for using Imgproxy with Minio.
IMGPROXY_KEY=$(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
IMGPROXY_SALT=$(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
ACCESS_SECRET=$(xxd -g 2 -l 5 -p /dev/random | tr -d '\n')
ACCESS_KEY=$(xxd -g 2 -l 5 -p /dev/random | tr -d '\n')
REGION=us-east-1
DEFAULT_BUCKET=sample
@0sc
0sc / pod.yaml
Last active August 6, 2019 19:45
helm pod template
apiVersion: v1
kind: Pod
metadata:
name: {{ template "simple-pod.fullname" . }}
labels:
{{ include "simple-pod.labels" . | indent 4 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.image }}
@0sc
0sc / Dockerfile
Created August 6, 2019 00:11
Sample Dockerfile using image from a docker registry running locally
FROM localhost:5000/mybusybox
CMD ["echo", "Hello from busybox"]
package main
import (
"fmt"
"io"
"log"
"math"
"math/rand"
"net/http"
"os"
package main
import (
"fmt"
"io"
"log"
"math"
"math/rand"
"net/http"
"os"
package main
import (
"fmt"
"io"
"log"
"math"
"math/rand"
"net/http"
"os"
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-logging
namespace: kube-system
labels:
app: fluentd-logging
data:
fluent.conf: |
<source>