Skip to content

Instantly share code, notes, and snippets.

View knu's full-sized avatar

Akinori Musha knu

  • Tokyo, Japan
  • 09:20 (UTC +09:00)
  • X @knu
View GitHub Profile
// ==UserScript==
// @name FriendFeed quotation
// @namespace greasemonkey.akinori.org
// @description Make quotations visual on FriendFeed
// @include http://friendfeed.com/*
// ==/UserScript==
(function () {
var ffqNode = function (text) {
var span = document.createElement('span');
require 'etc'
user = Etc.getpwnam("knu")
~user #=> "/home/knu"
Index: ext/etc/etc.c
===================================================================
--- ext/etc/etc.c (revision 23702)
+++ ext/etc/etc.c (working copy)
@@ -603,6 +603,7 @@ Init_etc(void)
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# Requirements:
# - rubygems
# - nokogiri (gem install nokogiri)
#
# Example Usage:
# ./50oui2ki2 http://www.chunichi.co.jp/igo-shogi/50oui/text.html 50oui-1
autoload -U zmv
ren () {
if [ $# -eq 1 ]; then
# Interactive edit
local newname="$1"
vared -c -p 'rename to: ' newname
command mv "$1" "$newname"
else
# Allow bare globbing
noglob zmv -W "$@"
# Put the following after defining PROMPT
if [ -n "$INSIDE_EMACS" ]; then
PROMPT="AnSiTu %n
AnSiTh %M
AnSiTc %d
$PROMPT"
fi
# Note the escape character right before each "AnSiT"
(eval-after-load "term"
'(progn
(setq term-prompt-regexp "^[^%]*%\\(\e\\[[0-9]*[A-Za-z]\\)* ")
(defun term-send-backspace () (interactive) (term-send-raw-string "\C-h"))
(define-key term-raw-escape-map "." 'term-line-mode)
(define-key term-mode-map "\C-c." 'term-char-mode)))
(autoload 'shell-toggle "shell-toggle"
"Toggles between the *shell* buffer and whatever buffer you are editing."
t)
@knu
knu / editmsg
Created November 2, 2009 13:17
#!/bin/sh
#
# editmsg - prompts user to input a message using an editor
#
# Copyright (c) 2007, 2008, 2009 Akinori MUSHA
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
module Enumerable
def filter
Enumerator.new { |y|
begin
each { |x|
yield(x, y)
}
rescue LocalJumpError => e
end
}
@knu
knu / filter.rb
Last active September 4, 2015 00:04
module Enumerable
def filter(&block)
Enumerator.new { |y|
begin
each_with_object(y, &block)
rescue LocalJumpError => e
# handle break
raise unless /\Abreak from / === e.message
end
}