Skip to content

Instantly share code, notes, and snippets.

View hidsh's full-sized avatar

yakshaver hidsh

View GitHub Profile
;;; -*- Mode: Lisp; Package: editor -*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; .xyzzy ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; -*- Mode: Lisp; Package: editor -*-
;;;
;;; discrete.l
;;;
(provide "discrete")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;@@@ util
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@hidsh
hidsh / part_of_discrete.l
Created June 27, 2012 03:22
insert-horizontal-line
;; in discrete.l
isearch中に
C-w 選択範囲を1語前方(右)へ拡張
C-h 選択範囲を1語後方(左)へ拡張
C-y 選択範囲を行末まで拡張
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;@@@ insert-horizontal-line
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# utils
#
def usage(exit_code=0):
print USAGE_MSG
sys.exit(exit_code)
def error_exit(msg='error occurred. quit.'):
print msg
sys.exit()
@hidsh
hidsh / var_dump.py
Created June 27, 2012 03:23
python: PHPのvar_dump的なもの
# -*- coding: utf-8 -*-
"""
PHPのvar_dump的なもの
"""
from pprint import pprint
import types
def var_dump(obj, stream=None):
pprint(dump(obj), stream)
@hidsh
hidsh / unescape_html_ent.py
Created June 27, 2012 03:24
python: Removes HTML or XML character references and entities from a text string.
# unescape_html_ent.py
#
# thx:
# http://effbot.org/zone/re-sub.htm#unescape-html
import re, htmlentitydefs
##
# Removes HTML or XML character references and entities from a text string.
#
@hidsh
hidsh / koukai-kansu.py
Created June 28, 2012 03:23
python: 高階関数サンプル
>>> def caller(f):
return f(3)
>>> caller(lambda x: x*2)
6
>>> def qu(n):
return n*4
>>> caller(qu)
12
@hidsh
hidsh / dnd_rm_svn.bat
Created June 29, 2012 09:14
remove .svn
:: dnd_rm_svn.bat
::
:: ドラッグアンドドロップしたフォルダ内の .svnフォルダを再帰的に削除する
::
:: 使い方: フォルダをこのバッチファイルのアイコンにドラッグアンドドロップする
:: ローカルPC以外では動きません
@echo off
setlocal
@hidsh
hidsh / eratos.el
Created October 20, 2012 14:49
elisp: Sieve of Eratosthenes
(defun iota (max &optional min)
"minからmaxまでの整数をリストで返す。min省略時は1から。"
(unless min (setq min 1))
(if (< max min) nil
(cons min (iota max (1+ min)))))
(defun multiple-p (n of)
"nがofの倍数かどうかを返す。"
(if (= (% n of) 0) t nil))
@hidsh
hidsh / mark-fringe
Created October 22, 2012 07:52
elisp: fringe test
(defvar ol-mark-fringe nil)
(defun fr ()
(interactive)
(let ((s (make-string 1 ?x)))
(when ol-mark-fringe (delete-overlay ol-mark-fringe))
(setq ol-mark-fringe (make-overlay (point) (1+ (point))))
(put-text-property 0 1 'display '(left-fringe right-triangle) s)
(overlay-put ol-mark-fringe 'before-string s)))