This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'pp' | |
def shuffle(array) | |
i = array.length | |
while 0 < i | |
i = i - 1 | |
j = (Random.rand * i).to_i | |
array[i], array[j] = array[j], array[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(2..36).each do |base| | |
n = '1' * (base - 1) | |
puts "base: #{base} #{n} * #{n} = #{(n.to_i(base) ** 2).to_s(base)}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
words = %w(ボ ン ジョ ヴィ) | |
targets = %w(ジョ ン ボ ン ジョ ヴィ) | |
recent = [] | |
num_generate = 0 | |
begin | |
num_generate += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def undump | |
self.sub(/\A"/, '').sub(/"\z/, '').gsub(/\\(x([0-9a-f]{2})) | \\(u\{([0-9a-f]{4})\}) | \\(.) /ix) { | |
if $1 # \xXX | |
[$2.hex].pack("C") | |
elsif $3 # \u{xxxx} | |
[$4.hex].pack("U") | |
else # \. | |
case $5 | |
when 't' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-key minibuffer-local-filename-completion-map "\C-l" '(lambda () (interactive) (insert-string (concat (helm-reduce-file-name (delete-and-extract-region (minibuffer-prompt-end) (point-max)) 1 ) "/")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun dev-gitweb-diff-url-from-magit () | |
(interactive) | |
(let* ( | |
(branch (magit-get-current-branch)) | |
(remote (and branch (magit-get "branch" branch "remote"))) | |
(remote-rebase (and branch (magit-get-boolean "branch" branch "rebase"))) | |
(remote-branch (or (and branch (magit-remote-branch-for branch)) branch)) | |
(remote-string (and remote remote-branch (magit-remote-string remote remote-branch remote-rebase))) | |
(remote-url (and remote (magit-get "remote" remote "url"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
BEGIN{ | |
# $ENV{XSLATE} = ' dump=ast '; # @@@ @@@ | |
} | |
use Text::Xslate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: snippet -*- | |
# name: package | |
# key: package | |
# -- | |
package ${1:`(if (string-match "/lib/\\(.*\\)\\.pm" buffer-file-name) (replace-regexp-in-string "/" "::" (match-string 1 buffer-file-name)) "")`}; | |
use strict; | |
use warnings FATAL => qw(all); | |
$0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun toggle-camelcase-and-snakecase () | |
(interactive) | |
(let (start end bounds) | |
(if (and transient-mark-mode mark-active) | |
(progn | |
(setq start (mark)) | |
(setq end (point))) | |
(let ((bounds (bounds-of-thing-at-point 'symbol))) | |
(when bounds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar accelerated-move:buffer nil) | |
(defvar accelerated-move:count 0) | |
(defvar accelerated-move:point (make-hash-table)) | |
(defvar accelerated-move:table '(7 12 17 21 24 26 28 30)) | |
(defun accelerated-move:previous (&optional arg try-vscroll) | |
(interactive "^p\np") | |
(accelerated-move:do 'previous-line "previous" arg try-vscroll)) | |
(defun accelerated-move:next (&optional arg try-vscroll) |