Skip to content

Instantly share code, notes, and snippets.

@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/
@nurse
nurse / merge-json.sh
Created July 8, 2011 09:04
To merge json gem to ruby repo
#!/bin/sh
# you should merge https://github.com/nurse/json/tree/fix-extconf before merging
dest=$1
cp -R lib/* $dest/ext/json/lib
cp -R ext/json/ext/* $dest/ext/json
cp -R tests/* $dest/test/json
cd $dest/ext/json/lib/json/
rm -rf *.xpm pure* ext editor.rb add/rails.rb
@nurse
nurse / gist:1104171
Created July 25, 2011 13:52
git-up - update the repository
#!/bin/sh
# If you may use this through git like git up,
# add a line like following to [alias] section of ~/.gitconfig
# up = "!~/bin/git-up"
if [ -d tools/clang ]
then
svn up
cd tools/clang
svn up
@nurse
nurse / gist:1129437
Last active September 26, 2015 16:57
Get the path of ruby binary
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 2bd2e30..9da0ed7 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -597,6 +597,155 @@ etc_systmpdir(void)
return tmpdir;
}
+#ifdef _WIN32
+# define RUBYPATH_GetModuleFileName
@nurse
nurse / charwidth.cs
Created August 13, 2011 22:34
Show the width of the character
using System;
using System.Drawing;
using System.Windows.Forms;
class CharacterWidth
{
static void Main(string[] args)
{
Font font = new Font("MS Gothic", 12, GraphicsUnit.Pixel);
for (char c = '!'; c < 0x0301; c++) {
@nurse
nurse / gist:1183041
Created August 31, 2011 07:59
File::Stat#birthtime
diff --git a/configure.in b/configure.in
index 0bbc444..da8d58d 100644
--- a/configure.in
+++ b/configure.in
@@ -1171,6 +1171,8 @@ AC_CHECK_MEMBERS([struct stat.st_mtimensec])
AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_ctimespec])
AC_CHECK_MEMBERS([struct stat.st_ctimensec])
+AC_CHECK_MEMBERS([struct stat.st_birthtimespec])
+AC_CHECK_MEMBERS([struct stat.st_birthtimensec])
@nurse
nurse / gist:1208392
Created September 10, 2011 14:53
Ruby with Onigmo
1) Failure:
test_parse_utf8(TestDateParse) [/home/naruse/ruby/test/date/test_date_parse.rb:651]:
<"日本"> expected but was
<nil>.
2) Failure:
test_regexp_named_class(TestM17N) [/home/naruse/ruby/test/ruby/test_m17n.rb:543]:
Expected /[[:space:]]/ to match " ".
3) Failure:
@nurse
nurse / gist:1241551
Created September 26, 2011 03:23
Patch for Realtek NIC sticks on QEMU against NetBSD current
Index: rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.133
diff -u -r1.133 rtl8169.c
--- rtl8169.c 28 Jul 2010 23:30:21 -0000 1.133
+++ rtl8169.c 19 Sep 2011 18:53:39 -0000
@@ -110,7 +110,10 @@
* jumbo frames larger than 7.5K, so the max MTU possible with this
* driver is 7500 bytes.
@nurse
nurse / gist:1380159
Created November 20, 2011 11:18
kern/162379
Index: sys/kern/sys_generic.c
===================================================================
--- sys/kern/sys_generic.c (revision 227609)
+++ sys/kern/sys_generic.c (working copy)
@@ -919,8 +919,27 @@
swizzle_fdset(ibits[1]);
swizzle_fdset(ibits[2]);
- if (nbufbytes != 0)
+ if (nbufbytes != 0) {
@nurse
nurse / chat.cgi
Created January 7, 2012 18:52
TeaChat with flock(2)
#!/usr/local/bin/perl
# ---------------------------------------------------
#
# TeaChat
$version = '1.8.4b'; # 04/01/19 00:29
# (c) 1998-2004 Toshikazu.S All rights reserved.
#
# URL : http://www.teachat.org/
# E-Mail : webmaster@teachat.org