Skip to content

Instantly share code, notes, and snippets.

@knagano
knagano / kn-heisei.el
Created August 26, 2015 05:01
平成
(defun kn-heisei ()
(interactive)
(message "平成%d" (- (nth 5 (decode-time)) 1988)))
(defalias 'heisei 'kn-heisei)
@knagano
knagano / update_chromium.sh
Created August 28, 2014 04:25
Update Chromium for Mac
#!/bin/bash
cd /var/tmp
curl -L https://download-chromium.appspot.com/dl/Mac >chrome-mac.zip
unzip chrome-mac.zip
rm chrome-mac.zip
rm -rf ~/Applications/Chromium.app
mv chrome-mac/Chromium.app ~/Applications/
rmdir chrome-mac
;; 普通の1行電卓のM-x calculatorより逆ポー電卓のM-x calcのほうがタイプ数短いのずっと納得行ってない
;; calculatorをclcに逃す
;; clはCommon Lispと被っておかしくなるのが不安だし、M-x calは15年以上calendarに割り当てていて染み付いているので
(defalias 'cal 'calendar)
(defalias 'clc 'calculator)
@knagano
knagano / hosts_edit.bat
Created November 7, 2013 03:38
open notepad as Administrator to edit hosts elevate.exe: http://code.kliu.org/misc/elevate/
C:\path\to\elevate.exe notepad C:\Windows\System32\drivers\etc\hosts
@knagano
knagano / smtp_using_bash_only.sh
Created October 22, 2013 01:47
smtp using bash only
exec 42<>/dev/tcp/127.0.0.1/smtp
(echo 'HELO localhost' \
;echo 'mail from:foo@example.com' \
;echo 'rcpt to:bar@example.com' \
;echo 'data' \
;echo 'From:foo@example.com' \
;echo 'To:bar@example.com' \
;echo 'Subject:qux' \
;echo '' \
;echo 'quux' \
function di() {
diff -uN --ignore-all-space $@
}
@knagano
knagano / getmail_wait1sec.diff
Created July 11, 2013 08:23
getmail_wait1sec
--- /usr/bin/getmail 2010-01-05 00:52:45.000000000 +0900
+++ getmail_wait1sec 2013-07-11 17:12:01.000000000 +0900
@@ -185,6 +185,15 @@
break
if msg is not None:
+
+ #time.sleep(2) #knagano
+ #knagano wait at least 1sec
+ time_before = time.time()
@knagano
knagano / initializecheck.php
Last active December 14, 2015 12:48
dragon collection initializecheck.php anti-pc players & bots
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/1.1) 1.0//EN" "i-xhtml_4ja_10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<noscript><meta http-equiv="refresh" content="1;URL=sessionerror.php?errorcode=90002" /></noscript>
<style>:root{background: #000000;}</style>
<script type="text/javascript" src="http://aimg-pf.gree.net/js/app/touch.js?201304051400\"></script>
<script type="text/javascript">
<!--
var is_pc = 0;
@knagano
knagano / ack.el
Last active September 28, 2015 09:58
M-x ack
(defun ack ()
(interactive)
(let ((buf (get-buffer "*grep*")))
(and buf (kill-buffer buf)))
(let ((save grep-find-command))
(grep-apply-setting 'grep-find-command "ack --nocolor --nogroup ")
(unwind-protect
(call-interactively 'grep-find)
(grep-apply-setting 'grep-find-command save))))
@knagano
knagano / tomcat_restart.sh
Created November 1, 2011 02:55
restart Tomcat
#!/bin/bash
function tomcatchk() {
tmp=$(ps auxww |grep tomcat |grep java |wc -l)
if [ $tmp = '0' ]; then
return 1 #false
fi
return 0 #true
}