Skip to content

Instantly share code, notes, and snippets.

@kobapan
kobapan / uri-get.scm
Created April 6, 2020 02:33
get html body with uri (Gauche Scheme lisp)
(use rfc.http) ; http-get http-compose-query
(use rfc.uri) ; uri-parse uri-compose
(define (uri-get uri :key (query #f))
(if query (set! uri (string-append uri (if (car query) (http-compose-query "" query)
#"&~(http-compose-query #f (cdr query))"))))
(receive (code status body)
(receive (scheme user-info hostname port path query frament)
(uri-parse uri)
(http-get hostname (uri-compose :path path :query query)))
@kobapan
kobapan / eval-print-region.el
Last active October 17, 2022 09:40
リージョン選択範囲、もしくは現在行のLisp 式を(1つ)読み込み、評価した結果を、次行に挿入する
(defun eval-print-region ()
(interactive)
(let ((f (lambda (s e)
(print (eval (read (replace-regexp-in-string "," "" (buffer-substring s e)))) (current-buffer)))))
(if (region-active-p)
;; リージョン全体
(funcall f (region-beginning) (region-end))
;; カーソルのある行全体
(progn (end-of-line)
(funcall f (point-at-bol) (point-at-eol))))))
@kobapan
kobapan / exif.sh
Last active September 29, 2022 00:17
Show or Update the exif ImageDescription and DateTimeOriginal in command line
#!/usr/bin/env bash
# exif.sh
# usage
usage_exit() {
if [[ $1 ]]; then echo "error $1"; fi
echo "---
Usage:
;;; Depentancy:
;;
;; e2ps
;; ps2pdf
;; sudo apt install e2ps; sudo apt install ghostscript ;
;;; Usage:
;;
;; M-x e2ps-ps2pdf
;; 保存ディレクトリを選ぶ
@kobapan
kobapan / call-sxiv.el
Last active January 19, 2018 08:08
emacsのdiredでsxivを呼び出して、ディレクトリ内の全画像を表示する。
(defun call-sxiv ()
(interactive)
(let ((image-files;画像ファイル名のリスト
(delq nil;この辺はemacs26辺りで filterマクロに置き換えか?
(mapcar
(lambda (f)
(when (string-match
"\.\\(jpe?g\\|png\\|gif\\|bmp\\)$"
f )
f ))
@kobapan
kobapan / sudo.el
Last active January 10, 2018 08:11
一般ユーザでemacsを起動しているのに、root権限のフィルを編集したくなることが多かったらこれ
;;; sudo.el ---
;; Author: kobapan <[email protected]>
;; Keywords: emacs,lisp
;; 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
;; (at your option) any later version.
@kobapan
kobapan / homepage_watcher.sh
Last active October 11, 2017 08:28
【sh】RSS を配信していないホームページで、指定したhtmlに更新(変化)があった場合に、メールでお知らせする
#! /bin/sh
# RSS を配信していないホームページで、指定したhtmlに更新(変化)があった場合に、メールでお知らせする
# cron で利用する
url=http://hogehoge.ne.jp
title="「ほげほげ」で更新がありました"
[email protected]
[email protected]
@kobapan
kobapan / Bookmarklet_Clip_to_Evernote.js
Created July 6, 2016 23:41
Bookmarklet_Clip_to_Evernote.js
javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})()
@kobapan
kobapan / Bookmarklet_add_Pocket.js
Last active July 11, 2016 04:04
Bookmarklet_add_Pocket.js
javascript:(function(){var%20e=function(t,n,r,i,s){var%20o=[1340913,5798130,5000562,5283307,5168011,1469845,5181843,5267827,5592619,3956242];var%20i=i||0,u=0,n=n||[],r=r||0,s=s||0;var%20a={'a':97,'b':98,'c':99,'d':100,'e':101,'f':102,'g':103,'h':104,'i':105,'j':106,'k':107,'l':108,'m':109,'n':110,'o':111,'p':112,'q':113,'r':114,'s':115,'t':116,'u':117,'v':118,'w':119,'x':120,'y':121,'z':122,'A':65,'B':66,'C':67,'D':68,'E':69,'F':70,'G':71,'H':72,'I':73,'J':74,'K':75,'L':76,'M':77,'N':78,'O':79,'P':80,'Q':81,'R':82,'S':83,'T':84,'U':85,'V':86,'W':87,'X':88,'Y':89,'Z':90,'0':48,'1':49,'2':50,'3':51,'4':52,'5':53,'6':54,'7':55,'8':56,'9':57,'\/':47,':':58,'?':63,'=':61,'-':45,'_':95,'&':38,'$':36,'!':33,'.':46};if(!s||s==0){t=o[0]+t}for(var%20f=0;f<t.length;f++){var%20l=function(e,t){return%20a[e[t]]?a[e[t]]:e.charCodeAt(t)}(t,f);if(!l*1)l=3;var%20c=l*(o[i]+l*o[u%o.length]);n[r]=(n[r]?n[r]+c:c)+s+u;var%20p=c%(50*1);if(n[p]){var%20d=n[r];n[r]=n[p];n[p]=d}u+=c;r=r==50?0:r+1;i=i==o.length-1?0:i+1}if(s==140){var%20v
@kobapan
kobapan / mutt_vte.py
Last active June 9, 2016 03:29
create a virtual terminal for the mutt mail client
#!/usr/bin/env python3
# libvte-2.90-9
from gi.repository import Gtk, Vte, GLib
class VteWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self) # now self means Gtk.Window object
# Create a virtual terminal