Skip to content

Instantly share code, notes, and snippets.

package tcom.trinhnd.apptravel.util;
import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
public class GlideUtils {
public static void loadWeatherIcon(Context context, ImageView ivWeather, int code) {
public static double[] calculateCampaignPrice(double medicationFee, double copayment, double capValue, boolean isCopayFix, boolean isCapFix) {
double actualCap = 0;
double total = 0;
double actualCopay = 0;
double copayAmount = isCopayFix ? copayment : copayment * medicationFee / 100;
double capAmount = isCapFix ? capValue : capValue * medicationFee / 100;
if (copayAmount == 0) {
actualCopay = 0;
public void checkCodeData() {
//TODO: chuyển sang BH
if (!TextUtils.isEmpty(MainApplication.submittedPromoCode)) {
checkPromoCode();
return;
}
long checkCodeTimestamp = (long) Utils.shared().getSharedPreference(Constants.DEEPLINK_TIMESTAMP_KEY, 0L);
String campaignId = (String) Utils.shared().getSharedPreference(Constants.CAMPAIGN_ID_KEY, "");
deepLinkCode = (String) Utils.shared().getSharedPreference(Constants.DEEPLINK_CODE_KEY, "");
long now = new Date().getTime();
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] args) {
String input = "2019-09-30 12:23:48.009Z";
Date date = convertDateStringToString(input, "yyyy-MM-dd HH:mm:ss.SSS'Z");
if (date != null) {
private WebView mWebView;
private void doWebViewPrint() {
// Create a WebView object specifically for printing
WebView webView = new WebView(this);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}

Keybase proof

I hereby claim:

  • I am trinhcu18 on github.
  • I am trinhdnd96 (https://keybase.io/trinhdnd96) on keybase.
  • I have a public key ASDmC_FbS23d-mG5F79_xnl6DhjRKZwNI5Aygs1nU4ytOwo

To claim this, I am signing this object:

@trinhcu18
trinhcu18 / ctr_account.js
Last active September 4, 2019 07:09
Validate apple in-app purchase receipt
import iap from 'in-app-purchase';
import { Account } from 'model';
import { constants } from '../util';
class AccountController {
async validateReceipt(user, receipt) {
let account_id = user._id;
iap.config({
/* Configurations for Apple */
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
import com.times.vn.R;
@trinhcu18
trinhcu18 / FragmentObserver.java
Created August 29, 2018 08:19 — forked from alexfu/FragmentObserver.java
Observer pattern for notifying Fragments of a ViewPager to update their views. This will update the current Fragment, as well as the off screen Fragments that are retained.
public class FragmentObserver extends Observable {
@Override
public void notifyObservers() {
setChanged(); // Set the changed flag to true, otherwise observers won't be notified.
super.notifyObservers();
}
}
@trinhcu18
trinhcu18 / nodejs-custom-es6-errors.md
Created July 10, 2018 07:35 — forked from slavafomin/nodejs-custom-es6-errors.md
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js