Skip to content

Instantly share code, notes, and snippets.

@ratpik
ratpik / isUUID.js
Last active May 4, 2017 09:55
Checks if input is a valid UUID (any version, includes nil and GUID) as per RFC 4122 - https://tools.ietf.org/html/rfc4122
// Fiddle - https://jsfiddle.net/ratpik/azf5a9bv/3/
var UUIDIndex = {0:8, 1:4, 2:4, 3:4, 4:12};
function isHex(h, index) {
if (UUIDIndex[index] !== _.size(h)) return false;
var a = parseInt(h, 16);
return !isNaN(a) &&
a.toString(16) === _.toLower(h) ||
_.join(_.times(_.size(h), _.constant(0)), '') === _.toLower(h);
@ratpik
ratpik / NodeHTTPStatusCodes.js
Last active October 9, 2017 10:30
List of Valid HTTP Response Codes in Node (as of node v6.11.4)
console.log(require('http').STATUS_CODES);
@ratpik
ratpik / parsePostmanCollection.js
Created October 11, 2017 06:46
Postman Collection SDK Example
var fs = require('fs'), // needed to read JSON file from disk
sdk = require('postman-collection'),
Collection = sdk.Collection,
Request = sdk.Request,
Item = sdk.Item,
ItemGroup = sdk.ItemGroup,
_ = require('lodash'),
myCollection,
requests = [],
dfs = function (item, requests) { // fn -> Depth first search
@ratpik
ratpik / users.js
Created May 1, 2018 07:46
User in Postman App
pm.models.user.find({}, (err, users) => {
users.forEach((user) => {
console.log(`User ID: ${user.id} \n Access Token: ${user.auth.access_token} \n Email: ${user.email}`);
});
});
@ratpik
ratpik / clear-redis.sh
Created May 1, 2018 07:47
Redis Delete all keys
./redis-cli -p 7777--raw keys "*" | xargs ./redis-cli -p 7777 del
@ratpik
ratpik / countUniqueInColumn2ofCSVFiles.sh
Created May 12, 2018 17:02
Split lines with Regex provided to awk
cat *.csv| awk -F "\"*,\"*" '{print $2}'|uniq|wc -l
@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
@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 / 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 / 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