Skip to content

Instantly share code, notes, and snippets.

View sgk's full-sized avatar

Shigeru KANEMOTO sgk

  • Switch Science /144Lab
  • Tokyo / Osaka
View GitHub Profile
@sgk
sgk / README.md
Last active April 8, 2016 14:30
Gnome端末の日本語表示で「↑」とか「◯」の幅を全角にする(Ubuntu 14.10用)。

Ubuntu 15.04では、プロファイル設定の「互換性」タブで設定できるので不要。この方法は機能しない。

  • このファイルを、~/.local/share/applications以下に、○○.desktopなどという名前で置き、実行権限をつける。
  • Nautilus(ファイルブラウザ)から、このファイルを開く。
  • 端末が開いてランチャにアイコンが現れるので、アイコンを右クリック→「Launcherに登録」をクリック。

vimではまた別の問題があるので、.vimrcの中で「set ambiwidth=double」も必要。

@sgk
sgk / gist:5788552
Last active December 18, 2015 13:18
Ubuntuをインストールしたら行う設定
% sudo apt-get install aptitude
% sudo apt-get install virtualbox-guest-utils
% sudo apt-get purge unity-lens-music unity-lens-photos unity-lens-video
% sudo apt-get purge unity-scope-gdrive unity-scope-musicstores unity-scope-video-remote
% sudo apt-get purge unity-webapps-common
% sudo apt-get purge xul-ext-ubufox xul-ext-unity xul-ext-webaccounts xul-ext-websites-integration
% sudo apt-get purge ubuntuone-client python-ubuntuone-client python-ubuntuone-storageprotocol
% sudo vi /etc/default/ntpdate
% sudo apt-get install ntp
% sudo vi /etc/ntp.conf
@sgk
sgk / cache.py
Last active December 18, 2015 12:59
Simple cache: dictionary with expire
#vim:set fileencoding=utf-8
import time
# Cache with Expire
class Cache:
def __init__(self, timeout):
# Actual expire is more than timeout and less than timeout*3.
self.timeout_ = timeout
self.clear()
@sgk
sgk / update53-couchdb.py
Last active December 17, 2015 22:59
Linux startup script to update Route53 zone entry using the EC2 dynamically allocated IP address.
#!/usr/bin/python
### BEGIN INIT INFO
# Provides: update53
# Required-Start: $network $local_fs
# Required-Stop:
# Should-Start:
# Should-Stop:
# X-Start-Before: couchbase-server
# X-Stop-After: couchbase-server
@sgk
sgk / ddns.py
Last active December 17, 2015 21:59
A simple script to update the AWS Route53 entry using "boto".
#!/usr/bin/python
import boto
import boto.route53.record
access_key = 'XXXXXXXXXXXXXXXXXXXX'
secret_access_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
zone_id = 'XXXXXXXXXXXXXX'
domain = 'example.com.' # last '.' required.
@sgk
sgk / gist:5537886
Created May 8, 2013 02:58
ipythonで、^Dで確認なしで終了できるようにする。
ipythonで、^Dで確認なしで終了できるようにする。
% ipython profile create
% vi $HOME/.ipython/profile_default/ipython_config.py
以下の設定を行う。
c.TerminalInteractiveShell.confirm_exit = False
@sgk
sgk / build.sh
Last active December 14, 2015 04:48
Build and install GIT 1.8.1.4 on the very old Solaris 9.
#!/usr/bin/env bash
SOURCE=git-1.8.1.4.tar.gz
SOURCEDIR=git-1.8.1.4
BASH=/usr/bin/bash
MAKE=/usr/local/bin/make
PERL=/usr/local/bin/perl
PYTHON=/usr/local/bin/python
LIBDIR=/usr/local/lib
@sgk
sgk / LeonardoTest.ino
Created February 21, 2013 12:18
LeonardoTest
int i = 0;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
while(!Serial) {
}
}
void loop() {
@sgk
sgk / fft.py
Last active December 12, 2015 08:39
FFT study in Python. Original in C: http://www.kurims.kyoto-u.ac.jp/~ooura/fftman/ftmn1_2.html
import math
def fft(data):
n = len(data)
assert 2 ** int(math.log(n, 2)) == n, "Number of samples should be 2^n."
theta = math.pi * 2 / n
def scramble(k, i):
while True:
@sgk
sgk / printflen.c
Last active December 11, 2015 19:18
Compute the length printf would print.
#include <stdio.h>
#include <stdarg.h>
/* returns the length printf would print. */
int
printflen(const char* format, ...) {
va_list ap;
char buf[1];
int len;