gene

JavaScript: Number.EPSILON and Number.MAX_SAFE_INTEGER

EPSILON The Number.EPSILON property represents the difference between 1 and the smallest floating point number greater than 1 > Number.EPSILON == Math.pow(2, -52) true Use Number.EPSILON to test floating point number equality. x = 0.2; y = 0.3; z = 0.1; equal = (Math.abs(x – y + z) < Number.EPSILON); https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON MAX_SAFE_INTEGER & MIN_SAFE_INTEGER The MAX_SAFE_INTEGER constant has a …

JavaScript: Number.EPSILON and Number.MAX_SAFE_INTEGER Read More »

Non-cryptographic Hash Functions

See: List of non-cryptographic hash functions Pearson hashing Pearson hashing is a hash function designed for fast execution on processors with 8-bit registers. This hash function is a CBC-MAC that uses an 8-bit substitution cipher implemented via the substitution table. An 8-bit cipher has negligible cryptographic security, so the Pearson hash function is not cryptographically strong, but it is useful for implementing hash tables or as a data integrity check …

Non-cryptographic Hash Functions Read More »

Python: pearson_hashing.py

$ cat pearson_hashing.py from random import shuffle example_table = list(range(0, 256)) shuffle(example_table) def hash8(message, table): hash = len(message) % 256 for c in message: #hash = table[(hash+ord(c)) % 256] print(f’for c=\'{c}\’, ord(c)={ord(c)}: {hash} ^ {ord(c)} => {hash ^ ord(c)} and table[hash ^ ord(c)] = {table[hash ^ ord(c)]}’) hash = table[hash ^ ord(c)] return hash if …

Python: pearson_hashing.py Read More »

Bloom Filters in Redis

Probabilistic (P11C) data structure https://github.com/guyroyse/understanding-probabilistic-data-structures/blob/master/code/bloom-filter/javascript/bloom.js https://github.com/guyroyse/understanding-probabilistic-data-structures/blob/master/slides/understanding-probabilistic-data-structures.pdf

AWS CDK Cheat Sheet

Documentation https://docs.aws.amazon.com/cdk/latest/guide/stack_how_to_create_multiple_stacks.html https://docs.aws.amazon.com/cdk/latest/guide/get_context_var.html https://docs.aws.amazon.com/cdk/latest/guide/testing.html CDK Constructs Library TypeScript API Reference Best Practices github.com/kevinslin/open-cdk Examples github.com/kolomied/awesome-cdk github.com/cloudcomponents/cdk-constructs/tree/master/examples github.com/aws-samples/aws-cdk-examples github.com/blndspt/aws-full-stack-template github.com/awslabs/aws-full-stack-template github.com/aws-samples/aws-bookstore-demo-app bobbyhadz.com/blog/how-does-aws-cdk-work bobbyhadz.com/blog/cdk-constructs-tutorial bobbyhadz.com/blog/aws-cdk-identifiers bobbyhadz.com/blog/how-to-use-context-aws-cdk bobbyhadz.com/blog/aws-cdk-parameters-example bobbyhadz.com/blog/aws-cdk-vpc-example bobbyhadz.com/blog/aws-cdk-security-group-example Some Gotchas When synthesizing an AWS CDK stack, I get the message –app is required either in command-line, in cdk.json or in ~/.cdk.json This message usually means that you …

AWS CDK Cheat Sheet Read More »

Downloading Files using Google Drive API

See: Google Cloud SDK (gcloud CLI) Create project in https://console.cloud.google.com Enable Google Drive API in console https://developers.google.com/drive/api/v3/enable-drive-api Using gcloud cli: gcloud doesn’t provide command to access google drive. Install gdrive https://github.com/prasmussen/gdrive After entering verification code from browser: -q, –query <query> https://developers.google.com/drive/api/v3/search-shareddriveshttps://developers.google.com/drive/api/v3/ref-search-terms#operators –order <sortOrder> OrderBy sets the optional parameter “orderBy”: A comma-separated list of sort keys. …

Downloading Files using Google Drive API Read More »

Google Cloud SDK (gcloud CLI)

Installation options Home Brew: https://formulae.brew.sh/cask/google-cloud-sdk Official: https://cloud.google.com/sdk/docs/install gcloud CLI gcloud init – initialize or reinitialize gcloud See: https://cloud.google.com/sdk/docs/initializing gcloud auth – manage credentials  gcloud auth login – authorize gcloud to access Google Cloud Platform with Google user credentials gcloud auth list – lists credentialed accounts gcloud auth activate-service-account – authorize access to Google Cloud Platform …

Google Cloud SDK (gcloud CLI) Read More »