Skip to content

Instantly share code, notes, and snippets.

View regalius's full-sized avatar
💻
<IMG SRC=j&#X41vascript:alert('!XSS!')>

Felix Tan regalius

💻
<IMG SRC=j&#X41vascript:alert('!XSS!')>
View GitHub Profile
@regalius
regalius / magic-cube.yaml
Last active April 28, 2022 08:13
magic-cube.yaml
blueprint:
name: Aqara Magic Cube
description: Control anything using Aqara Magic Cube.
domain: automation
input:
remote:
name: Magic Cube
description: Select the Aqara Magic Cube device
selector:
device:

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@regalius
regalius / cheatsheet-elasticsearch.md
Created July 5, 2020 07:28 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@regalius
regalius / command for copy redis
Last active June 10, 2020 09:08 — forked from stephanustedy/command for copy redis
command for copy redis
# COPY REAL TIME / NEW DATA
while true; do exec redis-cli -h [old-endpoint] monitor | sed -u 's/.*]//' | grep -vi "get\|ping" | redis-cli -h [new-endpoint] >> /dev/null; done;
# COPY DATA ON REDIS with TTL
redis-cli -h [old-endpoint] --scan | while read key; do tempTTL=$(redis-cli -h [old-endpoint] TTL "$key"); ttl=$tempTTL;if [ $tempTTL -lt 0 ]; then ttl=0; fi; redis-cli -h [old-endpoint] --raw DUMP "$key" | head -c -1 |redis-cli -x -h [new-endpoint] RESTORE "$key" $ttl; echo "copied $key $ttl"; done
@regalius
regalius / benchmark.md
Last active October 2, 2019 09:05
Benchmarking Go App

Golang

Benchmark HTTP

package test

import (
	"log"
	"net/http/httptest"
	"testing"
@regalius
regalius / benchmark.go
Created September 26, 2019 17:53
Benchmark Golang
// All material is licensed under the Apache License Version 2.0, January 2004
// http://www.apache.org/licenses/LICENSE-2.0
// go test -run none -bench . -benchtime 3s -benchmem
// Tests to see how each algorithm compare.
package main
import (
"bytes"
@regalius
regalius / compression.go
Created July 17, 2019 15:03
Comparing compression algorithm in Go
package main
import (
"bytes"
"compress/gzip"
"compress/lzw"
b64 "encoding/base64"
"encoding/binary"
"encoding/json"
"fmt"
@regalius
regalius / server.md
Last active March 28, 2022 10:35
Cheatsheet

Sniffing HTTP request/response with tcpdump

tcpdump -A -s 0 'tcp dst port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

Sniffing TCP request/response with tcpdump to UTF-8

tcpdump tcp port 2112 -s 16000 -w - | tr -t '[^[:print:]]' ''

Sniffing Datadog Metrics sent

import initStoryshots, {
multiSnapshotWithOptions,
imageSnapshot
} from "@storybook/addon-storyshots";
import path from "path";
initStoryshots({
suite: "Storyshots",
integrityOptions: { cwd: __dirname },
test: multiSnapshotWithOptions({})
{
"name": "storybook-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"cross-env": "^5.1.4",
"npm-run-all": "^4.1.2",
"react": "^16.3.1",
"react-dom": "^16.3.1",