Skip to content

Instantly share code, notes, and snippets.

@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;
@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 / 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 / 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
//
// 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 / Install-php-mysql-apache-on-osx-with-brew.md
Last active October 11, 2018 11:42 — forked from GabLeRoux/Install-php-mysql-apache-on-osx-with-brew.md
Detailed steps to install PHP, MySQL, Apache and some usefull extensions such as xDebug on a mac running Mac Os X. Also included: PostgreSQL.

Install PHP, MySQL, PostgreSQL, Apache and xDebug on a Mac

You should have some tools installed like Homebrew, a text editor such as Sublime Text and it's subl command line app inside a bin folder and some basic terminal knowledge.

This gist is a more detailed version of niepi's gist with things that worked for me. It may help someone :)

Install PHP

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl
@handleman
handleman / Install Composer to use MAMP's PHP.md
Created October 11, 2018 07:04 — forked from kkirsche/Install Composer to use MAMP's PHP.md
How to install Composer globally using MAMP's PHP

##Create an alias to MAMP's PHP installation

To do this, we can simply create an alias for our bash profile. We'll be doing this is nano, though you can do it in vim or a number of other editors as well.

Within the terminal, run:

nano ~/.bash_profile

This will open nano with the contents, at the top in a blank line add the following line:

@handleman
handleman / findOffsetTop
Created June 28, 2016 09:26 — forked from waaronking/findOffsetTop
Find the offsetTop of any item by recursively looking at the parent element until parent offset is 0
/* Finds the total offset of an item inside a window */
var findOffsetTop = function(el) {
var offset = el.offsetTop;
if (el.parentNode.offsetTop !== 0) {
offset += findOffsetTop(el.parentNode);
}
return offset;
};
@handleman
handleman / grunt.copy.includeFile.js
Created June 21, 2016 16:15 — forked from purtuga/grunt.copy.includeFile.js
A Grunt Copy process function to embed content of files into other files.
/**
* includeFile() - embeds a file content within another. Meant to be
* used from the copy task as a 'processContent' function. The following
* tokens can be used in files: <br>
*
* - BUILD_INCLUDE('file')
* - /* BUILD_INCLUDE('file') *\x47
* - &lt;!-- BUILD_INCLUDE("file") --&gt;
*
* In addition, options can be added to the token above that further
@handleman
handleman / anchor_smooth_scroll.js
Last active August 29, 2015 14:27 — forked from justinmc/anchor_smooth_scroll.js
Anchor Smooth Scroll - Angular Directive
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
replace: false,