Skip to content

Instantly share code, notes, and snippets.

@a6b8
a6b8 / objectToKeyPaths.js
Last active July 23, 2023 22:08
Convert object to KeyPaths, and retrieve value by keyPath
function objectToKeyPaths( { data, parentKey='', separator='__' } ) {
const result = Object
.entries( data === undefined || data === null ? {} : data )
.reduce( ( acc, [ key, value ], index ) => {
const currentKey = parentKey ? `${parentKey}${separator}${key}` : key;
if( typeof data[ key ] === 'object' && !Array.isArray( data[ key ] ) ) {
const _next = objectToKeyPaths( {
'data': data[ key ],
'parentKey': currentKey,
separator
import {
Field,
SmartContract,
state,
State,
method,
} from 'snarkyjs';
export class Square extends SmartContract {
@a6b8
a6b8 / en-and-decrypt.js
Last active July 17, 2023 11:13
en/decrypt string
const crypto = require( 'crypto' )
const Cryption = class Cryption {
#state
constructor() {
this.config = {
'algorithm': 'aes-256-cbc'
@a6b8
a6b8 / base58-regexs.txt
Last active July 6, 2023 14:14
Satoshis Base58
^B62[a-km-zA-HJ-NP-Z1-9]{52}$
@a6b8
a6b8 / airtable-make.js
Created June 27, 2023 10:03
Airtable - Send webhook request to make
const webhookUrl = "https://..."
const { recordId } = input.config()
const response = await fetch( `${webhookUrl}?recordId=${recordId}` )
console.log( response.status )
@a6b8
a6b8 / easyAirtable.rb
Created April 13, 2023 02:13
Get Airtable Table
require "uri"
require "net/http"
require 'active_support/core_ext/hash/indifferent_access'
require 'json'
class EasyAirtable
def initialize()
@config = {
url: 'https://api.airtable.com/v0/'
@a6b8
a6b8 / htmlColors.js
Last active April 11, 2023 15:08
All Browser supported colors as json object
const htmlColors = {
'AliceBlue': '#F0F8FF', 'AntiqueWhite': '#FAEBD7',
'Aqua': '#00FFFF', 'Aquamarine': '#7FFFD4',
'Azure': '#F0FFFF', 'Beige': '#F5F5DC',
'Bisque': '#FFE4C4', 'Black': '#000000',
'BlanchedAlmond': '#FFEBCD', 'Blue': '#0000FF',
'BlueViolet': '#8A2BE2', 'Brown': '#A52A2A',
'BurlyWood': '#DEB887', 'CadetBlue': '#5F9EA0',
'Chartreuse': '#7FFF00', 'Chocolate': '#D2691E',
'Coral': '#FF7F50', 'CornflowerBlue': '#6495ED',
@a6b8
a6b8 / nokogiri_rss_generator.rb
Last active April 11, 2023 13:07
Simple Nokogiri RSS Generator
require 'nokogiri'
require 'time'
def generateAtomFeed( data: nil )
builder = Nokogiri::XML::Builder.new( encoding: 'utf-8' )
builder.feed(
'xmlns': 'http://www.w3.org/2005/Atom',
'xmlns:dc': 'http://purl.org/dc/elements/1.1/'
) do | root |
@a6b8
a6b8 / youtubeOwnData.js
Created April 3, 2023 20:27
Download Own Youtube Data
const fs = require( 'fs' )
const process = require( 'process' )
const path = require( 'path' )
const { authenticate } = require( '@google-cloud/local-auth' )
const { google } = require( 'googleapis' )
const moment = require( 'moment' )
const YoutubeOwnData = class YoutubeOwnData {
constructor() {
@a6b8
a6b8 / test.json
Last active March 22, 2023 06:46
{"type":"node","id":"0","labels":["User"],"properties":{"born":"2015-07-04T19:32:24","name":"Adam","place":{"crs":"wgs-84","latitude":13.1,"longitude":33.46789,"height":null},"age":42,"male":true,"kids":["Sam","Anna","Grace"]}}
{"type":"node","id":"1","labels":["User"],"properties":{"name":"Jim","age":42}}
{"type":"node","id":"2","labels":["User"],"properties":{"age":12}}
{"id":"0","type":"relationship","label":"KNOWS","properties":{"since":1993,"bffSince":"P5M1DT12H"},"start":{"id":"0","labels":["User"]},"end":{"id":"1","labels":["User"]}}