Skip to content

Instantly share code, notes, and snippets.

@ggl
ggl / htpasswd.pl
Last active October 18, 2021 21:51
htpasswd in perl, no need to install apache tools
#!/usr/bin/env perl
#
# htpasswd.pl
#
# Copyright (c) 2013, Gelu Lupas <gelu@devnull.ro>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@westonruter
westonruter / gist:5475349
Last active August 12, 2021 07:00 — forked from markjaquith/gist:2653957
WordPress Fragment Caching convenience wrapper
<?php
/*
Usage:
cache_fragment_output( 'unique-key', 3600, function () {
functions_that_do_stuff_live();
these_should_echo();
});
*/
function cache_fragment_output( $key, $ttl, $function ) {
@clarkdave
clarkdave / chef-insert-line-if-no-match.rb
Created June 13, 2013 11:12
[CHEF] Insert a line in a file if it doesn't already exist
line = '127.0.0.1 gateway.internal gateway'
file = Chef::Util::FileEdit.new('/etc/hosts')
file.insert_line_if_no_match(/#{line}/, line)
file.write_file
@cheeaun
cheeaun / js-error-logging-services.md
Last active December 10, 2023 13:04
JavaScript error logging services
@alvarobp
alvarobp / remote_pairing_setup.md
Last active July 29, 2022 20:20
Setting up a remote pair station with SSH + TMUX and/or Reverse SSH Tunnel

Disclaimer: The following examples try to give an overview of the process followed in different scenarios. Some commands were actually written from memory. Some tools might exist simplifying all this. Furthermore, I'm no expert so if anyone ever reads this and knows any improvement, please let me know.

Case 1: Direct access to Pairing Station

Given that the Guest User can access the Pairing Station directly, either because the station is publicly available or because NAT port forwarding can be used, there's only one thing we need to do, give ssh access to the Guest User by adding his ssh public key to our Local User (pair) .ssh/authorized_keys file.

The local user would open up a tmux session with

tmux new-session -s pairing
@christianberg
christianberg / create-docker-droplet.sh
Last active April 14, 2024 17:25
Shell script to create a Digital Ocean Droplet and install docker
#!/bin/bash
set -e
SECRETFILE=~/.digitalocean
if [[ -z $DIGOCEAN_ID ]] || [[ -z $DIGOCEAN_KEY ]]; then
if [ -e $SECRETFILE ]; then
. $SECRETFILE
fi
fi
@guifromrio
guifromrio / nodejs-ubuntu-bind-port-80.md
Last active January 10, 2024 22:47
Allow Node.js to bind to privileged ports without root access on Ubuntu

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

@trey
trey / Gruntfile.js
Last active October 22, 2018 12:59
This is a braindump of the first time I was actually able to get Grunt to do all of what I wanted.
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {},
}
},
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions