Skip to content

Instantly share code, notes, and snippets.

View pulasthibandara's full-sized avatar

Pulasthi Bandara pulasthibandara

  • Auckland, New Zealand
View GitHub Profile
@pulasthibandara
pulasthibandara / kinesis_async_logging.py
Created March 11, 2023 22:44
Python Kinesis async side-channel output
from dataclasses import dataclass, asdict
import json
from threading import Thread
from queue import Empty, Queue
from time import sleep, time
from types import TracebackType
from typing import List, Literal, Optional, Type, Union
from mypy_boto3_kinesis import KinesisClient
from mypy_boto3_kinesis.type_defs import PutRecordsRequestEntryTypeDef
@pulasthibandara
pulasthibandara / .p10k.zsh
Last active October 20, 2023 02:55
Zsh Setup
# Generated by Powerlevel10k configuration wizard on 2021-10-11 at 14:58 NZDT.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 54401.
# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 24h time,
# 2 lines, disconnected, no frame, compact, few icons, concise, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
# Tip: Looking for a nice color? Here's a one-liner to print colormap.
@pulasthibandara
pulasthibandara / aws_lambda_java_opts.md
Created January 29, 2021 01:24
A list of default `JAVA_OPTS` passed to AWS Lambda on different memory configurations and java versions.
  • java 8
  • Java 8 (Corretto)
  • Java 11 (Corretto)
128mb
[-XX:MaxHeapSize=111412k, -XX:MaxMetaspaceSize=13107k, -XX:ReservedCodeCacheSize=6553k, -Xshare:on, -XX:-TieredCompilation, -XX:+UseSerialGC, -Djava.net.preferIPv4Stack=true]
[-XX:MaxHeapSize=91750k, -XX:MaxMetaspaceSize=13107k, -XX:ReservedCodeCacheSize=6553k, -XX:+UseSerialGC, -Xshare:on, -XX:-TieredCompilation, -Djava.net.preferIPv4Stack=true]
[-XX:MaxHeapSize=111412k, -XX:MaxMetaspaceSize=13107k, -XX:ReservedCodeCacheSize=6553k, -XX:+UseSerialGC, -Xshare:on, -XX:SharedArchiveFile=/var/lang/lib/server/runtime.jsa, -XX:-TieredCompilation, -Djava.net.preferIPv4Stack=true]
@pulasthibandara
pulasthibandara / StripSuffix.scala
Created April 27, 2020 20:26
Scala HList strip suffix
import shapeless.{ ::, DepFn2, HList, HNil }
import scala.annotation.implicitNotFound
/**
* Returns {Out = B} after stripping suffix {A} from {BA}
* {{{
* val a: Int :: String :: HNil 1 :: "a" :: HNil
* val ba: Boolean :: String :: Int :: String :: HNil = true :: "b" :: 1 :: "a" :: HNil
* val b: Boolean :: String :: HNil = StripSuffix[Int :: String :: HNil, Boolean :: String :: Int :: String :: HNil](a, ba)
* }}}
@pulasthibandara
pulasthibandara / ShapelessNestedCoProduct.scala
Created April 15, 2020 21:24
Enables building a coproduct out of a higher kinded type where the type member is type that can be a coproduct.
import shapeless.ops.coproduct.RuntimeInject
import shapeless.{ :+:, CNil, Coproduct, Generic, Inl, Inr }
import scala.language.higherKinds
/**
* Enables building a coproduct out of a higher kinded type where the type member is type
* that can be a coproduct.
*
* for example:
@pulasthibandara
pulasthibandara / postgres_queries_and_commands.sql
Created December 6, 2017 23:46 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@pulasthibandara
pulasthibandara / _nz-phone-regex.md
Last active November 15, 2016 21:14
Regex for formatting NZ telephone numbers

regex for formatting NZ numbers

devides a given string of numbers. work with php, js, python

if an 0800 number:

(0800) 123 123 format

normal number: