Skip to content

Instantly share code, notes, and snippets.

View samkahchiin's full-sized avatar
🎯
Focusing

Sam Kah Chiin samkahchiin

🎯
Focusing
View GitHub Profile
{
"keys": [
{
"use": "sig",
"kty": "RSA",
"n": "x0D1Vs1ZfkP3bHVU9XAV13dCICcmPKPX3-iH1oFV_HHQ5zdtlHpkfa5zdyrxD9ZkjZMuNSYLDe-be8G1co1oLkqrrOd6nz6NKRWvb1abH0CDxmafCCojYAbTvK5jMQo4SNsIQNwYbuyujoCJO3mQPQQ0gDezZXHJOquRb51XdYTfm4nuRVGuN3ipKoVH-jxIawApdkQ3wlvmrCbm6dqijTgQ9Ee1Pna24IPHot1pWvciYNOJi1uiGTmpzbq61h3XSA7Mci2EIlXFh3mGVaKZynXCsNw0ILWSe1O_3imgvXn2S15Kw4BegpyXP9G_RIpknA0VF0zCSpNO5sv82hQMzQ",
"e": "AQAB",
"kid": "BpUurJFrqamJLBwfLAXJ",
"alg": "RS256"
}
{
"keys": [
{
"kty": "RSA",
"e": "AQAB",
"use": "sig",
"kid": "1bb9605c36e98e30117a69517569386830202b2d",
"n": "pAbfKmQ1ljT6yZcrdxaJxqsB7EupbBFcCLiMzmuFQMuk3y_g-vVPR8ZwTJbalwBxD-vUPmxmZAVok_iNthw1mnW0POg3kEwtl1qambgNKlaTeO8S3D-KGlUNV6bU-JXbyquds7v8bQjmIQ5oXhwIQt6x55bEyZTOCQDl3ZHy1XxeBWFyiPUXXnqkO51EFeVNiMi8Ihue16UY_lIizhivl2C_UwJ0Ymx9eWJ-nefPBo7Lr_fIxh81NaLMB6t5L8123RSIaaIcR_r1H_ZbEe9VNTfnGdYS3A0u-pNS_bm5jRSBo1qt01OFu0xEsjcO7-NESTBr8w8SUqGK86tg9oQz5w",
"alg": "RS256"
},
@samkahchiin
samkahchiin / generate-address.js
Created November 15, 2022 09:03
Generate Wallet Address
var ethers = require('ethers');
var crypto = require('crypto');
const generateAddress = async () => {
var id = crypto.randomBytes(32).toString('hex');
const privateKey = "0x"+id;
console.log("SAVE BUT DO NOT SHARE THIS:", privateKey);
// for provider
const provider = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/polygon_mumbai");
unless Rails.env.test?
# SAMPLING_RATE = 0.10
OpenTelemetry::SDK.configure do |c|
c.service_name = ENV.fetch('CLUSTER_NAME', "project-#{Rails.env}")
c.id_generator = OpenTelemetry::Propagator::XRay::IDGenerator
# The X-Ray Propagator injects the X-Ray Tracing Header into downstream calls
c.propagators = [OpenTelemetry::Propagator::XRay::TextMapPropagator.new]
@samkahchiin
samkahchiin / cdn-serve.js
Created May 26, 2022 08:16
Cloudflare worker (Serve CDN)
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event));
});
async function handleRequest(event) {
const request = event.request;
// Block all methods except GET and HEAD
if (request.method === "GET" || request.method === "HEAD") {
let response = await serveAsset(event);
// Set error code if error
@samkahchiin
samkahchiin / github-notification.sh
Created November 26, 2021 03:04
Github Notification cronjob
#!/bin/bash
USER=$(git config user.email)
TOKEN=$(security find-generic-password -s github_token -w)
echo $USER
echo $TOKEN
echo 'Hi'
curl -s -u $USER:$TOKEN https://api.github.com/notifications \
@samkahchiin
samkahchiin / cron.sh
Created November 26, 2021 03:02
brew cronjob
#!/bin/bash
# Update brew
brew update
# Upgrade all brew packages
brew upgrade
# Remove old versions of packages
brew cleanup
@samkahchiin
samkahchiin / rails http status codes
Created October 29, 2021 10:15 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@samkahchiin
samkahchiin / README.md
Last active September 13, 2021 07:37
README.md template
@samkahchiin
samkahchiin / closeAllTabs.applescript
Last active September 12, 2021 09:11
AppleScript to close all tabs
tell window 1 of app "google chrome" to close tabs whose id is not (get id of active tab)