Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
#!/usr/bin/env ruby
# GET english examples from SpaceAlc
require 'uri'
require 'open-uri'
require 'rubygems'
require 'nokogiri'
def e2j(eng)
eng.downcase.gsub("east", "東").gsub("north", "北").gsub("south", "南").gsub("west", "西").gsub("e", "東").gsub("n", "北").gsub("s", "南").gsub("w", "西")
end
;; http://article.gmane.org/gmane.emacs.orgmode/10256
(defun org-get-heading-title ()
"Returns the heading of the current entry as a string, without the leading stars, the TODO keyword or the tags."
(let ((title-with-props (org-get-heading t))
(keyword (org-get-todo-state)))
(substring-no-properties title-with-props (if keyword (1+ (length keyword))))))
(defun org-insert-heading-category ()
"Insert a :CATEGORY: property and it's value to the PROPERTY drawer at point."
(interactive)
(defun untabify-buffer ()
(interactive)
(untabify 1 (point-max))
(if (not (eq major-mode 'mew-draft-mode))
;; delete-trailing-whitespace does not work in mew-draft-mode.
(delete-trailing-whitespace)))
(defmacro errhdlr (&rest body)
"do body in condition-case"
(declare (indent 0) (debug t))
(list 'condition-case 'err (cons 'progn body)
(list 'error
(list 'message "%s"
(list 'error-message-string 'err)))
(list 'file-error
(list 'message "%s"
(list 'error-message-string 'err)))))
(defun delete-file-kill-buffer ()
"Do delete-file function then kill-buffer function"
(interactive)
(let ((buf (current-buffer))
(filepath (buffer-file-name (current-buffer))))
(when (and
(not (null filepath))
(file-exists-p filepath))
(delete-file filepath))
(kill-buffer buf)))
@takumikinjo
takumikinjo / .gitignore
Created August 5, 2010 13:56
HTML5 Presentation export for Org-mode
README.html
@takumikinjo
takumikinjo / generate-rss-xml.sh
Created October 30, 2010 05:33
Gather hash-tagged Twitter tweets and save them as a yaml file.
#!/bin/bash
# needs ruby-1.9.2.
for i in `ls *.yml`; do
j=${i%.yml}
cat <<EOF > $j.xml
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="rdf.xsl" type="text/xsl"?>
<rdf:RDF xmlns="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
@takumikinjo
takumikinjo / org2doku
Created March 21, 2011 07:19
Convert Emacs org-mode formatted text to Dokuwiki formatted one.
#!/usr/bin/env perl
# Usage
#
# cat <<EOF | ./org2doku
# * heading
#
# - item
# - sub item
#
@takumikinjo
takumikinjo / elnode-org-export-as.el
Created May 4, 2011 04:26
An example using elnode.el
;;; elnode-org-export-as.el --- An example using elnode.el.
;; Copyright (C) 2011 Takumi KINJO
;; Author: Takumi KINJO <[email protected]>
;; Created: 5th May 2011
;; Version: 0
;; Keywords: lisp
;; This file is NOT part of GNU Emacs.