Skip to content

Instantly share code, notes, and snippets.

View yoshinari-nomura's full-sized avatar

Yoshinari Nomura yoshinari-nomura

View GitHub Profile
function em () {
EMACS_SERVER_SOCKET_FILE="$TMPDIR/emacs$UID/server"
if [[ -S "$EMACS_SERVER_SOCKET_FILE" ]]; then
emacsclient -n "$@"
else
open -a /Applications/Emacs.app/Contents/MacOS/Emacs "$@"
fi
}
@yoshinari-nomura
yoshinari-nomura / .rvmrc-set-ruby-by-gemset-name.sh
Created June 4, 2014 13:55
Sample .rvmrc for searching suitable Ruby version from the name of gemset
MY_PROJECT_GEMSET='filebucket'
MY_PROJECT_RUBY_AND_GEMSET=$( \
rvm gemset list_all \
| awk '/^gemset/{ruby = $3}; /^ /{print ruby "@" $1}' \
| grep "@$MY_PROJECT_GEMSET\$" \
| tail -1
)
if [ -n "$MY_PROJECT_RUBY_AND_GEMSET" ]; then
(global-set-key [(meta ?+)] (lambda () (interactive) (text-scale-increase 1)))
(global-set-key [(meta ?-)] (lambda () (interactive) (text-scale-increase -1)))
(global-set-key [(meta ?0)] (lambda () (interactive) (text-scale-increase 0)))
(global-set-key [(meta ?8)] (lambda () (interactive) (toggle-current-background-type)))
@yoshinari-nomura
yoshinari-nomura / caldav-delete-all
Created May 9, 2014 05:14
Remove all calendar evens from Google calendar using mhc
#!/usr/bin/env ruby
# Usage: caldav-delete-all <calendarname>
#
# <calendarname>: calendar name found in ~/.mhc/config.yml
if File.symlink?(__FILE__) and ENV["RBENV_VERSION"]
ENV["RBENV_VERSION"] = nil
shims_path = File.expand_path("shims", ENV["RBENV_ROOT"])
ENV["PATH"] = shims_path + ":" + ENV["PATH"]
#!/bin/sh
CMD_NAME=`basename $0`
OLD_MHC_TOP_DIR="${1%/}" # remove trailing slash
NEW_MHC_TOP_DIR="${2%/}" # remove trailing slash
LOG_FILE="$NEW_MHC_TOP_DIR/$CMD_NAME$$.log"
usage() {
echo "Usage: $CMD_NAME <top-dir> <new-top-dir>"
echo " $CMD_NAME copies old mhc files from <top-dir> into"
#!/bin/bash
BOT_ID="nomnichi_bot"
ROOM="nomlab"
SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXX"
BASE_URL='http://lingr.com/api/room/say'
bot_verifier=`echo -n "$BOT_ID$SECRET" | openssl dgst -sha1 | sed 's/^.* //'`
URL="$BASE_URL?room=$ROOM&bot=$BOT_ID&bot_verifier=$bot_verifier"
@yoshinari-nomura
yoshinari-nomura / paper-sample-for-latex-makefile.tex
Created February 1, 2013 03:59
Sample TeX file for my Makefile Template.
\documentclass[10pt, conference, compsocconf]{IEEEtran}
\usepackage[dvipdfm]{graphicx}
\begin{document}
\title{Writing papers}
\author{\IEEEauthorblockN{
Taro Momo,
Saru Kiji,
and
Aka Oni}
@yoshinari-nomura
yoshinari-nomura / Makefile
Created January 17, 2013 03:19
My Makefile template for TeX documents.
###
### Makefile for LaTeX documents
###
### Yoshinari Nomura
###
### GNU make 3.81 will work for you.
###
#####################################################################
# Typeset commands and path settings
@yoshinari-nomura
yoshinari-nomura / gist:3465571
Created August 25, 2012 13:20
Font setup for Cocoa Emacs24
(when (and (>= emacs-major-version 24)
(eq window-system 'ns))
;; フォントセットを作る
(let* ((fontset-name "myfonts") ; フォントセットの名前
(size 14) ; ASCIIフォントのサイズ [9/10/12/14/15/17/19/20/...]
(asciifont "Menlo") ; ASCIIフォント
(jpfont "Hiragino Maru Gothic ProN") ; 日本語フォント
(font (format "%s-%d:weight=normal:slant=normal" asciifont size))
(fontspec (font-spec :family asciifont))
(jp-fontspec (font-spec :family jpfont))
(add-private-load-path "auto-complete")
(require 'popup)
(defun dic-at-point ()
(interactive)
(let* ((word (word-at-point))
(desc (and word (shell-command-to-string (format "dic '%s'" word)))))
(when (and desc (null popup-instances))
(popup-tip desc :margin t))))