Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="flatui_turquoise">#1abc9c</color>
<color name="flatui_emerland">#2ecc71</color>
<color name="flatui_peter_river">#3498db</color>
<color name="flatui_amethyst">#9b59b6</color>
<color name="flatui_wet_asphalt">#34495e</color>
<color name="flatui_green_sea">#16a085</color>
<color name="flatui_nephritis">#27ae60</color>
<color name="flatui_belize_hole">#2980b9</color>
sed -i '' 's/foo/bar/g' **/*
@billynyh
billynyh / gist:d949d233c6f313271182
Created September 17, 2014 02:01
keep view's padding when changing 9patch background
public void setBackgroundResource(View v, int id) {
int bottom = v.getPaddingBottom();
int top = v.getPaddingTop();
int right = v.getPaddingRight();
int left = v.getPaddingLeft();
v.setBackgroundResource(id);
v.setPadding(left, top, right, bottom);
}
// prefetch image https://plus.google.com/+Tom%C3%A1%C5%A1Linhart/posts/MA3oieUpWXj
Picasso.with(context).load(url).skipMemoryCache().fetch()
@billynyh
billynyh / hkoi.js
Created December 19, 2014 10:23
dirty script to filter out hkoi result, need jquery
// run in chrome developer console
var tables = $(".main table");
var TD = '<td style="width:40px; text-align:center">';
function fill_rank(st, ed){
var rank = 1;
for(var i=st; i<ed; i++){
$(tables[i]).find("tr").each(function(){
var row = $(this);
var td = $(row.find("td")[1]);
@billynyh
billynyh / change-bg.scpt
Created March 10, 2015 07:39
stupid script to change all wallpaper in mac
set bgFile to "path/to/wallpaper.jpg"
tell application "System Events"
repeat with i from 1 to 7
set theDesktops to (a reference to every desktop)
repeat with x from 1 to (count theDesktops)
set picture of item x of the theDesktops to bgFile
end repeat
delay 1
key code 124 using control down
end repeat
@billynyh
billynyh / gist:70fe7dc22a05ee0fa1f3
Created May 14, 2015 04:18
android default ripple effect bg drawable
// https://developer.android.com/training/material/animations.html
// ?android:attr/selectableItemBackground
@billynyh
billynyh / gist:3495860
Created August 28, 2012 07:30
read android app meta-data
// get meta-data from AndroidManifest.xml
ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
String meta = ai.metaData.getString("key");
// get version name and version code
PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String versionName = pinfo.versionName;
int versionCode = pinfo.versionCode;
@billynyh
billynyh / gist:3565241
Created September 1, 2012 06:08
my default styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="android:Theme.Light" />
<style name="FP">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
</style>
<style name="WC">
<item name="android:layout_width">wrap_content</item>
@billynyh
billynyh / gist:3719885
Created September 14, 2012 04:57
my android text helper : strike text, underline, decimal format
public class TextHelper {
public static SpannableString strikeText(String text){
if (text==null)text = "";
SpannableString str = new SpannableString(text);
str.setSpan(new StrikethroughSpan(), 0, str.length(), Spanned.SPAN_PARAGRAPH);
return str;
}
public static SpannableString underlineText(String text){
if (text==null)text = "";
SpannableString str = new SpannableString(text);