Skip to content

Instantly share code, notes, and snippets.

@tchn
tchn / README-CodiMD-Restore.md
Last active May 1, 2023 13:29 — forked from Himura2la/README-CodiMD-Restore.md
CodiMD Backup and Restore
@tchn
tchn / gist:7e4e92a40d535fb888d4
Last active August 29, 2015 14:06
python ip-bound simpleHTTPServer
#!/usr/bin/env python
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
# addr = ("127.0.0.1", 8888)
addr = (sys.argv[1], int(sys.argv[2]))
srv = BaseHTTPServer.HTTPServer(addr, SimpleHTTPRequestHandler)
srv.serve_forever()
@tchn
tchn / gist:9953ff071935ee7fe03c
Last active August 29, 2015 14:05
mutt で Content-type: text/plain な PGPメッセージを復号

Content-Type: multipart/encrypted なら問題なく扱えるのに、 ascii-armor な text/plain で 送られてくるPGPの暗号化メール (traditional PGP というらしい) を復号してくれない場合

メッセージを表示しつつ

:push <check-traditional-pgp>

でOKなら、設定で

@tchn
tchn / gist:9bed75fafca58718f286
Last active August 29, 2015 14:05
SSH で X11 forwarding request failed on channel x な時

sshd_config では X11Forwarding yes なのに SSH で X11 forwarding request failed on channel x な時

sshd_config に下記を追加で解消

AddressFamily inet
@tchn
tchn / hopip.sh
Created August 8, 2014 02:14
change ip and mac address of specified nic
#!/bin/sh
set -o nounset
network="10.1.1.";
network_bits="24";
gateway="10.1.1.254";
gateway_mac="aa:bb:cc:11:22:33";
nic="$1";
real_macaddr=$(cat /sys/class/net/${nic}/address);
current_ip=$(hostname -I | cut -d ' ' -f1);
@tchn
tchn / 00-androguard.py
Last active August 29, 2015 14:04
Androguard で APK静的解析する際の iptyhon profile 用
# $ ipython profile create androguard
# $ cd ~/.ipython/profile_androguard/startup/00-androguard.py
# $ ipython --profile=androguard
# In [1]: a, d, dk, dx, gx = set_target_apk(apk)
import sys
import os
def set_target_apk(apk):
"""
@tchn
tchn / gpg.conf
Created July 10, 2014 01:34
使う gnupg オプション
# Digest
# use gpg --version to list to get a list of available algorithms.
personal-digest-preferences SHA512
@tchn
tchn / gist:ff44b904f458a42d9965
Last active August 29, 2015 14:01
vmware workstation 10.0.1 for Linux 3.14

下記からパッチ (vmware_workstation_10.0.1_patch_for_linux_3.14.0.txt) を入手 http://pastebin.com/VKRDd56W

$ sed -e 's/.$//' vmware_workstation_10.0.1_patch_for_linux_3.14.0.txt > vmware_workstation_10.0.1_patch_for_linux_3.14.0
$ cd /usr/lib/vmware/modules/source
$ ls -1 *.tar | sudo xargs -I {} cp {} {}.bak
$ ls -1 *.tar | sudo xargs -I {} tar xvf {}
$ sudo patch -p1 -i vmware_workstation_10.0.1_patch_for_linux_3.14.0
$ パッチをあてたソースで、vmblock.tar, vmci.tar, vmmon.tar, vmnet.tar, vsock.tar を作成
@tchn
tchn / gist:15a9caf0755e8d657b06
Last active August 8, 2023 11:53
[Linux] CPUコアの有効化/無効化

制御の仕方

カーネル起動時のパラメータ( maxcpus=number_of_core )で指定

SMPでも起動時はシングルコアにする (起動が早くなる?)

$ cat grub.cfg
linux /vmlinuz-3.13-1-amd64 root=/dev/mapper/vg-lv ro quiet elevator=noop maxcpus=1
@tchn
tchn / gist:9d95658c37f6d251ed76
Last active December 19, 2015 00:09
Cのビット演算系のtips
  • 下位の n ビットの値を取り出す
val & (2**n - 1)
例: 96 の 下位6ビットの値を取り出す
01100000 // 96
00111111 // (2**6)-1 -> 63 (077)