Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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 / docker-compose.yml
Created January 18, 2020 09:46
Linting MySQL
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
version: '3.7'
# Define services
services:
# App backend service
index-digest:
image: macbre/index-digest:latest
# Configuration for building the docker image for the backend service
@ratpik
ratpik / keybase.md
Created August 1, 2019 16:47
Keybase

Keybase proof

I hereby claim:

  • I am ratpik on github.
  • I am pmandrek (https://keybase.io/pmandrek) on keybase.
  • I have a public key ASCGIZecGSKe3KKsspNk0kS58-Ce8AP-TPBtHLswDy6IhQo

To claim this, I am signing this object:

@ratpik
ratpik / create_user.sql
Last active July 7, 2023 07:16
AWS MySQL RDS create user and grant access
## View all users who can connect to this database
SELECT `user` FROM `mysql.user`;
## Create a new user in MySQL/AWS MySQL RDS
CREATE USER 'yourusername'@'%' IDENTIFIED BY 'yourpassword';
## List the operations that are permitted for this user
SHOW GRANTS FOR 'yourusername'@'%';
-> GRANT USAGE ON *.* TO 'yourusername'@'%' (Explanation - https://stackoverflow.com/questions/2126225/why-is-a-grant-usage-created-the-first-time-i-grant-a-user-privileges)
@ratpik
ratpik / tags.sh
Created March 5, 2019 04:40
Git List Tags with Date, Message
git for-each-ref --format="%(refname:short) %(taggerdate) %(subject) %(body)" refs/tags