Skip to content

Instantly share code, notes, and snippets.

View tuanchauict's full-sized avatar
🐟
I am lazy

Tuan Chau tuanchauict

🐟
I am lazy
View GitHub Profile
@tuanchauict
tuanchauict / SudokuBrain.go
Last active August 29, 2015 14:19
Sudoku solver algorithm by Golang, converted from Python language by http://norvig.com/sudoku.html
package sudoku
/**
* Algorithm from http://norvig.com/sudoku.html
*/
import (
"fmt"
"strings"
)
@tuanchauict
tuanchauict / IpRange.java
Last active September 18, 2015 06:47 — forked from minhanhhere/IpRange.java
Goodbye Google
import java.util.Arrays;
import java.util.List;
public class IpRange {
//region BlackListIpRanges
public static final List<IpRange> blacklistIpRanges = Arrays.asList(
new IpRange("104.132.0.0 - 104.135.255.255"),
new IpRange("104.154.0.0 - 104.155.255.255"),
new IpRange("104.196.0.0 - 104.199.255.255"),
@tuanchauict
tuanchauict / ParseListLoader.java
Last active October 23, 2015 01:35
ParseListLoader is an universal version of ParseQueryAdapter that we can use it on both ListView/GridView and RecyclerView as well as ViewPager
/*
* Copyright (C) 2015 Tuan Chau (tuanchauict)
*
* 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
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* 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
@tuanchauict
tuanchauict / AspectRatioFrameLayout.java
Created December 4, 2015 04:42
AspectRatioFrameLayout for Android
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* Created by tuanchauict on 11/18/15.
*/
public class AspectRatioFrameLayout extends FrameLayout {
private static final float DEFAULT_RATIO = 109.33f / 144f;
@tuanchauict
tuanchauict / AspectRatioFrameLayout.java
Created December 4, 2015 04:42
AspectRatioFrameLayout for Android
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* Created by tuanchauict on 11/18/15.
*/
public class AspectRatioFrameLayout extends FrameLayout {
private static final float DEFAULT_RATIO = 109.33f / 144f;
@tuanchauict
tuanchauict / PermissionActivity.java
Last active March 14, 2016 15:00
Headless permissions request for Android 23+
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.SparseArray;
import java.util.ArrayList;
@tuanchauict
tuanchauict / RotateOrientationEventListener.java
Created March 16, 2016 13:10
Handle screen rotation without onConfigurationChanged
package com.notabasement.common.photopicker.events;
import android.content.Context;
/**
* Created by tuanchauict on 3/16/16.
*/
public abstract class RotateOrientationEventListener extends SimpleOrientationEventListener {
public RotateOrientationEventListener(Context context) {
super(context);
@tuanchauict
tuanchauict / README.md
Last active March 17, 2016 07:09
Revoke permissions for testing request permissions on android SDK >= 23
$ python3 revoke_permission.py
$ python3 revoke_permission.py <device_code>
@tuanchauict
tuanchauict / BaseFragment.java
Last active June 6, 2016 06:49
Shortcut way for finding a view that is located inside layout of an ViewStub on Android.
private SparseArray<View> mViewStubSparseArray;
/**
* Find view inside ViewStub layout
*
* @param stubId
* @param viewId
* @param <T>
* @return
*/