Skip to content

Instantly share code, notes, and snippets.

@anjankow
anjankow / string_values_test.go
Last active August 12, 2023 10:28
UpdateStringValues of all struct fields (including nested fields) using reflection + benchmark for performance comparison
package reflectplayground
import (
"errors"
"fmt"
"reflect"
"reflect-playground/testdata"
"testing"
"github.com/stretchr/testify/assert"
@anjankow
anjankow / generate_big_struct.py
Created August 12, 2023 08:32
To generate a BigStruct in Go with a desired number of fields + a function to update all its (nested) values
import sys
'''
Usage: generate_big_struct.py <fields_num>
For fields_num = 2 outputs:
--- file big_struct2.go ---
package testdata
@anjankow
anjankow / sawtooth_event_listener.rs
Created April 26, 2023 12:06
Event listener for Hyperledger Sawtooth blockchain, using zmq and sawtooth_sdk
// [dependencies]
// protobuf = "2.23"
// sawtooth-sdk = "0.5.2"
// zmq = "0.9.0"
// needed for write_to_bytes() method
use protobuf::Message;
const DEFAULT_VALIDATOR_ENDPOINT: &str = "tcp://validator:4004";
@anjankow
anjankow / exec_on_each_struct_field.go
Created March 15, 2023 20:04
Calling an interface function on each field of a struct in Go
package demo_test
import (
"errors"
"fmt"
"reflect"
"testing"
"github.com/stretchr/testify/require"
)
@anjankow
anjankow / set_azure_adb2c_custom_user_attributes.go
Created July 4, 2022 20:21
Setting Azure AD B2C custom user attributes
/*****
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
@anjankow
anjankow / get_azure_adb2c_user_attributes.go
Last active July 4, 2022 19:57
Getting custom Azure AD B2C user attributes
/*****
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
@anjankow
anjankow / access_token_azure_adb2c.go
Last active July 4, 2022 19:24
Getting an access token from Azure AD B2C using client's secret
/*
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
@anjankow
anjankow / permutation_generator.ipynb
Created May 23, 2019 14:43
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anjankow
anjankow / recursive_permutation.ipynb
Created May 23, 2019 14:08
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anjankow
anjankow / simple_generator.ipynb
Created May 22, 2019 14:19
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.