Skip to content

Instantly share code, notes, and snippets.

View vaiorabbit's full-sized avatar
🎮
busy playing video games

vaiorabbit

🎮
busy playing video games
View GitHub Profile
@vaiorabbit
vaiorabbit / TwitterBackup.rb
Created May 30, 2011 14:28
Collects tweets posted by specified user.
# -*- coding: utf-8-unix -*-
#
# Tested on :
# - Ruby 1.9.2-p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
#
# Usage : $ ruby TwitterBackup.rb [user name]
#
require 'date'
require 'net/http'
require 'rexml/document'
@vaiorabbit
vaiorabbit / HoughCircles.py
Created June 19, 2011 15:01
HoughCircles.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# USAGE : $ ./HoughCircles.py Media/foo.jpg
import cv
import sys
if __name__ == "__main__":
image = cv.LoadImage(sys.argv[1], cv.CV_LOAD_IMAGE_GRAYSCALE)
src = cv.LoadImage(sys.argv[1])
@vaiorabbit
vaiorabbit / gist:1075729
Created July 11, 2011 12:09
std::tr1::bind
#include <algorithm>
#include <tr1/functional>
#include <vector>
struct Contact
{
Vec3 Position;
// ...
};
@vaiorabbit
vaiorabbit / dec2bin.el
Created January 1, 2012 11:11
dec2bin.el
; Example:
; * M-x dec2bin -> Decimal: 10 [Enter] -> 1010
; * (dec2bin 10) -> "1010"
; * C-u 10 M-x dec2bin -> 1010
; Ref.:
; * Basic syntax : http://xahlee.org/emacs/elisp_basics.html
; * concat : http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Strings.html
; * called-interactively-p : http://www.gnu.org/software/emacs/manual/html_node/elisp/Distinguish-Interactive.html
(defun dec2bin (n)
"Returns binary expression of decimal number N."
@vaiorabbit
vaiorabbit / markdown-aux-insert-unordered-list-item.el
Created February 21, 2012 16:12
markdown-aux-insert-unordered-list-item
;; (autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
;; 箇条書き入力支援
;; Ref.: Emacs Lisp Idioms (for writing interactive commands) - Get Current Word or Line
;; http://xahlee.org/emacs/elisp_idioms.html
;; Inconsistent Behavior for 'line
;; http://xahlee.blogspot.com/2011/02/emacs-lisp-using-thing-at-point.html
(setq markdown-aux-unordered-list-item-string "* ")
(defun markdown-aux-insert-unordered-list-item ()
"Insert `markdown-aux-unordered-list-item-string'."
@vaiorabbit
vaiorabbit / gist:1891633
Created February 23, 2012 08:48
unnamed-memo.el
;;; -*- mode: emacs-lisp; coding: iso-2022-7bit -*-
(defvar unnamed-memo-default-filename "~/memo/%Y/%Y-%m-%d-%H%M%S.")
(defvar unnamed-memo-default-suffix "mdwn")
(defvar unnamed-memo-default-header "<!-- -*- mode:markdown; coding:utf-8; -*- -->\n\n")
(defvar unnamed-memo-default-time-format "[%Y-%m-%d %H:%M:%S(%a)]")
(defun unnamed-memo-aux-new-file-sequence (time)
(setq buffer-file-coding-system 'utf-8)
(insert unnamed-memo-default-header)
@vaiorabbit
vaiorabbit / excerpt_from_lv.c
Created February 23, 2012 15:19
Excerpt from lv.c
/* lv.c */
#define GREP_COMMAND "lgrep"
/* ... */
private void LvInit( byte **argv )
{
/* ... */
@vaiorabbit
vaiorabbit / lv451-OptionF.diff
Created February 23, 2012 15:35
LV Version 4.51 : patch for '-F' to select filename display
diff -u src_orig/conf.c src/conf.c
--- src_orig/conf.c 2004-01-05 16:23:29.000000000 +0900
+++ src/conf.c 2012-02-24 00:20:06.000000000 +0900
@@ -285,6 +285,7 @@
case 'd': casefold_search = TRUE; s++; continue;
case 'i': casefold_search = TRUE; s++; continue;
case 'f': regexp_search = FALSE; s++; continue;
+ case 'F': show_filename = TRUE; s++; continue;
case 'g': grep_mode = TRUE; s++; continue;
@vaiorabbit
vaiorabbit / texmath2png.rb
Created April 7, 2012 11:42
Converts math formula (written in TeX language) into PNG file via Google Chart API.
# -*- coding: utf-8 -*-
require 'date'
require 'uri'
require 'net/http'
USAGE = <<EOL
Converts math formula (written in TeX language) into PNG file via Google Chart API.
USAGE: $ ruby #{__FILE__} "Formula_in_TeX_language"
ex.) ruby chartapi.rb "x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"
EOL
@vaiorabbit
vaiorabbit / texmath2png.html
Created April 7, 2012 15:53
Converts math formula (written in TeX language) into PNG file via Google Chart API.
<html>
<head>
<script type="text/javascript">
function reload_formula(tex_math)
{
// Ref.: Comparing escape(), encodeURI(), and encodeURIComponent()
// http://xkr.us/articles/javascript/encode-compare/
document.getElementById("formula_image").src = "https://chart.googleapis.com/chart?cht=tx&chl=" + encodeURIComponent(tex_math);
}
</script>