Skip to content

Instantly share code, notes, and snippets.

@ernix
ernix / gist:12394d28a1282ca022a62dcbee8ac7aa
Created August 1, 2017 00:24
neomutt won't work with notmuch
✔ kojima:kojiMac ~$ mutt
dyld: Library not loaded: /usr/local/opt/notmuch/lib/libnotmuch.4.dylib
Referenced from: /usr/local/bin/mutt
Reason: image not found
mutt: warning: mutt crashed, killed by SIGABRT.
mutt itself has not crashed, but for transparency,
it will now kill itself (without dumping core) with the same signal
warnings can be silenced by the --no-warnings (-n) option
@ernix
ernix / mastodon_owners.pl
Last active June 29, 2017 13:55
mastodonのownerをスクレイピング
#!/usr/bin/perl
use strict;
use warnings;
use Mojo::UserAgent;
use Mojo::IOLoop;
our $INSTANCES_URL = 'https://instances.mastodon.xyz/instances.json';
my $ua = Mojo::UserAgent->new;
$ua->max_redirects(3);
@ernix
ernix / vim-toggle-case.vim
Created April 26, 2017 04:19
vim-toggle-case.vim
function! s:ToggleCase()
let cur_word = expand("<cword>")
if cur_word == ''
return
endif
let new_word = ''
if toupper(cur_word)==#cur_word " CONST_ISH
let new_word = tolower(cur_word)
elseif cur_word =~ '_' " snake_case
@ernix
ernix / mastodon_universal_regex_filter.js
Created April 18, 2017 08:22
Add regex filter button for Public/Federated TimeLines
(function (g) {
var d = g.document
filter = prompt('Feed me a filtering regex:'),
regex = new RegExp(filter, 'gi');
display = function (value) {
[].forEach.call(d.querySelectorAll('.status'), function (n) {
var c, t;
if (value !== 'block') {
c = n.querySelector('.status__content');
t = c.innerText || c.textContent;
@ernix
ernix / jquery-reduce.js
Created August 25, 2016 22:21
jQuery.reduce()
$.fn.extend({
reduce: function (cb, init) {
this.each(function (i) {
if (i === 0 && typeof init === 'undefined') {
init = $(this);
} else {
init = cb.call($(this), init);
}
});
return init;
@ernix
ernix / mock_open.pl
Last active April 11, 2019 14:14
Mock(override) built-in `open` function in perl.
#
# http://perldoc.perl.org/CORE.html#OVERRIDING-CORE-FUNCTIONS
# > To override a built-in globally (that is, in all namespaces), you need to
# > import your function into the CORE::GLOBAL pseudo-namespace at compile
# > time:
# >
# > BEGIN {
# > *CORE::GLOBAL::hex = sub {
# > # ... your code here
# > };
@ernix
ernix / dovecot-2.2.10-mysql-virtual-user-lookup-doesnt-overwrite-settings.md
Last active October 31, 2015 00:35
dovecot 2.2.10 mysql virtual user lookup doesn't overwrite uid/gid/home/mail etc

Error:

Couldn't drop privileges: User is missing UID (see mail_uid setting)

Switch include order in conf.d/10-auth.conf to fix the problem.

diff --git a/conf.d/10-auth.conf b/conf.d/10-auth.conf
index e9cfd05..fbfed63 100644
@ernix
ernix / gist:5315a4c75dca57a19e97
Created May 15, 2014 05:14
xpath against IE11 bug
# http://connect.microsoft.com/IE/feedback/details/807447/ie-11-metro-version-submitting-form-fails-if-input-tag-has-no-name-attribute
//form[not(.//input) or count(.//input[@name] == 0)]
@ernix
ernix / plenv-install-perl-5.8.9-i386.sh
Created April 28, 2014 07:46
Install 32bit perl on Mac OSX with plenv
plenv install 5.8.9 \
-Dcc=gcc \
-Dld=g++ \
-Dusethreads \
-Duseithreads \
-Duseshrplib \
-Accflags="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" \
-Accflags="-mmacosx-version-min=10.6" \
-Accflags="-arch i386 -DUSE_SITECUSTOMIZE -Duselargefiles" \
-Aldflags="-Wl,-search_paths_first -arch i386" \
@ernix
ernix / pmautotest
Created September 13, 2012 04:35
`Autotest::Screen` for perl modules built in Dist::Zilla.
#!/bin/sh
anchor="dist.ini"
dir_p="$PWD" found= src_root=
while [ -n "$dir_p" ]
do
found=$(find "$dir_p" -maxdepth 1 -name "$anchor")
[ -n "$found" ] && break
dir_p="${dir_p%/*}"