Skip to content

Instantly share code, notes, and snippets.

View sinergy's full-sized avatar

Cloud Chen sinergy

View GitHub Profile
@sinergy
sinergy / 1. Example.scss
Created March 22, 2013 03:26 — forked from Integralist/1. Example.scss
cross-browser CSS3 keyframe animation for SASS.
@include keyframe(fadeout) {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@sinergy
sinergy / new_gist_file
Created May 22, 2013 10:45
Check if Key existed in the JsonData Object of LitJSON (A C# JSON Parser) source: http://goo.gl/NxBcP
static public bool JsonDataContainsKey(JsonData data,string key)
{
bool result = false;
if(data == null)
return result;
if(!data.IsObject)
{
return result;
}
IDictionary tdictionary = data as IDictionary;
@sinergy
sinergy / OnOneClickListener.java
Created June 13, 2014 14:36
This class allows a single click and prevents multiple clicks on the same button in rapid succession.
/**
* This class allows a single click and prevents multiple clicks on
* the same button in rapid succession. Setting unclickable is not enough
* because click events may still be queued up.
*
* Override onOneClick() to handle single clicks. Call reset() when you want to
* accept another click.
*/
public abstract class OnOneClickListener implements View.OnClickListener {
@sinergy
sinergy / csv_format.csv
Last active August 29, 2015 14:07
A script which read the duty table CSV file, and send a notification message to the specific room of HipChat. 讀取 CSV 中的值日生名單,並且透過 hipchat.pl 這隻 perl script 傳遞提醒訊息至指定的 room 中
日期 值日生
2014/07/04 Arc
2014/07/11 Clark
2014/07/18 Jack
2014/07/25 William
2014/08/01 kiki
2014/08/08 Cloud
2014/08/15 Isaac
2014/08/22 Haru
2014/08/29 Jimmy
@sinergy
sinergy / MyDaoGenerator.java
Created January 21, 2015 07:20
DaoGenerator snippet created for my blog post.
package com.cloudchen;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
@sinergy
sinergy / themes-debug.xml
Last active August 29, 2015 03:23 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@sinergy
sinergy / android-findbug.gradle
Created September 2, 2015 05:44
add FindBugs Gradle task into Android project
apply plugin: 'findbugs'
afterEvaluate {
def variants = plugins.hasPlugin('com.android.application') ?
android.applicationVariants : android.libraryVariants
variants.each { variant ->
def task = tasks.create("findBugs${variant.name.capitalize()}", FindBugs)
task.group = 'verification'
@sinergy
sinergy / gist:1e09fa953562972cf63e
Created March 28, 2016 12:52 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@sinergy
sinergy / RxponetialBackoff.java
Created July 5, 2016 15:26 — forked from sddamico/LICENSE
Exponential Backoff Transformer
/**
* @param interval The base interval to start backing off from. The function is: attemptNum^2 * intervalTime
* @param units The units for interval
* @param retryAttempts The max number of attempts to retry this task or -1 to try MAX_INT times,
*/
public static <T> Observable.Transformer<T, T> backoff(final long interval, final TimeUnit units, final int retryAttempts) {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(final Observable<T> observable) {
return observable.retryWhen(