Skip to content

Instantly share code, notes, and snippets.

@tatuas
tatuas / MainActivity.partof.java
Last active December 25, 2015 14:59
androidで、インストールされているパッケージ名すべてを閲覧する
public void isInstalled(Context activityContext) {
PackageManager pm = activityContext.getPackageManager();
List<ApplicationInfo> list = pm.getInstalledApplications(0);
for (ApplicationInfo info : list) {
Log.e("PackageName", info.packageName);
}
}
@tatuas
tatuas / gist:7174159
Last active December 26, 2015 15:39
Ubuntuお決まり設定
$ sudo apt-get install xdg-user-dirs-gtk
$ LANG=C xdg-user-dirs-gtk-update
$ gsettings set org.gnome.desktop.interface gtk-key-theme Emacs
$ sudo apt-get install tmux
$ sudo apt-get install vim
$ sudo apt-get install xclip
$ sudo update-alternatives --config editor
@tatuas
tatuas / gist:7174312
Created October 26, 2013 20:42
UbuntuにEclipseをインストール。
aptのは古い。
バイナリはeclipse.orgからダウンロード。
$ mv eclipse-juno-*.tar.gz /usr/local/lib
$ cd /usr/local/lib
$ sudo tar -xvzof eclipse-juno-*.tar.gz
$ cd /usr/local/lib/eclipse
$ ./eclipse
@tatuas
tatuas / gist:7175398
Created October 26, 2013 22:38
Ubuntu13.10でCapsLockをCtrlにする
sudo vim /etc/default/keyboard
XKBOPTIONS="ctrl:nocaps"
を追加。
$ sudo dpkg-reconfigure keyboard-configuration
キーボードショートカットの設定をすると無効になる。
@tatuas
tatuas / gist:7886092
Last active December 30, 2015 21:18
ターミナルから再帰的にテキストファイル内文字を検索・置換。(GNU系で検証)
# ディレクトリ内のphpファイルから「salt」を再帰的に検索。
# タブで整列し行番号を出力するgrepオプション。
$ find . -name "*.php" -exec grep -nTH "salt" {} \; | less
# ディレクトリ内のphpファイルのタブをスペースに置換。
# findの検索結果が{} \;に入るのでそれを利用。
$ find . -name "*.php" -exec sed "s/\t/ /g" {} \;
# ディレクトリ内のphpファイルの「hello」を「bye」に置換。
# gは全部変換。iは大文字小文字無視。
@tatuas
tatuas / gist:7923527
Created December 12, 2013 05:17
Javaで日付の頭数を整えた文字列を生成
String month = String.format("%1$02d", 9);
// 09と出力
System.out.println("mouth", month);
@tatuas
tatuas / gist:7929012
Last active December 31, 2015 03:39
Froyo以前におけるHttpURLConnectionのバグ:検証端末(Samsung Galaxy S 2.2.0・Sharp IS05 2.2.1)
・setRequestPropertyを何度コールしても、最初のコール以外は無視される。
・setRequestPropertyで、キーが必ず小文字になる。
・POSTリクエストにおいて、Authenticator.setDefaultでBasic認証でリクエストすると、POSTした内容が消える。
String username = "username";
String password = "pass";
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password.toCharArray());
}
@tatuas
tatuas / SampleOfHashMap.java
Created December 17, 2013 06:09
How to use HashMap in Java
public void hashMapSample() {
File file1 = new File("sample1.txt");
File file2 = new File("sample2.txt");
HashMap<File, String> maps = new HashMap<File, String>();
maps.put(file1, "hello");
maps.put(file2, "bye");
Iterator<File> it = maps.keySet().iterator();
@tatuas
tatuas / layout_sample.xml
Created December 18, 2013 11:21
AndroidのRelativeLayoutでmarginを開けつつもbottomに配置する方法
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/emptyView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
@tatuas
tatuas / gist:8038037
Created December 19, 2013 11:47
MySQLのステータスを調べるコマンド。
% mysqladmin status -u username -p
% mysqladmin extended-status -u username -p