Skip to content

Instantly share code, notes, and snippets.

@d5884
d5884 / brainf*ck
Created February 2, 2010 02:29
adhock implementation of brainf*ck
#include <stdio.h>
#include <stdlib.h>
#define INPUT_BUFSIZE 4096
#define HEAP_SIZE 65535
#define SYM_INC_PTR '>'
#define SYM_DEC_PTR '<'
#define SYM_ADD_CUR '+'
#define SYM_SUB_CUR '-'
@d5884
d5884 / fizzbuzz.c
Created February 20, 2010 02:53
fizzbuzz
#include <stdio.h>
int main()
{
int i, five, three;
for (i = 1; i <= 100; i++) {
three = i % 3;
five = i % 5;
@d5884
d5884 / init.el
Created December 19, 2011 12:08
to use interruption keys in shell-mode
(defadvice comint-interrupt-subjob (around ad-comint-interrupt-subjob activate)
(process-send-string nil "\C-c"))
(defadvice comint-stop-subjob (around ad-comint-interrupt-subjob activate)
(process-send-string nil "\C-z"))
(defadvice comint-send-eof (around ad-comint-send-eof activate)
(process-send-string nil "\C-d"))
@d5884
d5884 / init.el
Created December 19, 2011 15:29
cl suppress warning
(require 'cl nil t)
(setq byte-compile-warnings '(not cl-functions))
;; to use cl-lib
(require 'inf-ruby)
;; from http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/20892
(define-key inferior-ruby-mode-map (kbd "TAB") 'inferior-ruby-complete-or-tab)
(defun inferior-ruby-completions (seed)
"Return a list of completions for the line of ruby code starting with SEED."
(let* ((proc (get-buffer-process ruby-buffer))
(comint-filt (process-filter proc))
(kept "") completions)
@d5884
d5884 / google-maps.el
Created July 30, 2012 02:23
google maps localization
;; google-map / git clone http://git.naquadah.org/git/google-maps.git
(when (locate-library "google-maps")
(autoload 'google-maps "google-maps" nil t)
(eval-after-load "google-maps"
'(progn
(when (require 'popwin nil t)
(add-to-list 'popwin:special-display-config '("*Google Maps*")))
(defadvice google-maps-static-show (before ini:ad-google-maps-set-lang
@d5884
d5884 / scratch-20120111.el
Created July 30, 2012 12:07
color changer
;; 明るさ変更
(labels ((rgb-to-ycrcb (r g b)
(mapcar (lambda (v)
(round v 1000))
(list (+ (* 299 r) (* 587 g) (* 114 b))
(+ (* 500 r) (* -418.69 g) (* -81.31 b))
(+ (* -168.74 r) (* -331.26 g) (* 500 b)))))
(ycrcb-to-rgb (y cr cb)
(let ((y (* y 1000)))
(mapcar (lambda (v)
@d5884
d5884 / gist:3252900
Created August 4, 2012 00:10
function coding system
(defmacro in:set-function-coding-system (function decoding encoding)
"関数使用時のコーディングシステムを設定する.
関数 FUNCTION に対し、実行時に DECODING を `coding-system-for-read' に、
ENCODING を `coding-system-for-write' に設定する advice を作成、活性化する."
`(defadvice ,function (around
,(intern (format "in:ad-%s-coding-setup" function))
activate compile)
,(format "関数実行時のコーディングシステムを以下に置き換える.
`coding-system-for-read': %s
`coding-system-for-write': %s" (eval decoding) (eval encoding))
;;; locate-file-cache.el --- Support cache for locate-file.
;; Copyright (C) 2013 Daisuke Kobayashi
;; Author: Daisuke Kobayashi <d5884jp@gmail.com>
;; Keywords: extensions
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; helm のサスペンドステータス更新系
(with-eval-after-load "helm"
(defun ini:helm-set-suspend-update-flag (status)
(when (and status (not helm-suspend-update-flag))
(helm-kill-async-processes)
(setq helm-pattern ""))
(setq helm-suspend-update-flag status))
(defadvice mozc-mode (after ini:mozc-helm-suspender-init activate)
(when (helm-alive-p)