Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright 2013 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@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 / 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 / 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 / ApiModule.java
Last active May 29, 2020 07:25
Android integration of retrofit, signpost, twitter api
public class ApiModule {
private TwitterApi mApi;
public void init(String token, String tokenSecret) {
OAuthConsumer consumer = new DefaultOAuthConsumer(
Config.TWEET_API_KEY,
Config.TWEET_API_SECRET);
consumer.setTokenWithSecret(token, tokenSecret);
// prefetch image https://plus.google.com/+Tom%C3%A1%C5%A1Linhart/posts/MA3oieUpWXj
Picasso.with(context).load(url).skipMemoryCache().fetch()
@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);
}
sed -i '' 's/foo/bar/g' **/*
<?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>
@billynyh
billynyh / ParallaxImageView.java
Created November 24, 2013 09:31
ParallaxImageView copy from notboringactionbar
package com.flavienlaurent.notboringactionbar;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by f.laurent on 21/11/13.
* antoine-merle.com inspiration