Skip to content

Instantly share code, notes, and snippets.

View unhammer's full-sized avatar
kevin :: Coffee → Code

Kevin Brubeck Unhammer unhammer

kevin :: Coffee → Code
View GitHub Profile
@tavisrudd
tavisrudd / readline_clipboard.sh
Created August 24, 2011 20:18
bash readline integration with clipboards: M-k = kill, M-y = yank, M-u = backwards kill
## derived from http://stackoverflow.com/questions/994563/integrate-readlines-kill-ring-and-the-x11-clipboard
## You need to choose which clipboard to integrate with, OS X or X11:
shell_copy() {
pbcopy # OS X
# or ssh user@remote_mac pbcopy
# or xclip
}
shell_yank() {
@unhammer
unhammer / window-toggle-decorations.py
Created February 13, 2012 08:55
toggle gtk window decorations
#! /usr/bin/python2
import gtk.gdk
w = gtk.gdk.window_foreign_new( gtk.gdk.get_default_root_window().property_get("_NET_ACTIVE_WINDOW")[2][0] )
w.set_decorations( (w.get_decorations()+1)%2 ) # toggle between 0 and 1
gtk.gdk.window_process_all_updates()
gtk.gdk.flush()
# now bind this to super-r or something
@unhammer
unhammer / signal
Last active February 21, 2022 20:04
Launch Signal if not running, otherwise toggle hidden/shown state. Put signal.desktop in ~/.config/autostart/.
#!/bin/bash
run () {
signal-desktop &
disown
}
show () {
local -r id="$1"
idx="$(printf "0x%08x" "${id}")"
@alphapapa
alphapapa / replace-words-randomly.el
Created July 24, 2017 22:40
Emacs: Replace all words in buffer with random words of the same length
;; This function replaces all words in a buffer with words of the same length,
;; chosen at random from /usr/share/dict/words. Words are replaced consistently,
;; so e.g. "A" is always replaced with "Z". The mapping changes when Emacs is
;; restarted or when the cache buffer is killed. If all unique words of a certain
;; length are exhausted, random strings are used.
(defun ap/replace-words-randomly (&optional buffer)
"Replace all words in BUFFER or current buffer with randomly selected words from the dictionary.
Every time a new word is found, it is mapped to a replacement
word, so every instance of word A will be replaced with word Z."
@slackorama
slackorama / js-beautify.el
Created November 23, 2010 19:51
beautify some js code in emacs
;;; js-beautify.el -- beautify some js code
(defgroup js-beautify nil
"Use jsbeautify to beautify some js"
:group 'editing)
(defcustom js-beautify-args "--jslint-happy --brace-style=end-expand --keep-array-indentation"
"Arguments to pass to jsbeautify script"
:type '(string)
:group 'js-beautify)
@unhammer
unhammer / intervec.py
Last active July 27, 2021 15:59
Multilingual word vectors for SpaCy (based on https://github.com/Babylonpartners/fastText_multilingual )
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# A SpaCy implementation of
# https://github.com/Babylonpartners/fastText_multilingual
#
# heavily based on
# https://github.com/Babylonpartners/fastText_multilingual/blob/master/align_your_own.ipynb
import numpy as np
@yolabingo
yolabingo / wp-email-validate-check.php
Last active May 21, 2020 04:15
Test Wordpress email validation regular expression
<?php
/*
Wordpress bug https://core.trac.wordpress.org/ticket/47855
When using a current PHP version, class-phpmailer.php:validateAddress() uses a complex regex ("pcre8") for email address validation.
PHP < 7.3 uses libpcre 8.x.
PHP 7.3 uses libpcre2 10.x.
Due to a bug in libpcre2 < 10.32-RC1 https://bugs.exim.org/show_bug.cgi?id=2300,
@kosmikus
kosmikus / Tutorial.hs
Last active May 1, 2020 23:59
Preliminary rewrite of Gabriel's lens tutorial to use `optics` instead of `lens`
{-| This @lens@ tutorial targets Haskell beginners and assumes only basic
familiarity with Haskell. By the end of this tutorial you should:
* understand what problems the @lens@ library solves,
* know when it is appropriate to use the @lens@ library,
* be proficient in the most common @lens@ idioms,
* understand the drawbacks of using lenses, and:
@wmerrifield
wmerrifield / build+archive.sh
Created November 8, 2010 17:53
A shell script to perform the equivalent of Xcode's "Build & Archive" command.
#!/bin/sh
#
# Copyright (c) 2010 Warren Merrifield
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@unhammer
unhammer / mindiff
Last active December 18, 2015 04:49
call diff on two files, but ignore lines after the length of the shortest one
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "Usage: $0 file1 file2 [additional options to diff]"
exit 1
fi
if1=$1
if2=$2
shift 2