Skip to content

Instantly share code, notes, and snippets.

@kiwanami
kiwanami / funcm.yasnippet
Created January 20, 2017 06:11
メソッドの関数定義を展開して、近所のレシーバーを自動で入れる
# -*- mode: snippet -*-
# name: golang method receiver
# key: sf
# --
func (${1:`(save-excursion
(let ((re "^func (\\([^\\)]*\\))"))
(cond
((or
(re-search-backward re nil t)
(re-search-forward re nil t))
(defmacro define-background-function-wrapper (bg-function fn)
(let ((is-loading-sym (intern (concat "*" (symbol-name bg-function) "-is-loading*"))))
`(progn
(defvar ,is-loading-sym nil)
(defun ,bg-function ()
(interactive)
(when ,is-loading-sym
(message ,(concat (symbol-name fn) " is already loading")))
(setq ,is-loading-sym t)
(make-thread (lambda ()
(defun my-fancy-startup-screen (&rest args)
(clear-image-cache)
(let* ((pwidth (window-pixel-width))
(pheight (* pwidth 0.75))
(file (expand-file-name "~/some-background.jpg"))
(tfile "/tmp/emacs-splash.jpg")
(color "white")
(font "/usr/share/fonts/corefonts/times.ttf")
(rt (/ pwidth 1000.0))
(size1 (* 80.0 rt)) (size2 (* 16.0 rt)) (size3 (* 24.0 rt))
@kiwanami
kiwanami / goemon.sh
Last active July 17, 2019 02:23
goemon と pandoc で md リアルタイムプレビュー
# ~/lib/goemon.yml と適当なCSSを準備。
# mdのファイルのある場所で以下のコマンドで起動。
# webサーバーはpythonでなくてもwebrickでもnginxでも何でも。
goemon -c ~/lib/goemon.yml python2.7 -m SimpleHTTPServer
@kiwanami
kiwanami / jsdoc.yasnippet
Last active December 17, 2016 04:27
JS の function の定義から、ある程度自動的に内容を拾ってjsdoc用のコメントをつくる yasnippet
# -*- mode: snippet -*-
# name: jsdoc comment
# key: doc
# --
/**
* $0
`(save-excursion
(let* ((pos-fun (re-search-forward "\\<function\\s-*(\\([^)]*\\))"))
(argstr (and pos-fun (match-string 1)))
(args (and pos-fun (split-string argstr ",\\s-*"))))
@kiwanami
kiwanami / ProcessRun.java
Last active August 29, 2015 14:18
Process.execにて、スレッド使わずに外部コマンド実行する
import java.io.*;
public class ProcessRun {
public static void main(String[] args) throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec("locate javac");
InputStream stdout = p.getInputStream();
InputStream stderr = p.getErrorStream();
int val = 0;
while (true) {
String so = readString(stdout);
@kiwanami
kiwanami / calfw-git.el
Last active August 14, 2023 16:27
Calendar view for git-log
;;; calfw-git.el --- calendar view for git-log
;; Copyright (C) 2014 SAKURAI Masashi
;; Author: SAKURAI Masashi <m.sakurai at kiwanami.net>
;; Keywords: calendar
;; 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
(let* ((source1
(lexical-let ((file "./some-schedule.org"))
(make-cfw:source
:name (concat "Org:" "TEST")
:data (lambda (begin end)
(let ((org-agenda-files (list file)))
(cfw:org-schedule-period-to-calendar begin end))))))
(cp (cfw:create-calendar-component-buffer
:view 'month
:contents-sources (list source1)
;;; syobo.el --- calfw for syoboi calendar
;; Copyright (C) 2014 @kiwanami
;; Author: @kiwanami
;; Keywords: calendar
;; 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
(require 'calfw)
(cfw:open-calendar-buffer)