Skip to content

Instantly share code, notes, and snippets.

# This script does codegen for the facebook plugin.
# It codegens both the rest client and the cloudquery table and fetcher.
# It requires cloning https://github.com/facebook/facebook-business-sdk-codegen and using the json specs therein.
# It is a little primitive - only codegens a single resource at a time, and user needs to point to the relevant json file.
import sys
import re
import json
from typing import List, Dict, Optional
import io
@shimonp21
shimonp21 / gist:70c0a3cceaeab3f054e76c2846810b3e
Created January 10, 2023 09:52
generate_OracleClients.py
# Outputs an `OracleClients` struct, and intialization code for the struct.
# To be used with one of `--imports`, `--initialization`, or `--struct` flags.
#
# import "github.com/oracle/oci-go-sdk/v65/core"
# import "github.com/oracle/oci-go-sdk/v65/identity"
# ...
# type OracleClients struct {
# IdentityClient *identity.IdentityClient
# ComputeClient *core.ComputeClient
# NetworkClient *core.VirtualNetworkClient
@shimonp21
shimonp21 / golang_inheritance.go
Created December 25, 2022 15:37
golang struct inheritance
package main
import (
"fmt"
)
type Parent struct {
Num int
}
@shimonp21
shimonp21 / refactor.py
Last active December 25, 2022 15:38
refactor.py
# This script needs to be used on codegen recipe files.
# It refactors the codegen resources to use r"TableDefinition: codegen.TableDefinition{" for the fields
# inherited from the codegen.TableDefinition embedded struct.
# This is needed because of a golang limitation: https://gist.github.com/shimonp21/8907b859d60ec40e932172c0f21fa636
import sys
import re
import os
from pathlib import Path
# I refactored these manually
package main
import "math/rand"
const BigNumber = 1000
func main() {
m := make(map[int]int)
go mapWriter(m)