Skip to content

Instantly share code, notes, and snippets.

module.exports = {
  presets: [
    [
      /**
       * We don't care about the these useless options as they aren't needed.
       *
       * https://babeljs.io/docs/babel-preset-env#bugfixes
       * https://babeljs.io/docs/babel-preset-env#spec
       * https://babeljs.io/docs/babel-preset-env#loose
@mridang
mridang / gist:0692a227e6e09fd0176bf9a77b93dc7f
Created October 15, 2024 12:14
Building a weappp 2024 Ed
* Nel
*Csp
*Health
*Version
*Req id
* Timing
* Problems
Csche control
Etag
Cors
@mridang
mridang / rxjs_fast_paginate.md
Last active October 15, 2024 06:06
rxjs_fast_paginate

I recently needed a blazing fast concurrent to fetch items from an API. Of course, I could use a combination of async-awaits and some cryptic code with promises and so I took a stab at doing this in rxjs.

import { Observable } from 'rxjs';

export function doPaginate<T>(
  fetchPage: (page: number) => Promise<{ totalRows: number; resultItems: T[] }>,
): Observable<T> {
@mridang
mridang / load_npm_ls_output.md
Last active October 11, 2024 03:01
Querying NPM packages using SQL

The following is an altenative way to do dependency analysis for Node projects but using SQL.

Note

This project is not intended to be comprehensive by any means but is simply a demonstration of what is possible.

The approach centers around reading the dependency tree using the the output of the npm ls command and loading it into SQLite.

@mridang
mridang / publish_npm_layer.md
Last active October 15, 2024 06:03
Publing NPM modules as Lambda layers
@mridang
mridang / emr-master-ip.sh
Created October 19, 2021 17:00
Helper command to fetch the IP address of the master node of running EMR cluster
#!/bin/bash
aws emr describe-cluster --cluster-id @1 | jq --raw-output '.Cluster .MasterPublicDnsName | sub("ip-(?<ip1>[0-9]*)-(?<ip2>[0-9]*)-(?<ip3>[0-9]*)-(?<ip4>[0-9]*).*$"; "\(.ip1).\(.ip2).\(.ip3).\(.ip4)")'
aws emr create-cluster --auto-scaling-role production-emr-auto-scaling --applications Name=Hadoop Name=Hive Name=Spark --bootstrap-actions '[{"Path":"s3://nosto-emr-bootstrap/sshkeys.sh","Name":"Add ssh keys"}]' --ebs-root-volume-size 20 --ec2-attributes '{"KeyName":"mridang","InstanceProfile":"production-emr","ServiceAccessSecurityGroup":"sg-025cd99e844eb8ee9","SubnetId":"subnet-de214af5","EmrManagedSlaveSecurityGroup":"sg-0548dc804984f9cf8","EmrManagedMasterSecurityGroup":"sg-0f5fc3a1f9be29054"}' --service-role production-emr-service --enable-debugging --release-label emr-6.2.0 --log-uri 's3://nosto-emr-logs/' --name 'MridangTest' --instance-groups '[{"InstanceCount":1,"EbsConfiguration":{"EbsBlockDeviceConfigs":[{"VolumeSpecification":{"SizeInGB":32,"VolumeType":"gp2"},"VolumesPerInstance":2}]},"InstanceGroupType":"CORE","InstanceType":"c5a.xlarge","Name":"Core - 2"},{"InstanceCount":1,"EbsConfiguration":{"EbsBlockDeviceConfigs":[{"VolumeSpecification":{"SizeInGB":32,"VolumeType":"gp2"},"VolumesPerInstance
#!/bin/sh
sha=$(shasum -b "$1" | awk '{print $1}')
url="https://search.maven.org/solrsearch/select?q=1:%22${sha}%22&rows=1&wt=json"
if curl -s -o json -L "$url"; then
gav=$(jq -r '.response.docs[0].g + ":" + .response.docs[0].a + ":" + .response.docs[0].v' json)
if [ "$gav" != "null" ]; then
cat gav
fi
rm -f json
install coreutils
install findutils --with-default-names
install gnu-indent --with-default-names
install gnu-sed --with-default-names
install gnutls
install grep --with-default-names
install gnu-tar --with-default-names
install gawk
install tree
install icdiff
@mridang
mridang / ImageBuilder.java
Created March 19, 2016 15:10
Gasflow Notification Icon Generator
package com.mridang.dashbar;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Typeface;
import android.os.Environment;