Skip to content

Instantly share code, notes, and snippets.

View kyanagi's full-sized avatar

Kouhei Yanagita kyanagi

View GitHub Profile
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
#!/usr/bin/env ruby
# Merge zsh's history files and print them to stdout.
# Entries are sorted by timestamp.
#
# usage:
# merge-zsh-history file1 file2 ...
# format of history entry
#
require 'date'
require 'google_drive'
require 'pixela'
CREDENTIAL_PATH = File.join(__dir__, 'secret', 'credential.json')
SPREADSHEET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
PIXELA_USERNAME = 'xxxxxxxxx'
PIXELA_TOKEN = 'xxxxxxxxx'
PIXELA_GRAPH_ID = 'xxxxxxxxxx'
def run
results = []
1.upto(100000) do |i|
results.push(rand(2))
results.shift if results.size == 4
if results.size == 3 && results.uniq.size == 1
return i
end
end
require 'active_record'
class Foo < ActiveRecord::Base; end
module Bar
refine Integer do
define_method(:+) { }
end
end
(defun kill-buffer-file-name (nondirectory-p)
(interactive "P")
(let ((file-name (buffer-file-name)))
(if (stringp file-name)
(progn
(when nondirectory-p
(setq file-name (file-name-nondirectory file-name)))
(message "%s" file-name)
(kill-new file-name))
(error "This buffer does not visit a file"))))
function bundle-cd {
local output exit_status
output=`bundle show $1`
exit_status=$?
if [ $exit_status -eq 0 ]; then
cd "$output"
else
echo $output 1>&2
return $exit_status
fi
@kyanagi
kyanagi / gist:1955722
Created March 2, 2012 04:37
anything-minibuffer-history: replace minibuffer contents
(setcdr (assoc 'action anything-c-source-minibuffer-history)
(lambda (candidate)
(delete-minibuffer-contents)
(insert candidate)))
function shogun {
:
}
function _shogun {
local -a _names
_names=(
Ieyasu
Hidetada
if type growlnotify > /dev/null 2>&1
then
GROWL_REPORTTIME=5
COMMAND=
COMMAND_START_TIME=0
function reset_command_start_time {
COMMAND="${1}"
COMMAND_START_TIME=`date +%s`
echo $COMMAND
}