Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Tuan Nguyen Anh anhtuank7c

🏠
Working from home
View GitHub Profile
@anhtuank7c
anhtuank7c / cleanup_node_modules.sh
Created Jan 7, 2023
[Mac/Linux] List and remove all the node_modules at the current directory
View cleanup_node_modules.sh
#!/bin/bash
# Cleanup node_modules
echo "Calculate disk space for node_modules in all directory"
find . -name "node_modules" -type d -prune -print | xargs du -chs
echo "Remove all node_modules directory"
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
@anhtuank7c
anhtuank7c / const_keyword.dart
Last active Jun 23, 2022
Exploring const keyword in Dart
View const_keyword.dart
class Contact {
// Constructor is marked 'const' so all fields must be final.
final String name;
final int age;
// const at class level have to go along with static keyword
static const alive = true;
// const constructor
const Contact(this.name, this.age);
@anhtuank7c
anhtuank7c / final_keyword.dart
Last active Jun 18, 2022
Exploring final keyword in Dart
View final_keyword.dart
class Contact {
String name;
int age;
Contact(this.name, this.age);
@override
String toString() {
return "$name: $age";
}
@anhtuank7c
anhtuank7c / AudioCue.kt
Created Apr 20, 2022
AudioCue class, let initial this class to call speakOut function to speech the text.
View AudioCue.kt
package com.example;
import android.content.Context
import android.content.Context.AUDIO_SERVICE
import android.media.AudioAttributes
import android.media.AudioFocusRequest
import android.media.AudioManager
import android.os.Build
import android.os.Bundle
import android.speech.tts.TextToSpeech
@anhtuank7c
anhtuank7c / react-native-reanimated-drag-sort_apple-music.jsx React Native Reanimated 2 Multiple Drag and Sort: Apple Music Example
View react-native-reanimated-drag-sort_apple-music.jsx
// Expo SDK40
// expo-blur: ~8.2.2
// expo-haptics: ~8.4.0
// react-native-gesture-handler: ~1.8.0
// react-native-reanimated: ^2.0.0-rc.0
// react-native-safe-area-context: 3.1.9
import React, { useState } from 'react';
import {
Image,
View regex-vietnamese-phone-number-updated-2018.js
/*
Before Septemper 15 2018, Vietnam has phone number start with 09*, 01(2|6|8|9).
After that, the phone number can start with 03, 05, 07 or 08.
So this function provide a way to validate the input number is a Vietnamese phone number
*/
function isVietnamesePhoneNumber(number) {
return /(03|05|07|08|09|01[2|6|8|9])+([0-9]{8})\b/.test(number);
}
View VehicleMarker.js
import React, {memo, useEffect, useState} from 'react';
import {Animated, Platform, StyleSheet} from 'react-native';
import {AnimatedRegion, Marker} from 'react-native-maps';
import {Car} from '../../../../../Assets/Images';
function VehicleMarker({
data,
tripIndex,
initLatDelta,
initLongDelta,
@anhtuank7c
anhtuank7c / BroadcastReceiver.kt
Created Nov 16, 2020 — forked from afollestad/BroadcastReceiver.kt
A Lifecycle components aware BroadcastReceiver DSL (Kotlin)
View BroadcastReceiver.kt
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import androidx.lifecycle.Lifecycle.Event.ON_START
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import android.content.BroadcastReceiver as StockReceiver
@anhtuank7c
anhtuank7c / BroadcastReceiver.kt
Created Nov 16, 2020 — forked from afollestad/BroadcastReceiver.kt
A Lifecycle components aware BroadcastReceiver DSL (Kotlin)
View BroadcastReceiver.kt
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import androidx.lifecycle.Lifecycle.Event.ON_START
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import android.content.BroadcastReceiver as StockReceiver
View com.apple.private.health.heart-rhythm.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>HKAtrialFibrillationDetectionOnboardingCompleted</key>
<integer>1</integer>
<key>HKElectrocardiogramOnboardingCompleted</key>
<integer>3</integer>
</dict>
</plist>