Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@handleman
handleman / gist:592e5fe7adda8da98a046e6ffc7cea1c
Last active March 6, 2019 13:23 — forked from sgergely/gist:3793166
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@handleman
handleman / pre-commit
Created June 4, 2020 08:21 — forked from jiskanulo/pre-commit
Git pre-commit hook: detect file size over 100MB
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
# Redirect output to stderr.
@handleman
handleman / jq to filter by value.md
Last active September 15, 2020 15:26 — forked from ipbastola/jq to filter by value.md
JQ to filter JSON by value

JQ to filter JSON by value and produce new json file with filtered data

Syntax: cat <filename> | jq -c '[.[] | select( .<key> | contains("<value>"))]' > <path_to_new_file.json>

Example: To get json record having _id equal 611

cat my.json | jq -c '[.[] | select( ._id | contains(611))]' > ./myProject/jsons/filtered.json

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@handleman
handleman / hero.ts
Created March 30, 2021 14:10 — forked from brennanMKE/hero.ts
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;