Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
grep pam_tid /etc/pam.d/sudo >/dev/null || echo auth sufficient pam_tid.so | cat - /etc/pam.d/sudo | sudo tee /etc/pam.d/sudo > /dev/null
@winzig
winzig / cloudsearch-clone-domain.sh
Created May 8, 2018 04:35
A bash script to help you clone an AWS CloudSearch domain
#!/bin/bash
#
# Usage: cloudsearch-clone-domain <domain> <newdomain>
#
# After you run this script, you'll have a file named define-fields-<newdomain>.sh, which
# you can run to re-create all the fields from the cloned domain. If you haven't yet created
# the new CS domain, then run `aws cloudsearch create-domain --domain-name <newdomain>` before
# running the define-fields script that is produced by this script.
die () {
@andregoncalves
andregoncalves / request.js
Created July 10, 2017 07:09
HTTP Request Retry with exponential backoff with Async
function wait (timeout) {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
}, timeout)
})
}
async function requestWithRetry (url) {
const MAX_RETRIES = 10
exports.handler = (event, context, callback) => {
callback(null, "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAA4pklEQVR4Ae2dd1xUd9b/LwWxY++KxnSjMRtN302yMSXrpuTZjfntZpM1m90YjRQYCgPMwEjvIoqKvaPYCxZAsceuiAXFgoACoShz7/S58/vcPCS7Ppgswgxc7pw/3i99Ucbhcs/b7/fc8z2HsVgsRBuzPXunc6Bc8Un4jKg14ADYDZL9AuQvVVfXONM1aj3MlZccWP9Og7gZwyeDcKBg5T0+0GeHdqPr0/bQRWhjcvP2jYWsjkJQJmAGfANmYJwRGXNSHqJ8S6vV0fWyIby6ioGYxnGRI3dDUkZgAuYGTFzEIyWsvOfnhoOz7fMakbCIg4cOjw0ICj3RICjLL8ADY0RUbIYyPLITXTcrYzYwrHJAVy7qsQXcDHcD5MQDy4NxN7JB3f0N3y+yr2tEwiKOHT/hBlmt/GVZNcIEzkdExQym62c9ONXwxyCiSw0rKst/ReV+j5W7fWo8udI+rhEJizh16gwTGKz4e5gq0ijI6CHgQUlsfOKTdB1bjib6iRchoKrGq6pfBzmu7cZTa4bRNSRh2QXHj5/sJQuQrxIk1EzKEpNTR9K1bD6ahLHPQ1Z1jYTUtFWWiQ3u9Tfj+c10LUlY0ufMmXNv+foHVQjyaQFXZs1O70/X8+HRzHx5LLaBdwT5NBfWv+NC49msHnQ9SViS5nzhBSY4NGwatoN8C4XF4zVOzJ2/sANd16ajnfP7YZDVjZbIqmFbWAhh/YauKQlL0pw5e66rr1/gPEE6VsAEaWUvXrqcrm0T0C74Yzds584KwmkprJ+ryXQx+xOpXzMSFglrhMw/aI8gHCthgLRWr1i5WhrbtZSXbSOrZZM6cKph+Y0S7M0Er2XhlAO9TEW5kr5fSVgkrPEQ1iVBNlZErwyPWL123Qarvc/0eRkMEvt9W/v6QA
@kylemanna
kylemanna / README-python-service-on-systemd-activated-socket.md
Last active January 10, 2026 01:29 — forked from drmalex07/README-python-service-on-systemd-activated-socket.md
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at ~/tmp/foo/serve.py.

@charity
charity / init.sh
Created May 18, 2016 20:19
terraform environment init.sh
#!/bin/bash
# Usage: ./init.sh once to initialize remote storage for this environment.
# Subsequent tf actions in this environment don't require re-initialization,
# unless you have completely cleared your .terraform cache.
#
# terraform plan -var-file=./production.tfvars
# terraform apply -var-file=./production.tfvars
tf_env="production"
@vasanthk
vasanthk / System Design.md
Last active March 13, 2026 10:40
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@mattjbarlow
mattjbarlow / gist:242b66cdae6938d34419
Created December 22, 2014 15:40
Chef Shell in Test Kitchen
cd into /tmp/kitchen.
/opt/chef/embedded/bin/gem install chef-zero
/opt/chef/embedded/bin/chef-zero -d
knife cookbook upload -a -c client.rb
chef-shell -z -c client.rb -o '<YOUR RECIPE>'
@tam7t
tam7t / gist:86eb4793e8ecf3f55037
Last active April 14, 2022 10:57
Securing Ruby's OpenSSL

Are your Ruby HTTPS API calls secure?

Let's check:

2.0.0-p481 :001 > OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
 => {:ssl_version=>"SSLv23", :verify_mode=>1, :ciphers=>"ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", :options=>-2147482625}
2.0.0-p481 :002 > rating = JSON.parse(RestClient::Resource.new("https://www.howsmyssl.com/a/check" ).get)['rating']
 => "Bad"
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'https://github.com/cburgmer/upsidedown'