Skip to content

Instantly share code, notes, and snippets.

drmikecrowe

Block or report user

Report or block drmikecrowe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@doublemarked
doublemarked / !Fragmenting Loopback Models.md
Last active May 2, 2016
Boot script for fragmented loading of Loopback models
View !Fragmenting Loopback Models.md

Fragmenting Loopback Models

Hey! I've bundled this approach into a component: https://github.com/doublemarked/loopback-component-model-fragments

This boot script will load module components on app initialization. Stick this file in server/boot. Components are looked for in the directory common/models/model-name. The script will load recursively any script from that directory, passing it the Model handle as a parameter (just like model.js loads). Conveniently, since this is occuring during the boot phase, those model scripts will execute at a later phase than model.js, meaning PersistedModel is already initialized and all peer model handles are already usable. Note - it's necessary for you to still maintain a model.js file for Loopback to load the model at all.

@Yimiprod
Yimiprod / difference.js
Last active Mar 28, 2020
Deep diff between two object, using lodash
View difference.js
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@keo
keo / bootstrap.sh
Last active Mar 4, 2020
Setup encrypted partition for Docker containers
View bootstrap.sh
#!/bin/sh
# Setup encrypted disk image
# For Ubuntu 14.04 LTS
CRYPTFS_ROOT=/cryptfs
apt-get update
apt-get -y upgrade
apt-get -y install cryptsetup
@joshcarr
joshcarr / bookmarklet-boilerplate.js
Last active Aug 29, 2015
bookmarklet boilerplate
View bookmarklet-boilerplate.js
javascript:(function(){
// avoid the bookmarklet activating more than once
if (window.MyNamespace) {
return;
}
window.MyNamespace = { };
var version = 1,
script = document.createElement('script');
@neonexus
neonexus / OpenSSL Commands.md
Last active May 17, 2016
AWS ELB OpenSSL commands list
View OpenSSL Commands.md

Generate KEY and CSR:

openssl req -new -newkey rsa:2048 -nodes -keyout DOMAIN.key -out DOMAIN.csr

Echo the KEY in PEM format:

openssl rsa -in DOMAIN.key -outform PEM

Echo the CRT in PEM format:

@carlessistare
carlessistare / tuning_nginx_nodejs
Created Sep 2, 2013
Tuning Nginx for heavy loading with nodejs as upstream. Short requests and a lot of concurrence.
View tuning_nginx_nodejs
# This number should be, at maximum, the number of CPU cores on your system.
# (since nginx doesn't benefit from more than one worker per CPU.)
worker_processes 8;
# Determines how many clients will be served by each worker process.
# (Max clients = worker_connections * worker_processes)
# "Max clients" is also limited by the number of socket connections available on the system (~64k)
# run ss -s and u'll see a timewait param
# The reason for TIMED_WAIT is to handle the case of packets arriving after the socket is closed.
@st4lk
st4lk / root_logger_settings.py
Last active Jan 4, 2020
Python logging settings for root logger
View root_logger_settings.py
"""
Settings for root logger.
Log messages will be printed to console and also to log file (rotated, with
specified size). All log messages from used libraries will be also handled.
Three approaches for defining logging settings are used:
1. using logging classes directly (py25+, py30+)
2. using fileConfig (py26+, py30+)
3. using dictConfig (py27+, py32+)
Choose any variant as you like, but keep in mind python versions, that
You can’t perform that action at this time.