Skip to content

Instantly share code, notes, and snippets.

View uchida's full-sized avatar

Akihiro Uchida uchida

View GitHub Profile
@uchida
uchida / README.md
Last active August 29, 2015 13:56
メール送信コマンド (python 2.6 以上で動作)

使い方

設定名は後述する設定ファイルで設定します。

$ /path/to/mail.py '設定名' '宛先アドレス' '題名' '本文'

設定

// ========================== KeySnail Init File =========================== //
// この領域は, GUI により設定ファイルを生成した際にも引き継がれます
// 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
// ========================================================================= //
//{{%PRESERVE%
plugins.options["ldrnail.keybind"] = {
'j': 'next',
'k': 'prev',
'p': 'pin',
(defn access [array & idxs]
(loop [i (first idxs)
idxs (rest idxs)
ret array]
(if i
(recur (first idxs) (rest idxs) (get ret i))
ret)))
(access [[0 1 2]] 0 1)
@uchida
uchida / gist:949753
Created April 30, 2011 15:34
crontab format
# crontab format
# * * * * * command to be execute
# | | | | +---- day of week (0 - 6) (Sunday = 0 or 7) or sun, mon, ..., sat
# | | | +------ month (1 - 12) or jan, feb, ..., dec
# | | +-------- day of month (1 - 31)
# | +---------- hour (0 - 23)
# +------------ minute (0 - 59)
# special string
# string meaning
# ------ -------
@uchida
uchida / open_nt.sh
Created April 30, 2011 21:55
open url in Safari with new Tab
#!/bin/sh
osascript -e "tell application \"Safari\"
tell window 1
set current tab to (make new tab)
set currenttab to open location \"$@\"
end tell
end tell"
@uchida
uchida / bookmark.py
Created April 30, 2011 21:50
bookmark script for newsbeuter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# bookmark script for newsbeuter
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import sys
import os.path
import cPickle as pickle
BOOKMARK = os.path.expanduser('~/newsbeuter/bookmark.pkl')
@uchida
uchida / ndindex.py
Created May 20, 2011 10:40
a portable and compact version of numpy.ndindex
import functools, operator
prod = functools.partial(functools.reduce, operator.mul)
def ndindex(maxvals):
total = prod(maxvals)
index = [0] * len(maxvals)
for _ in range(total):
yield tuple(index)
for i, n in enumerate(reversed(maxvals)):
index[-i-1] += 1
if index[-i-1] < n:
@uchida
uchida / gist:1285408
Created October 13, 2011 20:26
Tokyo.Scipy#2 ディスカッション事前アンケート3
# -*- coding:utf8 -*-
# Tokyo.Scipy#2 ディスカッション事前アンケート
# http://www.surveymonkey.com/s/XJ2KNBW
#
# 3. nanやInfを含む値の列
# x = numpy.array([[1,0,nan,1,Inf,1,....]])
# が与えられたとき、
# NaNやInf以外のxの要素の合計を計算する方法が直ぐに思い浮かびますか?
from numpy import array
@uchida
uchida / gist:1285419
Created October 13, 2011 20:29
Tokyo.Scipy#2 ディスカッション事前アンケート4
# -*- coding:utf8 -*-
# Tokyo.Scipy#2 ディスカッション事前アンケート
# http://www.surveymonkey.com/s/XJ2KNBW
#
# 4. nanを含む4x2行列
# m = numpy.array([[1,nan,-1,0],[0,0,nan,1]])
# が与えられたとき、
# nanを含む行を削除して2x2行列にする方法が直ぐに思い浮かびますか?
from numpy import array
@uchida
uchida / gist:1285432
Created October 13, 2011 20:31
Tokyo.Scipy#2 ディスカッション事前アンケート5
# -*- coding:utf8 -*-
# Tokyo.Scipy#2 ディスカッション事前アンケート
# http://www.surveymonkey.com/s/XJ2KNBW
#
# 5. numpy.array([[1,3,2]]) を、1-of-K表記法変換して
# numpy.array([[1,0,0],[0,0,1],[0,1,0]])
# にする処理方法が直ぐに思い浮かびますか?
from numpy import array, zeros