Skip to content

Instantly share code, notes, and snippets.

View yanbe's full-sized avatar

yanbe

View GitHub Profile
@yanbe
yanbe / ac-python-complete.el
Created September 25, 2010 23:51
Source definition of Auto Complete Mode for Python module contents.
(defun ac-python-candidates ()
(python-find-imports)
(car (read-from-string
(python-send-receive
(format "emacs.complete(%S,%s)"
(python-partial-symbol)
python-imports)))))
(ac-define-source python
'((candidates . ac-python-candidates)
@yanbe
yanbe / installing-pptpd-on-qnap-nas.txt
Created November 9, 2010 11:53
QNAP製のNAS (Intel CPU) で PPTP Server を起動するまでの手順
# デフォルトではppp関連のモジュールが存在しないのでQNAPが公開しているカーネル
# コンフィグファイルを取得し、自分でコンパイルする必要がある
$ cd /share/MD0_DATA/(適当な作業ディレクトリ)
$ wget http://resources.qnap.com/Storage/tsd/QNAP_GPL_3.3.3-20100928.tar.gz
$ wget ftp://ftp.jp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.33.2.tar.gz
$ tar xzvf QNAP_GPL_3.3.3-20100928.tar.gz
$ tar xzvf linux-2.6.33.2.tar.gz
$ cp GPL_TS/kernel_cfg/TS-459/linux-2.6.33.2.cfg linux-2.6.33.2/.config
$ cd linux-2.6.33.2
$ sudo ipkg install gcc
@yanbe
yanbe / gist:673924
Created November 12, 2010 09:47
Skype 5 for MacのDebug consoleで表示中のチャットの内容をTumblrのチャット形式(sender: body)に変換
var s=jQuery.makeArray($('img + a')), b=jQuery.makeArray($('.body')), lines=new Array(); for(var i=0; i<s.length; i++) {lines.push([s[i].innerText,': ',b[i].innerText].join(''))} console.log(lines.join('\n'));
@yanbe
yanbe / gist:718643
Created November 28, 2010 06:00
Easiest way to get text from malformed HTML
$ wget -q -O /dev/stdout example.com | w3m -dump -T text/html > formatted.txt
@yanbe
yanbe / check_and_mail_diff.sh
Created December 7, 2010 11:05
Check arbitrary PDF file on the web and mail diff from last version if it has changed.
#!/bin/sh
export PATH=/opt/bin:$PATH
URL=http://example.com/kushitu.pdf
CUR_LENGTH=`curl --head $URL 2>/dev/null | awk '/Content-Length:/ {print $2}'`
cd /home/john/kushitu_checker
if [ $CUR_LENGTH != `cat last_length` ]; then
curl $URL > kushitu.pdf
pdftotext -enc UTF-8 -raw kushitu.pdf /dev/stdout | sed 's/^.*現在//g' > kushitu.txt
diff -U 0 kushitu.txt last_kushitu.txt | nail -A myaccount -s "Room Updates" john@example.com
echo $CUR_LENGTH > last_length; rm kushitu.pdf; mv kushitu.txt last_kushitu.txt
@yanbe
yanbe / gist:961328
Created May 8, 2011 12:02
iPhoneのSafariのブックマークレットに選択文字列を渡すサンプル(Safariでブラウジング中に大辞林アプリで選択中の単語を調べる)
javascript:document.addEventListener('gesturestart',function()%7Bvar%20w=window.getSelection();if(w!=%22%22)window.location='mkdaijirin://jp.monokakido.DAIJIRIN/search?text='+encodeURIComponent(w)+'&srcname=Safari&src='+encodeURIComponent(location.href)%7D,false);
/*
前準備:
上記をiPhoneのSafariのブックマークとして登録
使い方:
1. Safariでブラウジング中調べたい単語が見つかったら,ブックマークレットを起動する
 (この段階では何も起こらない.実際にはユーザーがタッチパネル上で何らかのジェスチャーを行なったときに
  発動するイベントがページに仕込まれる)
@yanbe
yanbe / netcheck.sh
Created May 12, 2011 02:25
インターネットへの到達性を定期的に監視して、状態が変わるとしゃべる
#!/bin/sh
while true
do
ping -t 6 -i 2 www.google.com 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
echo "Network Has Gone"
if [ `cat ~/.netcheck.last` = "OK" ]
then
reduce(lambda a, b: a+b,map(lambda e: e*2, (1,2,3)))
@yanbe
yanbe / CentOS6-L2TP-IPsec.md
Created October 2, 2018 15:14 — forked from CLCL/CentOS6-L2TP-IPsec.md
L2TP/IPsec(AndroidやiPhoneからのVPN接続)を経路を用意すべくVPSにL2TP/IPsecサーバを設置するとき、ネットにある情報だとなかなかつながらないから、標準環境としてAWSのCentOS 6.3 x86_64 Release Media(ami-3fe8603e)の起動直後から最短距離で設定する方法をまとめた。

CentOS 6でとにかくL2TP/IPsecサーバ

  • AWSでEC2のインスタンスを借りる
  • 今回は東京リージョンのCentOS 6.3 x86_64 Release MediaのAIM(ami-3fe8603e)でインスタンスを建てる
  • Security Group: L2TP/IPsec(Inbound 22/TCP: SSH, 500/UDP: ISAKMP, 1701/UDP: L2TP, 4500/UDP: IPSec NAT Traversal)を許可
  • ec2-54-249-173-214.ap-northeast-1.compute.amazonaws.com(グローバルIPアドレス:54.249.173.214)にrootでログイン

SELinuxを無効にする

[root@ip-10-132-164-105 ~]# setenforce 0