Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"log"
"flag"
"os"
yaml "gopkg.in/yaml.v2"
"path/filepath"
"os/user"
@toshiharu
toshiharu / EvernoteNewNoteFromFile.scpt
Last active December 31, 2015 22:06
OS X の Evernote でインポートフォルダを作る
--
-- [Mac] Evernote auto-import folder for Mac OS X - Evernote - Evernote User Forum
-- https://discussion.evernote.com/topic/29948-evernote-auto-import-folder-for-mac-os-x/
--
-- これを ~/Library/Scripts/Folder Action Scripts/ に置いて、
-- インポートフォルダにしたいフォルダのコンテクストメニューでフォルダアクション設定を行う。
--
on adding folder items to theFolder after receiving theNewItems
repeat with theNewItem in theNewItems
@toshiharu
toshiharu / gist:7276365
Created November 2, 2013 06:59
procmail から maildrop へ移行した。

procmail から maildrop へ移行した。

Xcode-5.0.1 と MacPorts-2.2.1 へアップデートしたあたりで procmail が動かなくなってしまった。procmail のソースを開いてみたところでようやく procmail の更新が 12 年も前から止まっていることを知り、「procmail alternatives」でウェブ検索してみて maildrop へ移行することにした。

procmail は、/var/log/mail.log に「detected source and destination buffer overlap」というメッセージが残っているので、まあたぶん文字列関係の関数の挙動が変わったせいでエラーになるのだと思う。

ウェブ上には maildrop に関する先人たちの知識が多数あるので、ここにメモなんてせずに、手元で作った ~/.mailfilter を載せておく。

要注意なのは rcvstore のパス。bin ではなく lib にある。rcvstore 自体は nmh パッケージに含まれる。

--- rc-local.service.~1~ 2013-05-13 00:04:40.000000000 +0900
+++ rc-local.service 2013-05-13 01:55:21.895025151 +0900
@@ -6,15 +6,15 @@
# (at your option) any later version.
# This unit gets pulled automatically into multi-user.target by
-# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
+# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
-Description=/etc/rc.d/rc.local Compatibility
@toshiharu
toshiharu / gist:5539841
Last active June 11, 2016 04:43
Windows の Ruby で SSL のエラーが出ないようにしたときのメモ。

Windows の Ruby で SSL を使う。

特別なことをせずに RubyInstaller for Windows 2.0.0-p0 でセットアップした ruby で https を扱おうとすると「OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed」といったエラーが出るわけで、これを回避するために次のようなことをした。

まず ca-bundle.crt をどこかからもらってくる。僕は手元の Linux 機からコピーした。たとえば Fedora なら ca-certificates パッケージに含まれているだろう。

次に上のエラーが出てしまうプログラムのなるべく最初のあたり (openssl.rb を読み込む前というか ssleay32.dll かな) に下の一行を追加する。ca-bundle.crt のパスとかは適当に処理のこと。

ENV['SSL_CERT_FILE'] = File.expand_path('C:\Users\toshiharu\ca-bundle.crt')
@toshiharu
toshiharu / gist:5395171
Last active December 16, 2015 06:59
バイナリ版 GHC と Haskell Platform のインストールをインストールしたときのメモ。

バイナリ版 GHC と Haskell Platform のインストール

Haskell Platform for Linux に従って (バイナリ版) GHC と Haskell Platform のインストールをしたときのメモ。

まず、バイナリ版の GHC をインストール。

$ wget http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-x86_64-unknown-linux.tar.bz2
@toshiharu
toshiharu / gist:5382196
Created April 14, 2013 10:09
ruby-mode で {} が打てない件。
--- ruby-mode.el.~1~ 2013-04-13 15:30:44.608612153 +0900
+++ ruby-mode.el 2013-04-14 19:07:54.417190578 +0900
@@ -874,7 +874,7 @@ Also ignores spaces after parenthesis wh
(defun ruby-electric-brace (arg)
(interactive "P")
- (insert-char last-command-char 1)
+ (insert-char last-command-event 1)
(ruby-indent-line t)
(delete-char -1)
@toshiharu
toshiharu / gist:5325395
Created April 6, 2013 08:28
Wanderlust でマスターパスワード的なもの。前は alpaca.el を使って書いたのだけど、twittering-mode.el を参考にして EasyPG にした。 でもググってみるとこんな設定は必要ないような雰囲気を感じる。
(eval-after-load "elmo-util"
'(progn
(setq toshiharu-wl-use-master-passwd t)
(defun elmo-passwd-alist-load ()
(let* ((filename (expand-file-name elmo-passwd-alist-file-name
elmo-msgdb-directory))
(filename-gpg (concat filename ".gpg")))
(cond ((and toshiharu-wl-use-master-passwd
(require 'epa nil t)
@toshiharu
toshiharu / gist:5202860
Created March 20, 2013 07:12
Ruby 1.9/2.0 で Gmail へメールを送る。Ruby 1.8 で必要だった tlsmail.rb はいらないことを知った。
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'net/smtp'
from_addr = 'from@example.com'
to_addr = 'to@example.com'
message = <<EOM
@toshiharu
toshiharu / gist:5198760
Created March 19, 2013 18:28
iTunes の「ミュージック」ライブラリ内にある曲をランダムに再生する AppleScript だと思いたい。AppleScript エディタ上でしか実行の確認をしていない。
tell application "iTunes"
set musicPlaylist to playlist "ミュージック"
set view of front browser window to musicPlaylist
set numberOfTracks to (count of tracks of musicPlaylist)
set randomNumber to (random number from 1 to numberOfTracks)
play track randomNumber of musicPlaylist
reveal current track
end tell