Skip to content

Instantly share code, notes, and snippets.

@solar
solar / gist:986348
Created May 23, 2011 07:08
Android grayscale ColroMatrixFilter
// grayscale color filter
float r = 0.298912F;
float g = 0.586611F;
float b = 0.114478F;
ColorMatrixFilter filter = new ColorMatrixFilter(
new ColorMatrix(new float[] {
r, g, b, 0, 0,
r, g, b, 0, 0,
@solar
solar / gist:992703
Created May 26, 2011 07:19
Parse String to Date
SimpleDateFormat format = new SimpleDateFormat("E MMM d kk:mm:ss Z yyyy", Locale.US);
Date datetime = format.parse("Thu Jun 10 01:32:13 +0000 2010");
@solar
solar / IconPreference.java
Created June 1, 2011 09:41
Android PreferenceScreen with icon image.
package org.sazabi.lib.preference;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
@solar
solar / gist:1563872
Created January 5, 2012 05:36
How to develop Android application with Scala
@solar
solar / boost
Created March 7, 2012 05:12
Building facebook/scribe
# install boost-1.49.0
cd ~/src
curl -L "http://downloads.sourceforge.net/project/boost/boost/1.49.0/boost_1_49_0.tar.gz?r=http%3A%2F%2Fwww.boost.org%2Fusers%2Fhistory%2Fversion_1_49_0.html&ts=1331091084&use_mirror=jaist" | tar zxv
cd boost_1_49_0
./bootstrap.sh
./b2
sudo ./b2 --prefix=/usr/local/boost_1_49_0 install
@solar
solar / libevent-2.0.20-stable.sh
Created May 2, 2012 05:22
Install libevent and tmux on CentOS/RH 6.3
#!/bin/sh
curl -sL 'https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz' | tar zx
cd libevent-2.0.20-stable/
./configure --prefix=/usr/local/libevent/2.0.20-stable
make
sudo make install
sudo alternatives --install /usr/local/lib64/libevent libevent /usr/local/libevent/2.0.20-stable/lib 20018 \
--slave /usr/local/include/libevent libevent-include /usr/local/libevent/2.0.20-stable/include \
--slave /usr/local/bin/event_rpcgen.py event_rpcgen /usr/local/libevent/2.0.20-stable/bin/event_rpcgen.py
@solar
solar / gist:3205949
Created July 30, 2012 09:56
Create virtual ip address in linux
# by ifconfig
ifconfig eth1:0 10.1.53.1
ifconfig eth1:0 down
# by iproute2
ip addr add 10.1.53.1 dev eth1
ip addr show
ip addr del 10.1.53.1 dev eth1
@solar
solar / zsh-5.0.0.sh
Created October 12, 2012 05:00
Install zsh 5.0.0 on CentOS/RH 6.3
# install zsh-5.0.0
# prerequisite: gcc ncurses-devel readline-devel pcre-devel zlib-devel
curl -L http://jaist.dl.sourceforge.net/project/zsh/zsh/5.0.0/zsh-5.0.0.tar.bz2 | tar jx
cd zsh-5.0.0/
./configure --prefix=/usr/local/zsh/5.0.0 --enable-cap --enable-pcre --enable-multibyte
make
sudo make install
sudo alternatives --install /usr/local/bin/zsh zsh /usr/local/zsh/5.0.0/bin/zsh 50000
@solar
solar / vim73.sh
Created October 12, 2012 05:48
Install vim 7.3
# install vim
curl -L ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2 | tar jx
cd vim73
./configure --prefix=/usr/local/vim/7.3 --enable-multibyte --with-features=huge
make
sudo make install
sudo alternatives --install /usr/local/bin/vim vim /usr/local/vim/7.3/bin/vim 070300 \
--slave /usr/local/bin/view view /usr/local/vim/7.3/bin/view
@solar
solar / git-1.7.12.3.sh
Created October 12, 2012 06:03
Install git
# install git
# prerequisite: openssl-devel pcre-devel curl-devel expat-devel
curl -sL http://git-core.googlecode.com/files/git-1.7.12.3.tar.gz | tar zx
cd git-1.7.12.3/
./configure --prefix=/usr/local/git/1.7.12.3 --with-openssl --with-libpcre --with-expat --with-curl
make
sudo make install
sudo alternatives --install /usr/local/bin/git git /usr/local/git/1.7.12.3/bin/git 1071203 \
--slave /usr/local/bin/git-receive-pack git-receive-pack /usr/local/git/1.7.12.3/bin/git-receive-pack \
--slave /usr/local/bin/git-shell git-shell /usr/local/git/1.7.12.3/bin/git-shell \