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
  • 10:20 (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 / start mongodb
Last active January 9, 2018 17:53
Ubuntu command
sudo service mongod start
sudo service mongod stop
mongo --host 127.0.0.1:27017
@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;
./gradlew app:dependencies
@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 / ImageButton
Last active August 24, 2019 16:51
Apply Material Design Touch Ripple to ImageButton?
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_button"
android:background="?attr/selectableItemBackgroundBorderless"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"