This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
encryptAESGCM, | |
decryptAESGCM, | |
generateSecretKey, | |
base64UrlDecode, | |
base64UrlEncode | |
} from "./aes-crypto"; | |
describe("AES-GCM Encryption and Decryption", () => { | |
const secretKey = "VGVzdEtleTI1NiBiaXRzIG11c3QgYmUgMzIgYnl0ZXM="; // Base64 encoded 32 bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Encrypts an email address using AES-256 GCM. | |
* | |
* @param string $email The email address to encrypt. | |
* @param string $secretKeyBase64 The base64 encoded secret key (32 bytes when decoded). | |
* @return string The URL-safe base64 encoded string of the combined nonce and ciphertext. Returns an empty string on error. | |
* @throws Exception If the key is invalid or encryption fails. | |
*/ | |
function encryptEmailAESGCM(string $email, string $secretKeyBase64): string { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { ReactElement, ReactNode } from "react"; | |
import { I18nKey, i18n } from "./i18n"; | |
interface TransProps { | |
i18nKey: I18nKey; | |
text?: string; | |
[x: string]: ReactNode; | |
} | |
const Trans = ({ i18nKey, text, ...interpolationData }: TransProps) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
USAGE = <<~DOC | |
USAGE: | |
ruby json_csv_converter.rb <in_file> <separator(optional)> | |
EXAMPLES: | |
Convert JSON to CSV | |
$ ruby json_csv_converter.rb file.json | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto from 'crypto' | |
// inputs | |
const key = 'notsosecret' | |
const method = 'POST' | |
const url = 'https://example.com' | |
const timestamp = '2022-11-03T01:08:19.138Z' | |
const data = '{"data":{"partnerId":"1","tokenId":47210468}}' | |
// generate signature |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { firestore } from 'firebase-admin'; | |
import * as functions from 'firebase-functions'; | |
const region = 'europe-west1'; | |
const firestoreCollection = 'webhook-posts'; | |
export const httpBin = functions | |
.region(region) | |
.https.onRequest(async ({ headers, body }, response) => { | |
const data = { headers, body }; | |
await firestore().collection(firestoreCollection).doc().create(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recursiveRedact({ a: 1, b: { a: 1, b: 2 } }, new Set(['a'])) | |
// Result | |
// { | |
// "a": "[redacted]", | |
// "b": { | |
// "a": "[redacted]", | |
// "b": 2 | |
// } | |
// } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE | |
# In any local GitHub repository run | |
# $ github_open | |
github_open() { | |
local remotename="${@:-origin}" | |
local remote="$(git remote -v | awk '/^'"$remotename"'.*\(push\)$/ {print $2}')" | |
[[ "$remote" ]] || return | |
local user_repo="$(echo "$remote" | perl -pe 's/.*://;s/\.git$//')" | |
open "https://github.com/$user_repo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.ruby': | |
'def method_missing .. end': | |
'prefix': 'defmm' | |
'body': | |
''' | |
def method_missing(method_name, *arguments, &block) | |
if ${1}.respond_to?(method_name) | |
${1}.public_send(method_name, *arguments, &block) | |
else | |
super |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# USAGE: | |
# $ check_redirects --help | |
# or | |
# $ ruby check_redirects.rb --help | |
require 'bundler/inline' | |
gemfile do |
NewerOlder