Skip to content

Instantly share code, notes, and snippets.

View thoinv's full-sized avatar
🎯
Focusing

Thoi Nguyen thoinv

🎯
Focusing
View GitHub Profile
@thoinv
thoinv / multiple_ssh_setting.md
Created May 4, 2021 10:56 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@thoinv
thoinv / FileObserver on Android
Created April 1, 2021 01:46 — forked from shirou/FileObserver on Android
Detect file change using FileObserver on Android
private class PathFileObserver extends FileObserver{
static final String TAG="FILEOBSERVER";
/**
* should be end with File.separator
*/
String rootPath;
static final int mask = (FileObserver.CREATE |
FileObserver.DELETE |
FileObserver.DELETE_SELF |
FileObserver.MODIFY |
@thoinv
thoinv / MarqueeToolbar.java
Created March 31, 2021 23:19 — forked from InsanityOnABun/MarqueeToolbar.java
A Marquee-able Android Toolbar.
import android.content.Context;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
import java.lang.reflect.Field;
public class MarqueeToolbar extends Toolbar {
@thoinv
thoinv / verifyReceipt.php
Created November 25, 2020 10:57 — forked from jamesstout/verifyReceipt.php
Verify iOS in-app purchase receipts
<?php
include("/var/www/vhosts/xxxxxcom/httpdocs/PHPUtils/dbConfig.php");
include("/var/www/vhosts/xxxxxcom/httpdocs/PHPUtils/DButils.php");
// verifies receipt from iOS in-app purchase
// returns:
// 0 - if params missing
// 1 - if receipt is valid
// 2 - if invalid receipt, or invalid response from verification server
// or bundle/in-app IDs are incorrect
@thoinv
thoinv / git-deployment.md
Created January 11, 2020 21:59 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@thoinv
thoinv / EndlessRecyclerOnScrollListener.java
Created May 11, 2019 07:02 — forked from mustafasevgi/EndlessRecyclerOnScrollListener.java
RecyclerView position helper to get first and last visible positions
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
@thoinv
thoinv / EachDirectoryPath.md
Last active April 23, 2019 16:04 — forked from granoeste/EachDirectoryPath.md
How to get the each directory path. #android #files

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@thoinv
thoinv / Connectivity.java
Created April 10, 2019 05:53 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed. #android #connectivity
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@thoinv
thoinv / FloatLabelLayout.java
Last active April 10, 2019 05:48 — forked from chrisbanes/FloatLabelLayout.java
FloatLabelLayout #android #ui
/*
* Copyright 2014 Chris Banes
*
* 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
@thoinv
thoinv / how-to-add-image-to-gist.md
Created April 8, 2019 06:28 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh