Skip to content

Instantly share code, notes, and snippets.

@nurse
nurse / gist:22763
Created November 7, 2008 02:47
patch for nkf
Index: ext/nkf/nkf-utf8/nkf.c
===================================================================
--- ext/nkf/nkf-utf8/nkf.c (revision 20127)
+++ ext/nkf/nkf-utf8/nkf.c (working copy)
@@ -33,7 +33,7 @@
***********************************************************************/
#define NKF_IDENT "$Id$"
#define NKF_VERSION "2.0.8"
-#define NKF_RELEASE_DATE "2008-10-28"
+#define NKF_RELEASE_DATE "2008-11-07"
/* 強調タグを追加 */
function emphasizeWord(word) {
return '<strong>' + word + '</strong>';
}
/* 長い順に並べるための比較関数 */
function compareLengthDecrease(a, b) {
a = a.length;
b = b.length;
return a > b ? -1 : a < b ? 1 : 0;
ALLOW_TAGS = %w/font span p b br/
def validate_xml_fragment
str = self
tags = str.scan(/\G(?:(<[^<>]+>)|[^<>&]+|[^&<>]*(?:&#?\w+;[^&<>]*)+)/)
return ERB::Util.html_escape(str) unless $'.empty?
stack = []
tags.each do |tag|
case tag.first
when /<(\w+)(?: +\w+=(?:"[^"]*"|'[^']*'|\w+))* *(\/)?>/
return ERB::Util.html_escape(str) unless ALLOW_TAGS.include?($1)
r = Regexp.compile(<<'__REGEXP__'.strip, Regexp::EXTENDED)
(?<json> \g<object> | \g<array> ){0}
(?<begin-array> \g<ws> \[ \g<ws> ){0}
(?<begin-object> \g<ws> \{ \g<ws> ){0}
(?<end-array> \g<ws> \] \g<ws> ){0}
(?<end-object> \g<ws> \} \g<ws> ){0}
(?<name-separator> \g<ws> : \g<ws> ){0}
(?<value-separator> \g<ws> , \g<ws> ){0}
(?<ws> [\x20\t\n\r]* ){0}
(?<value> false | null | true | \g<object> | \g<array> | \g<number> | \g<string> ){0}
@nurse
nurse / twitterbot.nb
Created April 13, 2009 05:17
twitter bot for nadoka
# -*-ruby-*-
#
# Acknowledgement
# @ko1_twitter
# http://uno.ac/d/20070727.html
# http://iseebi.half-done.net/diary/?date=20070417#p01
# http://mono.kmc.gr.jp/~yhara/d/?date=20070421#p02
# http://www.rubyist.net/~nobu/t/20051013.html#p02
require 'cgi'
require 'net/http'
@nurse
nurse / gist:213354
Created October 19, 2009 13:25
Xi Bot for nadoka
#
# Xi Bot
#
# No rights reserved.
#
# Synopsis:
# xi> 2d10 (two dice of ten)
# [2d10] 13 = 7 + 6
# xi> 5d
# [5d6] 14 = 3 + 1 + 3 + 1 + 6
@nurse
nurse / gist:259236
Created December 18, 2009 02:21
MarldiaBot for nadoka
# -*-ruby-*-
require 'cgi'
require 'net/http'
require 'rexml/document'
require 'uri'
require 'time'
class MarldiaBot < Nadoka::NDK_Bot
def bot_initialize
@chats = @bot_config.fetch(:chats, nil)
Index: lib/libpthread/pthread.c
===================================================================
RCS file: /cvsroot/src/lib/libpthread/pthread.c,v
retrieving revision 1.106.2.2
diff -u -p -r1.106.2.2 pthread.c
--- lib/libpthread/pthread.c 11 Jan 2010 00:47:29 -0000 1.106.2.2
+++ lib/libpthread/pthread.c 8 Feb 2010 22:59:19 -0000
@@ -261,6 +261,8 @@ pthread__child_callback(void)
* much. Anything that permits some pthread_* calls to work is
* merely being polite.
@nurse
nurse / merger.rb
Created June 5, 2010 04:22
Merger for Ruby
#! /bin/ruby
# http://coderepos.org/share/browser/docs/shyouhei/ruby%20development/merger.rb
require 'date'
require 'tempfile'
$repos = 'svn+ssh://svn@ci.ruby-lang.org/ruby/'
ENV['LC_ALL'] = 'C'
def help
@nurse
nurse / abnf2onig.rb
Created March 30, 2011 05:56
ABNF to Oniguruma Regexp Converter
#!/usr/local/bin/ruby
# If you want an ABNF to Regexp, see below.
# http://www.a-k-r.org/abnf/
# https://github.com/martinthomson/abnf2regex
require 'strscan'
RULENAME_ = /[A-Za-z][A-Za-z0-9\-]*/
C_WSPP_ = /[ \t]+(?:(?:;.*)?\n[ \t]+)*|(?:(?:;.*)?\n[ \t]+)+/
C_WSPS_ = /[ \t]*(?:(?:;.*)?\n[ \t]+)*/
C_NL_ = /(?:;.*)?\n/