Skip to content

Instantly share code, notes, and snippets.

View hoajb's full-sized avatar

Hoa Nguyen hoajb

  • EPAM Systems
  • Ho Chi Minh City, Viet Nam
  • 12:23 (UTC +07:00)
View GitHub Profile
@hoajb
hoajb / 0_reuse_code.js
Created July 4, 2017 03:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hoajb
hoajb / ToolbarAlphaScrollBehavior
Created September 28, 2018 06:57 — forked from NikolaDespotoski/ToolbarAlphaScrollBehavior.java
Toggle Toolbar background alpha and alpha of its title view.
public class ToolbarAlphaScrollBehavior extends CoordinatorLayout.Behavior<android.support.v7.widget.Toolbar> {
private ColorDrawable mStatusBarColorDrawable;
private int mStatusBarColor;
private TextView mTitleView;
private boolean searchedForTitleView = false;
public ToolbarAlphaScrollBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
mStatusBarColor = ContextCompat.getColor(context, R.color.primary_dark);
mStatusBarColor = getColorWithAlpha(0, mStatusBarColor);
@hoajb
hoajb / IntentFacebook.java
Created November 7, 2018 07:13 — forked from layerlre/IntentFacebook.java
Open Facebook Page URL in Facebook app with Intent
....
public void startFacebook(String facebookUrl) {
try {
Uri uri = null;
int versionCode = getPackageManager()
.getPackageInfo("com.facebook.katana", 0)
.versionCode;
@hoajb
hoajb / MainActivity.java
Created November 8, 2018 10:09
Custom Android AppBarLayout$ScrollingViewBehavior: Prevent Toolbar from scrolling when RecyclerView doesn't have enough items to scroll.
/*
* Copyright 2016 Alireza Eskandarpour Shoferi
*
* 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
@hoajb
hoajb / 00_READ_ME.txt
Created November 19, 2018 10:56 — forked from Kane-Shih/00_READ_ME.txt
Enable TLS 1.2 in Android 4.4
1. To enable TLS 1.2 in Android 4.4
Copy TLSSocketFactory.java
If using HttpsURLConnection:
=> conn.setSSLSocketFactory(new TLSSocketFactory());
Else if using OkHttp:
=> new OkHttpClient.Builder().setSocketFactory(new TLSSocketFactory()). ... .build();
Else if using HttpClient:
sample for legacy apache http library: https://github.com/Kane-Shih/TestApacheHttpClient
=> see: https://stackoverflow.com/questions/2603691/android-httpclient-and-https
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
@hoajb
hoajb / database.rules.json
Created May 21, 2019 03:10 — forked from codediodeio/database.rules.json
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@hoajb
hoajb / DebouncedOnClickListener.java
Created November 18, 2019 07:15 — forked from rfreedman/DebouncedOnClickListener.java
A debounced onClickListener for Android
import android.os.SystemClock;
import android.view.View;
import java.util.Map;
import java.util.WeakHashMap;
/**
* A Debounced OnClickListener
* Rejects clicks that are too close together in time.
* This class is safe to use as an OnClickListener for multiple views, and will debounce each one separately.
@hoajb
hoajb / homebrew-permissions-issue.md
Created February 15, 2020 04:13 — forked from irazasyed/homebrew-permissions-issue.md
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*