Skip to content

Instantly share code, notes, and snippets.

View pnlinh-it's full-sized avatar
🏠
Working from home

Phạm Ngọc Linh pnlinh-it

🏠
Working from home
View GitHub Profile
const val NETWORK_PAGE_SIZE = 500
private const val INITIAL_LOAD_SIZE = 1
class CryptoListPagingSource(
private val service: APIService,
private val mapper: CryptoListMapper
) : PagingSource<Int, CryptoItemResponse>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, CryptoItemResponse> {
// Start refresh at position 1 if undefined.
@pnlinh-it
pnlinh-it / GoogleDriveServiceProvider.php
Created August 25, 2021 14:02 — forked from sergomet/GoogleDriveServiceProvider.php
Setup a Laravel Storage driver with Google Drive API
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class GoogleDriveServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
@pnlinh-it
pnlinh-it / FileUtils.java
Created April 30, 2020 10:55 — forked from MaksimDmitriev/FileUtils.java
PowerMock with System.currentTimeMillis
package sample.com.sample_app;
import android.support.annotation.NonNull;
public class FileUtils {
@NonNull
public static String generateName() {
return Long.toString(System.currentTimeMillis());
}
@pnlinh-it
pnlinh-it / howto.md
Created November 7, 2019 03:45
Charles & Java application (SSL Proxying)

You can add your Charles Root Certificate to your root certificate trust store in Java, then all Java applications will trust the certificates that Charles issues. Note that you may need to do this each time you upgrade your Java installation.

In Charles go to the Help menu and choose "SSL Proxying > Save Charles Root Certificate". Save the root certificate (as a .crt) to your desktop, or somewhere where you can easily access it in the next step.

Now find the cacerts file, it should be in your $JAVA_HOME/jre/lib/security/cacerts, where $JAVA_HOME is your java home directory for the JVM you’re using.

Then type (substituting for JAVAHOME and DESKTOP):

@pnlinh-it
pnlinh-it / xdebug-mac.md
Created October 9, 2019 14:50 — forked from ankurk91/xdebug-mac.md
php xDebug on Ubuntu/Mac and phpStorm 2019

🪲 Install and Configure xDebug on MacOS for PhpStorm 🐘

⚠️ This guide only applies to Homebrew v1.6+

  • Check your version brew --version before proceeding

  • Assuming that you have already installed php and apache via Homebrew v1.6+

  • Install xDebug php extension

pecl channel-update pecl.php.net
pecl clear-cache

##Change default Mac OS X PHP to XAMPP's PHP Installation and Install Composer

Find out what version of PHP is running

which php

This will output the path to the default PHP install which comes preinstalled by Mac OS X, by default

@pnlinh-it
pnlinh-it / nginx-ssl-config
Created February 15, 2019 15:25 — forked from apollolm/nginx-ssl-config
Nginx Configuration with multiple port apps on same domain, with SSL.
# the IP(s) on which your node server is running. I chose port 3000.
upstream app_geoforce {
server 127.0.0.1:3000;
}
upstream app_pcodes{
server 127.0.0.1:3001;
}
var nodes = document.getElementById("reaction_profile_browser").childNodes;
var lists = [];
nodes.forEach(function(element){lists.push(element.querySelector("div._5j0e a").textContent)});
lists.forEach(function(name){
if(name.toLocaleLowerCase().indexOf("linh")> -1)
console.log(name)
})
@pnlinh-it
pnlinh-it / get-facebook-token-console-android.js
Created January 4, 2019 06:54 — forked from dieudv/get-facebook-token-console-android.js
Press F12 -> Console and patse this code for android or for ios. (Cre: dieudv)
var email = "youremail";
var password = "yourpassword";
var BASE_URL = "https://api.facebook.com/restserver.php";
var API_SECRET = "62f8ce9f74b12f84c123cc23437a4a32";
var md5 = function(d){result = M(V(Y(X(d),8*d.length)));return result.toLowerCase()};function M(d){for(var _,m="0123456789ABCDEF",f="",r=0;r<d.length;r++)_=d.charCodeAt(r),f+=m.charAt(_>>>4&15)+m.charAt(15&_);return f}function X(d){for(var _=Array(d.length>>2),m=0;m<_.length;m++)_[m]=0;for(m=0;m<8*d.length;m+=8)_[m>>5]|=(255&d.charCodeAt(m/8))<<m%32;return _}function V(d){for(var _="",m=0;m<32*d.length;m+=8)_+=String.fromCharCode(d[m>>5]>>>m%32&255);return _}function Y(d,_){d[_>>5]|=128<<_%32,d[14+(_+64>>>9<<4)]=_;for(var m=1732584193,f=-271733879,r=-1732584194,i=271733878,n=0;n<d.length;n+=16){var h=m,t=f,g=r,e=i;f=md5_ii(f=md5_ii(f=md5_ii(f=md5_ii(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_ff(f=md5_ff(f=md5_ff(f=md5_ff(f,r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+0],7,-680876936),f,r,d[n+1],12,-389564586),m,