Skip to content

Instantly share code, notes, and snippets.

@dpneumo
dpneumo / diff-phone_home.py.txt
Last active February 18, 2022 08:18
Modify cloud-init phone_home module to return a created server's public key for insertion into known_hosts. Works with cloud-iniit version 0.7.9 and later.
# Diff of the original cc_phone_home and the slightly modified version that supports
# including the server pub_keys in the phone_home payload
# Original: https://github.com/number5/cloud-init/blob/master/cloudinit/config/cc_phone_home.py
# A couple of typos in comment lines in the original were elided to make the diff a bit clearer.
# The Centos7 distros I am using do not provide pub_key_dsa.
# I am talking to a Rails app with phone_home.
# A dummy X-CSRF-Token: 1234567890 in the headers simplifies the code on the Rails side.
# I authenticate the phone_home payload by including a token provided in the
@a-dma
a-dma / yubitouch.sh
Last active March 10, 2022 14:43
Bash script for setting or clearing touch requirements for cryptographic operations in the OpenPGP application on a YubiKey 4.
#!/bin/bash
# Bash script for setting or clearing touch requirements for
# cryptographic operations the OpenPGP application on a YubiKey 4.
#
# Author: Alessio Di Mauro <alessio@yubico.com>
GCA=$(which gpg-connect-agent)
DO=0
UIF=0
@renchap
renchap / README.md
Last active October 12, 2022 17:14
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 {
@tdhopper
tdhopper / screenshot.md
Last active August 29, 2015 14:02
Using Keyboard Maestro to paste text from your clipboard to Drafts on iOS via Pushover. The Keyboard Maestro action will send a link to Pushover that will open the text in Drafts. The amount of text you can send is limited by the Pushover API.

@ohokay
ohokay / cloudapp-export.rb
Last active September 7, 2018 11:19 — forked from adamcooke/cloudapp-export.rb
Apparently the cloud app api returns a date object, so it needs to be converted to a string.
#!/usr/bin/env ruby
# A quick script to download all your files from CloudApp.
# To run this just run the script passing your e-mail & password
# to the script, for example:
#
# gem install cloudapp_api
# ruby cloudapp-export.rb adam@atechmedia.com mypassword
#
@kerotaa
kerotaa / remove-empty-lines-html.rb
Last active May 26, 2020 03:48
A plugin that remove empty lines from HTML files on jekyll.
module Jekyll
module Convertible
def write(dest)
path = destination(dest)
FileUtils.mkdir_p(File.dirname(path))
if File.extname(path).downcase == '.html' then
self.output.strip!
reg = /<\/?pre[^>]*>/i
pres = self.output.scan(reg)
tary = self.output.split(reg)
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@sedm0784
sedm0784 / CapsLockCtrlEscape.ahk
Last active April 11, 2024 22:38
AutoHotkey script to map Caps Lock to Escape when it's pressed on its own and Ctrl when used in combination with another key, à la Steve Losh. Adapted from one that does something similar with the Ctrl Key on the Vim Tips Wiki (http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows?oldid=32281). (Plus contribs from @randy909 & @mmikeww.)
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
# Raw transaction API example work-through
# Send coins to a 2-of-3 multisig, then spend them.
#
# For this example, I'm using these three keypairs (public/private)
# 0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86 / 5JaTXbAUmfPYZFRwrYaALK48fN6sFJp4rHqq2QSXs8ucfpE4yQU
# 04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a986818a7cb624532f062c1d1f8722084861c5c3291ccffef4ec6874 / 5Jb7fCeh1Wtm4yBBg3q3XbT6B525i17kVhy3vMC9AqfR6FH2qGk
# 048d2455d2403e08708fc1f556002f1b6cd83f992d085097f9974ab08a28838f07896fbab08f39495e15fa6fad6edbfb1e754e35fa1c7844c41f322a1863d46213 / 5JFjmGo5Fww9p8gvx48qBYDJNAzR9pmH5S389axMtDyPT8ddqmw
# First: combine the three keys into a multisig address:
./bitcoind createmultisig 2 '["0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86","04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a9
@jnovack
jnovack / pushover.pl
Last active March 28, 2018 19:08
pushover.pl - Sends irssi notifications to Pushover
use strict;
use warnings;
# {{{ DOCUMENTATION
#####
# A lot of code borrowed from the prowlnotify.pl script at
# http://www.denis.lemire.name/2009/07/07/prowl-irssi-hack/
# and pushovernotify.pl (Daniel Johansson <donnex@donnex.net>)
# and http://www.geekfarm.org/wu/muse/scripts/growl-notify.txt
#