Skip to content

Instantly share code, notes, and snippets.

@st4lk
st4lk / root_logger_settings.py
Last active February 15, 2024 14:16
Python logging settings for root logger
"""
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
@carlessistare
carlessistare / tuning_nginx_nodejs
Created September 2, 2013 20:34
Tuning Nginx for heavy loading with nodejs as upstream. Short requests and a lot of concurrence.
# 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.
@neonexus
neonexus / OpenSSL Commands.md
Last active May 17, 2016 14:24
AWS ELB OpenSSL commands list

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:

@joshcarr
joshcarr / bookmarklet-boilerplate.js
Last active August 9, 2023 08:51
bookmarklet boilerplate
javascript:(function(){
// avoid the bookmarklet activating more than once
if (window.MyNamespace) {
return;
}
window.MyNamespace = { };
var version = 1,
script = document.createElement('script');
@keo
keo / bootstrap.sh
Last active January 25, 2024 15:49
Setup encrypted partition for Docker containers
#!/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
@Yimiprod
Yimiprod / difference.js
Last active April 5, 2024 13:17
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* 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) {
@doublemarked
doublemarked / !Fragmenting Loopback Models.md
Last active May 2, 2016 00:40
Boot script for fragmented loading of Loopback models

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.

@Piskvor
Piskvor / u2f.sh
Created August 13, 2021 14:16
Ubuntu 18.04 u2f
# find the new device
lsusb -t
> Port 3: Dev 20, If 1, Class=Chip/SmartCard
# device number from lsusb "Dev"
lsusb -s 20
> Bus 001 Device 020: ID 32a3:3201
@drmikecrowe
drmikecrowe / launches.json
Last active March 4, 2022 12:14
My common launch.json config
[
{
"type": "node",
"request": "attach",
"port": 9229,
"sourceMaps": true,
"name": "Attach 9229",
"cwd": "${workspaceRoot}",
"address": "localhost",
"localRoot": "${workspaceFolder}",