Skip to content

Instantly share code, notes, and snippets.

View crossle's full-sized avatar
🌐

Crossle Song crossle

🌐
View GitHub Profile
@crossle
crossle / clear_log.rb
Last active December 11, 2015 04:28
Clear Rail log in development env only cp it to Rails.root/config/initializers/
if Rails.env.development?
MAX_LOG_SIZE = 10.megabytes
logs = [File.join(Rails.root, 'log', 'development.log'), File.join(Rails.root, 'log', 'test.log')]
logs.each do |log|
if File.size?(log).to_i > MAX_LOG_SIZE
$stdout.puts "Remove Log: #{log}"
`rm #{log}`
end
end
@crossle
crossle / DoubleTouchScrollView
Created January 17, 2013 08:31
ScrollView contain a TextView who had a scrollbar
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;
public class CustScrollView extends ScrollView {
public CustScrollView(Context context) {
super(context);
}
@crossle
crossle / SystemPropertiesProxy
Created February 27, 2013 09:15
Use the reflection invoke SystemProperites
import java.lang.reflect.Method;
public class SystemPropertiesProxy {
/**
* This class cannot be instantiated
*/
private SystemPropertiesProxy() {
}
@crossle
crossle / repo-switch
Created September 27, 2013 16:12
Convenient switch AOSP git repo
#!/bin/bash
while read LINE
do
echo $LINE
cd $LINE
`git checkout android-4.3_r1.1`
cd -
done < .repo/project.list
@crossle
crossle / dex.sh
Last active August 29, 2015 14:07 — forked from JakeWharton/dex.sh
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@crossle
crossle / FFmpeg compile for Linux
Last active August 29, 2015 14:09
FFmpeg compile config
./configure --disable-doc --disable-ffserver --enable-openssl --enable-gpl --enable-nonfree --enable-libx264 --enable-librtmp --enable-libmp3lame --enable-x11grab --extra-ldflags="-lstdc++"
make -j7 && make install
@crossle
crossle / gist:d8064c69fbd4b70f3f84
Created December 24, 2014 02:39
Merge multi file to one file
find -name "*.java" -exec 'cat' {} \; > a.txt
@crossle
crossle / sonatype_create_repo
Created January 13, 2015 05:54
Sonatype create repo
http://central.sonatype.org/pages/ossrh-guide.html#create-a-ticket-with-sonatype
@crossle
crossle / ffmpeg_cmd_watermark.sh
Last active August 29, 2015 14:16
ffmpeg add watermark
input="$1"
output="$2"
ffmpeg -i "$input" -vf "movie=watermark.png [watermark]; [in][watermark] overlay=10:10 [out]" -vsync 2 -bsf:a aac_adtstoasc -acodec copy "$output"
@crossle
crossle / gist:1de535e6a1d3f9fd48e6
Created May 26, 2015 06:59
libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
brew install exiftool
find . -path '*src/main/res/*' -name '*.png' -exec exiftool -overwrite_original -all= {} \;