Skip to content

Instantly share code, notes, and snippets.

@prithvihv
prithvihv / state_pipeline_cost.hs
Last active May 13, 2021 06:44
state pipeline cost calculation
s3CostPerGB:: Double
s3CostPerGB = 0.025 -- per GB
s3SizeWrittenPerDay :: Double
s3SizeWrittenPerDay = 23 -- GB
s3PricePerSession:: Double -- this uses the assumption that of session per day
s3PricePerSession = pricePerDay/requestPerDay
where
pricePerDay = s3SizeWrittenPerDay * s3CostPerGB
@prithvihv
prithvihv / WSL-ssh-server.md
Created May 16, 2021 06:54 — forked from dentechy/WSL-ssh-server.md
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
-- creating fake table for testing
CREATE TABLE products(product_id serial,
product_name text,
price numeric(11,2),
group_id integer
);
INSERT INTO products(product_name, price, group_id)
VALUES
let
pathToFile = if pkgs.stdenv.isLinux then
"./location1"
else
"./location2";
someFile = import pathToFile;
in rec {
somePkgsWithPlatformSupport = someFile;
}
// call this function as: PrintInfoAboutClass(classOf[ArrayUtils])
def PrintInfoAboutClass(cl: Class[_]) = {
val cName = cl.getName()
var p = cl.getPackage()
val title = p.getImplementationTitle()
val vendorVersion = p.getImplementationVersion()
val implVendor = p.getImplementationVendor()
println(s"$cName\n\t$title\n\t$vendorVersion\n\t$implVendor")
}
# to get shasum during your nix build, add perl package
with import <nixpkgs> { };
let
in pkgs.mkShell rec {
name = "dev-tools";
nativeBuildInputs = [
perl
@prithvihv
prithvihv / seat.sql
Last active July 24, 2021 08:47
(database locking for update) booking seat for x, database handling
CREATE TABLE t_flight AS
SELECT * FROM generate_series(1, 200) AS id;
// concurrently we can call
SELECT * FROM t_flight LIMIT 2 FOR
UPDATE SKIP LOCKED;
// first time: 1, 2
// second time: 3, 4
// ....