Skip to content

Instantly share code, notes, and snippets.

View tranquan's full-sized avatar
🥝
kiwi

Tran Quan tranquan

🥝
kiwi
View GitHub Profile
@tranquan
tranquan / RealmDatabase.ts
Created January 4, 2019 20:34
A helper to handle open and close realm database
/**
* Summary:
* - A helper to handle open and close realm database
* - If a database fail to open on the first time, the old one will be deleted.
* And a new database is re-created
* Documents:
* https://realm.io/docs/javascript/latest/
* https://realm.io/docs/javascript/latest/api/index.html
*/
import Realm from "realm";
@tranquan
tranquan / OverriddenPublishedContent.cs
Created November 12, 2018 16:32
A way to override property in umbraco
// source: https://www.formfakten.de/themen/2018/08/published-content-with-overridden-properties
public class OverriddenProperty : IPublishedProperty
{
private readonly string alias;
private readonly object value;
public OverriddenProperty(string alias, object value)
{
this.alias = alias;
this.value = value;
@tranquan
tranquan / reactotron_log_config.ts
Last active July 30, 2018 18:58
Reactotron Log Configure to connect Console.log
/**
* Copyright (C) SaigonMD, Inc - All Rights Reserved
* Licensed under the MIT license.
* Written by Tran Quan <tranquan221b@gmail.com>, July 2018
*/
/**
* Log helper using Reactotron https://github.com/infinitered/reactotron
* - log faster than console because no need to turn-on remote debug
* - able to customize the message
*/
@tranquan
tranquan / react_native_vscode_workspace_settings.json
Last active July 12, 2018 11:51
vscode workspace settings for react-native project
{
"eslint.enable": false,
"tslint.enable": false,
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"editor.wordWrapColumn": 100,
"editor.parameterHints": false,
"editor.rulers": [100],
"typescriptHero.imports.disableImportRemovalOnOrganize": false,
@tranquan
tranquan / swift_closure.md
Created January 6, 2018 09:14
A Summary and Best practices of Closure in Swift

Documents

What is closure?

Closures are self-contained blocks of functinality that can be PASSED around and USED in your code

# configure app name (in strings.xml) & firebase info google-services.json
# to match with the environment setting in app/constants/configs.js
# *** developer still have to config the applicationId manually ***
import os
import glob
import re
from shutil import copyfile
# Contants
createTimeMoment() {
if (!this.mCreateTimeMoment) {
this.mCreateTimeMoment = moment(this.createTime, 'X');
}
return this.mCreateTimeMoment;
}
/**
* Thanks to https://github.com/danleveille/react-native-input-accessory-demo
*/
import React, { Component } from 'react';
import {
Dimensions,
TouchableOpacity,
LayoutAnimation,
StyleSheet,
Keyboard,
/**
* Auto increment versionCode for every build
* read version.properties in android root directory and auto increment build number on release
*/
def readAndIncrementVersionCode() {
def isRelease = false
List<String> runTasks = gradle.startParameter.getTaskNames();
for (String item : runTasks) {
if (item.contains("assemble") && item.contains("Release")) {
@tranquan
tranquan / vscode_personal_settings.json
Last active July 12, 2018 11:50
vscode setting personal usage
{
"editor.dragAndDrop": false,
"editor.fontSize": 13,
"editor.fontFamily": "Monaco, 'Source Code Pro', Consolas, 'Ubuntu Mono', 'Courier New', monospace, 'Segoe UI Emoji'",
"editor.fontWeight": "100",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"editor.wordWrapColumn": 100,
"editor.minimap.enabled": false,