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 / report_env.rb
Created August 16, 2015 10:15
GLFW on Mac mini (Late 2014) : We need to pass some window hints to enable OpenGL 4.1 context; otherwise we'll get old OpenGL 2.1 context.
# coding: utf-8
#
# opengl-bindings
# * http://rubygems.org/gems/opengl-bindings
# * http://github.com/vaiorabbit/ruby-opengl
#
require 'opengl'
require 'glfw'
OpenGL.load_lib()
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <stdio.h>
int main(int argc, char **argv)
{
CGLContextObj ctx;
CGLPixelFormatObj pix;
GLint npix;
int attribs[] = {
@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 / 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