Skip to content

Instantly share code, notes, and snippets.

View alexanderankin's full-sized avatar

David Ankin alexanderankin

View GitHub Profile
@alexanderankin
alexanderankin / dataclasses_odata_azure.py
Created August 13, 2023 14:46
using vanilla python to parse azure rest api stuff to dataclasses
import dataclasses
import json
def default_dataclass_init_method(self, kwargs):
for fi in dataclasses.fields(self):
value = kwargs.get(fi.name, fi.default)
if value == dataclasses.MISSING:
if fi.default_factory == dataclasses.MISSING:
raise ValueError('missing field ' + fi.name + ' and no default/factory')
import collections
class ReadOnlyDict(collections.UserDict):
def __init__(self, data: dict):
super().__init__()
self.data = data
def __setitem__(self, key, item):
raise TypeError
package org.example;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.server.RouterFunction;
@alexanderankin
alexanderankin / ConfigurationPropertiesDemoApp.java
Last active July 6, 2023 09:32
simple ConfigurationProperties demo
// cat > src/main/java/org/example/App.java <<'EOF'
package org.example;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
To create a new subscription in Azure using the Azure Resource Manager (ARM) provider in Terraform, you need to perform the following steps:

Configure the AzureRM provider: In your Terraform configuration file (usually main.tf), add the AzureRM provider block and specify the necessary authentication details. This typically includes the subscription_id, client_id, client_secret, and tenant_id. Here's an example:
hcl
Copy code
provider "azurerm" {
  subscription_id = "<subscription_id>"
  client_id       = "<client_id>"
  client_secret   = "<client_secret>"
import com.google.zxing.BarcodeFormat;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import lombok.SneakyThrows;
import reactor.core.publisher.Mono;
import reactor.netty.DisposableServer;
import reactor.netty.http.server.HttpServer;
import java.io.ByteArrayOutputStream;
import org.gradle.api.internal.tasks.AbstractTaskDependency
import org.gradle.api.plugins.jvm.JvmTestSuite
static String printDeps(Task task) {
StringBuilder buffer = new StringBuilder(50)
printDeps(task, buffer, "", "")
return buffer.toString()
}
@SuppressWarnings('ConfigurationAvoidance')
import lombok.*;
import lombok.experimental.Accessors;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
let levels = {
error: 200,
warn: 300,
info: 400,
debug: 500,
trace: 600,
}
let level = levels['info'];

to run this benchmark, go to https://jsbench.me and copy the below inputs:

Setup Javascript:

let random = () => (Math.random() + 1).toString(36).substring(7);
let dummyArray = Array(10000).fill(null).map(random)
let dummySet = new Set(Array(10000).fill(null).map(random))