Skip to content

Instantly share code, notes, and snippets.

kafene

Block or report user

Report or block kafene

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mailhog-install.sh
#!/usr/bin/env bash
set -euo pipefail
if [[ -f /usr/local/bin/mailhog ]]; then
echo 'It seems mailhog is already installed.' >&2
echo 'Remove </usr/local/bin/mailhog> to force reinstallation.' >&2
exit 1
fi
if [[ "$EUID" -ne 0 ]]; then
View keybase.md

Keybase proof

I hereby claim:

  • I am kafene on github.
  • I am kafene (https://keybase.io/kafene) on keybase.
  • I have a public key ASB-7DLvRLALGUox5XxuLBTf9ZYVHPekMdL3Fp2fist-Wwo

To claim this, I am signing this object:

@kafene
kafene / gpg-wkd.md
Last active Jul 21, 2019
Setting up WKD for self-hosted automatic key discovery
View gpg-wkd.md

I just got this working so I figured I'd share what I found, since there's hardly any information about this anywhere online except an RFC, the GPG mailing list and one tutorial from the GnuPG blog.

You can use automatic key discovery with WKD (Web key directory) to make it easy for users to import your key, in GPG since version 2.1.12. Since this feature is fairly new, it isn't yet available in the current LTS release of Ubuntu (16.04; xenial), however it is available in Debian stable (stretch).

I couldn't add a DNS CERT or DANE / OPENPGPKEY record through my email service (which also hosts my nameservers). I tried making the PKA record - a foo._pka.example.com TXT record but GPG doesn't seem to recognize it and fails; I'm still investigating why.

So the last option for self-hosted auto-discovery was WKD.

First thing I had to do was add an email address to my key. My primary UID is just my name so the key represents my identity rather

@kafene
kafene / pulseaudio-systemd-user.md
Created May 18, 2017
Pulseaudio via systemd --user
View pulseaudio-systemd-user.md

~/.config/systemd/user/pulseaudio.service:

[Unit]
Description=Pulseaudio Sound Service
Requires=pulseaudio.socket

[Service]
Type=notify
ExecStart=/usr/bin/pulseaudio --verbose --daemonize=no
@kafene
kafene / firefox-extension-get-selected-text.md
Created Mar 10, 2017
Getting the currently selected text in a Firefox extension
View firefox-extension-get-selected-text.md

Post e10s, this seems to be the most consistent way (should work in both pre and post-e10s builds):

const tabs = require("sdk/tabs");

function getSelectedText() {
    return new Promise(function (resolve, reject) {
        tabs.activeTab.attach({
            contentScript: "self.postMessage(String(getSelection()));",
            onMessage: resolve,
@kafene
kafene / README.md
Last active Feb 24, 2017 — forked from EmanueleMinotto/README.md
PHP Microframework
View README.md

Microframework

This is a PHP (5.3+) microframework based on anonymous functions.

Features

  • requested URLs matched using regular expressions
  • request methods (matches using regular expressions too)
  • differenced FIFO queues for each $priority
  • command line usage
  • backward compatibility
  • integrated Dependency Injection and settings system
  • named patterns
@kafene
kafene / promise-script-loader.md
Last active Aug 29, 2015
Using Promises to load scripts
View promise-script-loader.md

I had a few of scripts I want to load in my userscript before executing it. After some head scratching and messing around with Promises it turns out it's quite easy. This way there's no need to require a larger module loader and other dependencies, which can be a pain to work with when writing userscripts.

(function load(scripts) {
    // Wait for DOMContentLoaded/window.onload
    if (document.readyState !== "interactive" && document.readyState !== "complete") {
        document.addEventListener("DOMContentLoaded", load.bind(null, scripts));
        return;
    }
@kafene
kafene / insertAdjacentElement.md
Last active Aug 29, 2015
Element.prototype.insertAdjacentElement shim
View insertAdjacentElement.md

This is a shim for Element.prototype.insertAdjacentElement, which is supported all major browsers except Firefox.

Example: https://jsfiddle.net/kafene/s6Lweg5k/

if ("undefined" === typeof (Element.prototype.insertAdjacentElement)) {
    Object.defineProperty(Element.prototype, "insertAdjacentElement", {
        enumerable: false,
        writable: true,
        configurable: true,
View HISTIGNORE-info.txt
###
####### HISTIGNORE #######
###
# examples from interwebs, noob dot file notes
#export HISTIGNORE='pwd:exit:fg:bg:top:clear'
# (if try to erasedups do not ignore things want 2 pune but on OSX it no workie)
# ignore things that start with a space, and ignore the exit command
#HISTIGNORE='[ \t]*:exit'
# some slashdot dudes says
#export HISTIGNORE="&:ls:[bf]g:exit:pwd:clear:mount:umount:[ \t]*"
View firegesture-open-link-or-duplicate-tab-in-background.js
You can’t perform that action at this time.