Skip to content

Instantly share code, notes, and snippets.

View jarvisluong's full-sized avatar
:octocat:
Never AWOL

D.H. Luong jarvisluong

:octocat:
Never AWOL
View GitHub Profile
@jarvisluong
jarvisluong / nonAccentVietnamese.js
Last active April 8, 2024 05:01
Converting standard Vietnamese Characters to non-accent ones (Chuyển đổi ký tự tiếng Việt sang không dấu). Example: hải -> hai
// This function converts the string to lowercase, then perform the conversion
function toLowerCaseNonAccentVietnamese(str) {
str = str.toLowerCase();
// We can also use this instead of from line 11 to line 17
// str = str.replace(/\u00E0|\u00E1|\u1EA1|\u1EA3|\u00E3|\u00E2|\u1EA7|\u1EA5|\u1EAD|\u1EA9|\u1EAB|\u0103|\u1EB1|\u1EAF|\u1EB7|\u1EB3|\u1EB5/g, "a");
// str = str.replace(/\u00E8|\u00E9|\u1EB9|\u1EBB|\u1EBD|\u00EA|\u1EC1|\u1EBF|\u1EC7|\u1EC3|\u1EC5/g, "e");
// str = str.replace(/\u00EC|\u00ED|\u1ECB|\u1EC9|\u0129/g, "i");
// str = str.replace(/\u00F2|\u00F3|\u1ECD|\u1ECF|\u00F5|\u00F4|\u1ED3|\u1ED1|\u1ED9|\u1ED5|\u1ED7|\u01A1|\u1EDD|\u1EDB|\u1EE3|\u1EDF|\u1EE1/g, "o");
// str = str.replace(/\u00F9|\u00FA|\u1EE5|\u1EE7|\u0169|\u01B0|\u1EEB|\u1EE9|\u1EF1|\u1EED|\u1EEF/g, "u");
// str = str.replace(/\u1EF3|\u00FD|\u1EF5|\u1EF7|\u1EF9/g, "y");
@jarvisluong
jarvisluong / utilities.swift
Created April 21, 2017 16:37
Random utilities in UIKit Swift
import Foundation
import UIKit
extension UIColor {
convenience init(colorArray array: [CGFloat]) {
let r = array[0]
let g = array[1]
let b = array[2]
self.init(red: r/255.0, green: g/255.0, blue: b/255.0, alpha:1.0)
}
@jarvisluong
jarvisluong / upload_to_pcloud.sh
Created July 20, 2017 08:46
Upload file to Pcloud via Rest API
#!/bin/bash
while :
do
zip -r $ZIP_FILENAME $FOLDERNAME && curl -F 'filename=@$ZIP_FILENAME' 'https://api.pcloud.com/uploadtolink?code=$PCLOUD_UPLOAD_CODE' && rm -f $ZIP_FILENAME && sleep $SLEEPTIME
done
#ZIP_FILENAME: file name of the zip you want to name it
#FOLDERNAME: the folder you want to zip
#PCLOUD_UPLOAD_CODE: go to pcloud, generate an upload link, you will find the code
#SLEEPTIME: the sleep interval for each upload cycle, if you want this to be a loop
@jarvisluong
jarvisluong / Count lines in Git repo
Created November 5, 2017 09:04 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
content = [1,2,3,4,5,6,7,8,9,10]
<SafeAreaView style={styles.container}>
<KeyboardAvoidingView style={styles.keyboardAvoidContainer} behavior="padding">
<ScrollView style={{flex: 1}}>
{content.map(num => (
<View style={{height: 80, margin: 10, borderWidth: 1, justifyContent: 'center', alignItems: 'center'}} key={num}>
<Text>{num}</Text>
</View>
)}
import React from 'react';
import {TouchableWithoutFeedback, Text, View} from 'react-native';
import * as Animatable from 'react-native-animatable';
Animatable.initializeRegistryWithDefinitions({
bounceLeftRight: {
0: {
translateX: 0,
},
0.3: {
// @flow
import Alert from 'utils/AlertUtils';
import { ImagePicker as ExpoImagePicker, Permissions } from 'expo';
export default {
async launchCameraAsync(options: {
allowsEditing?: boolean,
quality?: number
}): Promise<{ uri?: string }> {
const { status: cameraPermission } = await Permissions.askAsync(
@jarvisluong
jarvisluong / configureStore.js
Created September 22, 2018 18:50
Custom redux persist version for redux-offline
//@flow
import { createStore, applyMiddleware } from 'redux';
import storage from 'redux-persist/lib/storage'
import { composeWithDevTools } from 'redux-devtools-extension';
import { persistStore, persistReducer } from 'redux-persist';
import thunk from 'redux-thunk';
import reducer from 'reducers';
import { createOffline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults/index';
Verifying my Blockstack ID is secured with the address 1NdXY7NnA9ZVdg3D83ZhwHy1x4SxLCq5Rt https://explorer.blockstack.org/address/1NdXY7NnA9ZVdg3D83ZhwHy1x4SxLCq5Rt
@jarvisluong
jarvisluong / MainApplication.java
Created April 30, 2019 12:42 — forked from tsapeta/MainApplication.java
Configuring unimodules on Android
// Replace com.myapp with your app's package name
package com.myapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;