Skip to content

Instantly share code, notes, and snippets.

View mastilver's full-sized avatar

Thomas Sileghem mastilver

View GitHub Profile
@renchap
renchap / README.md
Last active February 14, 2025 13:25
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@1nstinct
1nstinct / or.js
Last active June 13, 2016 07:06
sails-hook-parametized-policies N policies
/**
* Ability to check any count of policies in OR ordering
* @author Yuriy Syedin <[email protected]>
* @returns {Function}
*/
module.exports = function () {
var makeFakeForbidden = function (policies, p, req, res, next) {
if (!policies[p + 1]) return res; // if there is no next policy, that should be verified - leave result as it is
var customRes = {}; // init empty response object
/**
* Simple userland heapdump generator using v8-profiler
* Usage: require('[path_to]/HeapDump').init('datadir')
*
* @module HeapDump
* @type {exports}
*/
var fs = require('fs');
var profiler = require('v8-profiler');
@dhoko
dhoko / countWatcher.js
Created September 22, 2015 09:42
[Bookmarklet] Debug AngularJS
// Version without jQuery
javascript:(function () { var root = angular.element(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) { if (element.data() && element.data().hasOwnProperty(scopeProperty)) { angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) { watchers.push(watcher); }); } }); angular.forEach(element.children(), function (childElement) { f(angular.element(childElement)); }); }; f(root); var watchersWithoutDuplicates = []; angular.forEach(watchers, function(item) { if(watchersWithoutDuplicates.indexOf(item) < 0) { watchersWithoutDuplicates.push(item); } }); console.log(watchersWithoutDuplicates.length); })();
// Version with jQuery
javascript:(function () { var root = $(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watche
@mastilver
mastilver / .gitconfig
Last active August 4, 2021 15:44
My git config
[push]
default = simple
[pull]
rebase = true
[fetch]
prune = true
[alias]
@ericelliott
ericelliott / essential-javascript-links.md
Last active June 14, 2025 18:43
Essential JavaScript Links
@mvalipour
mvalipour / install-hubflow.cmd
Last active September 8, 2018 08:36
Install HubFlow on windows
@echo off
setlocal
rem ===================
rem Set GIT_HOME
rem ===================
rem Read the Git for Windows installation path from the Registry.
:REG_QUERY
@campbellwmorgan
campbellwmorgan / gist:e305cc36365fa2d052a7
Last active December 29, 2016 09:59
Model Mock for unit testing Sails.js applications
var Waterline, count, memory, _;
_ = require('lodash');
// sails-memory stores the adapter as a
// variable and it needs a different version for each instance
count = 0;
Waterline = require('waterline');
@staltz
staltz / introrx.md
Last active July 17, 2025 11:35
The introduction to Reactive Programming you've been missing
// to compile (using mingw-w64)
// g++ this_filename.c -lole32
// outputs current system volume (out of 0-100) to stdout, ex: output "23"
// mostly gleaned from examples here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd370839(v=vs.85).aspx
// download a compiled version here:
// https://sourceforge.net/projects/mplayer-edl/files/adjust_get_current_system_volume_vista_plus.exe.exe (updated, can set it too now!)
#include <windows.h>
#include <commctrl.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>