Skip to content

Instantly share code, notes, and snippets.

@ratpik
ratpik / lru.js
Created June 14, 2020 15:51
LRUCache - Basic Implementation
const assert = require('assert')
let LRUCache = function (capacity) {
this.capacity = capacity;
this.cache = {};
this.head = null;
this.tail = null;
this.size = 0;
};
@ratpik
ratpik / postgres_timestamp_range_query.sql
Created November 17, 2020 14:42
Timestamp Range Query MySQL
select * from mytable where category LIKE 'search%' AND client_timestamp BETWEEN timestamp '2020-11-17T00:00:00' AND timestamp '2020-11-18T09:59:29'
@ratpik
ratpik / launch-with-nvs.json
Last active August 24, 2022 13:12
VS Code Node JS Mocha Debug Config
// As of 1st Feb 2022, the VSCode JS Debugger stopped detecting the node version selected using NVM
// Had to install and use NVS
// export NVS_HOME="$HOME/.nvs"
// git clone https://github.com/jasongin/nvs "$NVS_HOME"
// . "$NVS_HOME/nvs.sh" install
// nvs use 14
// Based on the comments here: https://github.com/microsoft/vscode/issues/133521#issuecomment-956108829
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
@ratpik
ratpik / generate_password.sh
Created April 25, 2021 16:49
Generate passwords command line
openssl rand -base64 32
date +%s | sha256sum | base64 | head -c 32 ; echo
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
@ratpik
ratpik / inheritance.yaml
Created January 21, 2022 12:46
JSON Schema Examples
#Reference - https://github.com/json-schema-org/json-schema-spec/issues/348#issuecomment-322940347
folderDeleted:
allOf:
- $ref: '#/components/schemas/folderCommon'
properties:
deletedCollectionItems:
type: array
items:
$ref: '#/components/schemas/collectionItem'
@ratpik
ratpik / mysql_local.sh
Created January 27, 2022 10:30
Re-installing MySQL 5.7 Mac OSX
#List all instances of MySQL that exists by running
brew services
# Remove each instance by running
brew uninstall <instance_name>
#Delete the MySQL directory in /usr/local/var/mysql:
rm -rf /usr/local/var/mysql
# Might need to run brew update here if brew has not been updated for a while