Skip to content

Instantly share code, notes, and snippets.

@yuutayamada
yuutayamada / fizzbuzz.nim
Last active Oct 4, 2017
fizz buzz nim static version
View fizzbuzz.nim
type
fbEnum = enum
raw = 0
fizz = "Fizz\n" # 1
buzz = "Buzz\n" # 2
fizzBuzz = "FizzBuzz\n" # 3
template isFizz(i: typed): bool = i mod 3 == 0
template isBuzz(i: typed): bool = i mod 5 == 0
proc computeFizzBuzz(i: int): fbEnum =
View org-dwim.el
(defun org-dwim ()
"My convinience function for `org-mode'."
(interactive)
(cond
((org-in-block-p '("src"))
;; (org-in-src-block-p)
(org-edit-special))
((org-src-edit-buffer-p)
(org-edit-src-exit))
((org-table-p)
@yuutayamada
yuutayamada / auto-complete-with-yasnippet.el
Last active May 18, 2017
Use auto-complete with yasnippet on markdown-mode
View auto-complete-with-yasnippet.el
(add-hook 'markdown-mode-hook
'(lambda ()
(auto-complete-mode t)
(local-unset-key [tab])
(setq-local yas-fallback-behavior '(apply auto-complete))))
@yuutayamada
yuutayamada / use-mykie-el-with multiple-cursor.el
Created Jan 7, 2014
Use this snippet if you encountered some trouble when you are using mykie.el with multiple-cursor.el
View use-mykie-el-with multiple-cursor.el
(eval-when-compile (require 'cl))
(defun* my/set-keybinds (map &rest key-and-func)
(loop with use-keymap = (keymapp map)
for i from 0 to (1- (length key-and-func)) by 2
for key = (nth i key-and-func)
for formatted-key = (if (vectorp key) key (kbd key))
for func = (nth (1+ i) key-and-func)
if use-keymap
do (define-key map formatted-key func)
View expand zencoding in JavaScript's string
(require 'zencoding-mode)
(eval-when-compile (require 'cl))
(require 'flyspell)
(defun my/zencoding-expand ()
"Execute zencoding if current point is in string and
you can execute from minibuffer if you push C-u before this command"
(interactive)
(lexical-let*
((quote "['\"]")
@yuutayamada
yuutayamada / gist:2178022
Created Mar 24, 2012
Magit: search the commit message by anything
View gist:2178022
;;; search commit log by anything
(defvar anything-c-source-log-edit-comment
'((name . "Log-edit Comment")
(candidates . anything-c-log-edit-comment-candidates)
(action . (("Insert" . (lambda (str) (insert str)))))
(migemo)
(multiline))
"Source for browse and insert Log-edit comment.")
(defun anything-c-log-edit-comment-candidates ()