Skip to content

Instantly share code, notes, and snippets.

@ernix
ernix / vsh.sh
Created December 26, 2010 04:48
Set OSX terminal window background color per SSH hosts.
#!/bin/sh
#--------------------------------------------------------------------#
# Set OSX terminal window background color per SSH hosts.
#--------------------------------------------------------------------#
change_bgcolor () {
case $1 in
red)
osascript -e 'tell app "Terminal" to set background color of first window to {17655, 0, 0, -16373}';;
@ernix
ernix / japanese mobile mail filter @gmail
Created May 6, 2011 14:46
Gmailで日本のケータイメールアドレスをフィルタする為のクエリ。
@(docomo.ne.jp|disney.ne.jp|mopera.net|dwmail.jp|softbank.ne.jp|i.softbank.jp|(d|h|t|c|r|k|n|s|q).vodafone.ne.jp|*ezweb.ne.jp|ido.ne.jp|*pdx.ne.jp|willcom.com|emnet.ne.jp|vertclub.ne.jp|jp-(d|h|t|c|r|k|n|s|q).ne.jp|sky.(tkk|tkc|tu-ka).ne.jp)
@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%/*}"
@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 / 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 / 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 / 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 / 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 / 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 / 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