Skip to content

Instantly share code, notes, and snippets.

@trmaphi
trmaphi / crypto-buffer.js
Created January 28, 2025 02:50 — forked from chris-rock/crypto-buffer.js
Encrypt and decrypt buffers in nodejs
// Part of https://github.com/chris-rock/node-crypto-examples
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
function encrypt(buffer){
var cipher = crypto.createCipher(algorithm,password)
var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]);
return crypted;
@trmaphi
trmaphi / metadata.json
Created January 23, 2025 11:55
NFA reward token
{
"name": "NFA REWARD TOKEN",
"symbol": "NFA",
"description": "Phi test token",
"image": "https://nfa.fund/icon.png",
"attributes": []
}
@trmaphi
trmaphi / vpn-compare.md
Created July 13, 2023 04:47
VPN compare for self-managed multi k8s cluster support service mesh
VPN IPsec OpenVPN WireGuard
Layer 3 4 4
Protocol IP UDP/IP UDP/IP
Topology site2site subnet, net30, p2p mesh
Multi cluster kubernetes Yes Not Found Yes
Self managed mulicluser No No Yes
Implementation (1) NotFound (2)

References:

@trmaphi
trmaphi / GNUPG_agent_forwarding.md
Created November 15, 2022 17:58 — forked from TimJDFletcher/GNUPG_agent_forwarding.md
GnuPG agent forwarding

Forward GnuPG agent from macOS to Linux

On the remote machine

Run gpg once as your to create the directory structure

gpg --list-keys

For headless systemd based hosts

@trmaphi
trmaphi / graphql-apollo-xray-error-formatter.js
Created January 4, 2021 04:28 — forked from mdlavin/graphql-apollo-xray-error-formatter.js
An Apollo Server formatError function that avoids "Converting circular structure to JSON" errors
// This is the attribute that continuation local storage uses to hold onto
// the current context. The value comes from https://github.com/othiym23/node-continuation-local-storage/blob/fc770288979f6050e4371c1e1b44d2b76b233664/context.js#L11
const CLS_CONTEXT_ATTRIBUTE = 'error@context';
// A formatError function that can be used with
// https://www.apollographql.com/docs/apollo-server/features/errors#for-the-client-response
function formatError (err) {
// The continuation-local-storage module attaches a context attribute to
// errors so that the context can be resolved from errors. The attribute
// is enumerable by default and so it gets included in GraphQL error
@trmaphi
trmaphi / tracing.ts
Last active January 7, 2021 03:53
Setup X-ray on Lambda
/// Setup tracing in a separate file
import * as AWSXRay from 'aws-xray-sdk-core';
// Configure the context missing strategy to do nothing
// https://docs.aws.amazon.com/lambda/latest/dg/nodejs-tracing.html
AWSXRay.setContextMissingStrategy(() => { });
// https://github.com/aws/aws-xray-sdk-node/issues/143
AWSXRay.captureAWS(require('aws-sdk'));
@trmaphi
trmaphi / x-ray-graphql.ts
Last active January 4, 2021 04:28
Tracing GraphQL resolvers with X-Ray
import traceResolvers from '@lifeomic/graphql-resolvers-xray-tracing';
// Apply tracing middleware if running Lambda environment
if (process.env.AWS_LAMBDA_FUNCTION_NAME) {
traceResolvers(schema);
}
const apolloServer = new ApolloServer({
schema,
context: contextFn,
@trmaphi
trmaphi / noti.sh
Created March 12, 2020 12:15
Notify slack incoming webhooks about current deployment
#!/usr/bin/env bash
TARGET=$(git describe --dirty --broken --all --long);
PROJECT=$(git config remote.origin.url |sed 's#.*\/\(.*\)\.git#\1#');
git pull && \
curl -i \
-H "Content-Type:application/json" \
-X POST \
-d "{\"text\": \"deployed \`${PROJECT}\` \`$TARGET\` to \`$1\` \"}" \
var AWS = require('aws-sdk');
var region = ''; // e.g. us-west-1
var domain = ''; // e.g. search-domain.region.es.amazonaws.com
var index = 'node-test';
var type = '_doc';
var id = '1';
var json = {
"title": "Moneyball",
"director": "Bennett Miller",