Skip to content

Instantly share code, notes, and snippets.

View monzou's full-sized avatar

Takuro Monji monzou

  • Tokyo
View GitHub Profile
@brenes
brenes / info_boxes_wikpiedia_regexp.rb
Created September 8, 2011 13:30
Removing infoboxes from Wikipedia pages with a regexp
# INFO extracted from : http://stackoverflow.com/questions/6331065/matching-balanced-parenthesis-in-ruby-using-recursive-regular-expressions-like-pe
require 'wikipedia'
wikipage = Wikipedia.find(title)
# This regular expression is not valid for infoboxes with '}' (i.e: http://en.wikipedia.org/wiki/The_Royal_Anthem_of_Jordan)
no_infoboxes = wikipage.content.gsub(/\{\{[^\}]*\}\}/, "")
# This regular expression makes use of recursive regular expressions so now handles recursive {{}} structures
no_infoboxes = wikipage.content.gsub(%r{(?<re>\{\{(?:(?> [^\{\}]+ )|\g<re>)*\}\})}x, "")
@mzp
mzp / git-now
Created August 5, 2011 07:47
git-now
#!/bin/sh
PREFIX="from now"
MESSAGE="[${PREFIX}] `date +\"%Y/%m/%d %T\"`"
get_amend() {
if [ -z `git log --pretty=oneline -1 | cut -d " " -f 2- | grep "^\[${PREFIX}]"` ]
then
return 1
fi