Skip to content

Instantly share code, notes, and snippets.

@jewel12
jewel12 / Hachioji.pm #37.md
Last active January 4, 2016 11:08
Hachioji.pm #37

Perl最高!Emacs最高!

@jewel_x12 です。

最近はPHPを書いています。Niigata.pmにいたりしてました。Perlは書きません。

今後ともよろしくお願い申し上げます。

今書いているコードのテストファイルを開きたい

今開いているファイルがテストのファイルっぽくなかったら、テストファイルっぽいのをhelm-ls-gitの入力にする。

@jewel12
jewel12 / age.sh
Created January 9, 2014 16:42
agで検索してpercolで絞り込みエディタで開く
function age() {
if [ $# -eq 1 ]; then
ag --noheading $1 | percol | sed 's/^\(.*\):\(.*\):.*/\1 +\2/' | xargs $EDITOR
else
echo "Usage: age QUERY"
fi
}
@jewel12
jewel12 / focus_next_window.js
Last active December 28, 2015 16:19
同じアプリケーションで別のウィンドウにフォーカスする Slate.app の設定
// 同じアプリケーションで別のウィンドウにフォーカスする
S.bind('n:alt,ctrl', function() {
function get_next_win(windows) {
truth_values_of_is_main = _.map(windows, function(w){ return w.isMain(); })
next_idx = _.indexOf(truth_values_of_is_main, 1) + 1;
if (next_idx >= _.size(windows)) { return windows[0]; }
return windows[next_idx];
}
windows = [];
slate.app().eachWindow(function(win){ windows.push(win); });
; Project Euler 1
(defn multiple-numbers-of-3-or-5 []
(defn whole-numbers [] (iterate inc 1))
(defn multiple-of-3-or-5? [x]
(if (or (zero? (rem x 3))
(zero? (rem x 5)))
true false))
(filter multiprable? (whole-numbers)))
@jewel12
jewel12 / join-words-by-underscore.el
Created May 11, 2013 19:16
カーソル手前の単語群をアンダースコアでつなげる
(defun join-words-by-underscore ()
(interactive)
(save-excursion
(save-restriction
(looking-back "[\s-\]*\\(\[a-zA-Z0-9\s-\]+\\)" nil t)
(narrow-to-region (match-beginning 1) (match-end 1))
(beginning-of-line)
(replace-string " " "_"))))
# コマンドを実行し、標準出力をlessに流す
function _exec_cmd_with_less () {
BUFFER+='|less'
zle accept-line
}
zle -N _exec_cmd_with_less
bindkey '^L' _exec_with_less
def yabai: Int = {
if (1==2) 100
else throw new Exception
}
@jewel12
jewel12 / Jewelve.rb
Created February 16, 2013 04:06
requireすると標準出力がJewelve.comっぽくなるオモシロrbです
# -*- coding: utf-8 -*-
module StringsOfJewelve
COLOR_NUMBERS = (0..7).to_a
def to_jewelve
return self.split('').map(&:to_random_colored).shuffle.join
end
def to_random_colored
# -*- coding: utf-8 -*-
class Player
module MovingMode
def self.create(velocity)
return lambda{ |direction, position|
case direction
when :up
position[:y] -= velocity[:y]
when :down
position[:y] += velocity[:y]
// アプリにフォーカスする。アプリが起動していなければ起動する。
var launch_and_focus = function(app_name) {
var launch = function(app_names, win) {
if( _.any(app_names, function(name){ return name == app_name; }) ) {
return;
}
win.doOperation(
slate.operation('shell', {
'command' : '/usr/bin/open -a ' + app_name,