Skip to content

Instantly share code, notes, and snippets.

Luong Dang Hai jarvisluong

Block or report user

Report or block jarvisluong

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jarvisluong
jarvisluong / MainApplication.java
Created Apr 30, 2019 — forked from tsapeta/MainApplication.java
Configuring unimodules on Android
View MainApplication.java
// 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;
View Blockstack
Verifying my Blockstack ID is secured with the address 1NdXY7NnA9ZVdg3D83ZhwHy1x4SxLCq5Rt https://explorer.blockstack.org/address/1NdXY7NnA9ZVdg3D83ZhwHy1x4SxLCq5Rt
@jarvisluong
jarvisluong / configureStore.js
Created Sep 22, 2018
Custom redux persist version for redux-offline
View configureStore.js
//@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';
View ImagePicker.js
// @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(
View bounceWhenTap.js
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: {
View chat-input-keyboard-aware.js
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>
)}
@jarvisluong
jarvisluong / Count lines in Git repo
Created Nov 5, 2017 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
View Count lines in Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@jarvisluong
jarvisluong / upload_to_pcloud.sh
Created Jul 20, 2017
Upload file to Pcloud via Rest API
View upload_to_pcloud.sh
#!/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 / utilities.swift
Created Apr 21, 2017
Random utilities in UIKit Swift
View utilities.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 / nonAccentVietnamese.js
Last active Feb 4, 2019
Converting standard Vietnamese Characters to non-accent ones. Example: hải -> hai
View nonAccentVietnamese.js
function nonAccentVietnamese(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");
// str = str.replace(/\u0111/g, "d");
You can’t perform that action at this time.