Skip to content

Instantly share code, notes, and snippets.

View congnt24's full-sized avatar
💭
exploring

Cong Nguyen congnt24

💭
exploring
  • Hanoi
View GitHub Profile
@congnt24
congnt24 / FBUnityHandler
Created December 14, 2015 08:18
Using FB sdk in unity to get Information, share, get and set score
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using Facebook.Unity;
using System.Collections.Generic;
using Facebook.MiniJSON;
public class FBController : MonoBehaviour {
Button[] btn = new Button[4];
@congnt24
congnt24 / .gitconfig
Created March 11, 2016 02:57
Git config use for command-line
[user]
name = Nguyen Trung Cong
email = congnt24@gmail.com
[color]
ui = true
[merge]
tool = meld
conflictstyle = diff3
[mergetool "mymeld"]
cmd = meld --diff $BASE $LOCAL --diff $BASE $REMOTE --diff $LOCAL $MERGED $REMOTE
@congnt24
congnt24 / Android_GetListContact
Created October 14, 2016 04:27
Get list contact
https://gist.github.com/evandrix/7058235
@congnt24
congnt24 / Realm Tips
Created March 24, 2017 03:48
Tips for using realm
1. Using realm.executeTransaction instead realm.beginTransaction and realm.commitTransaction because executeTransaction() automatically handles calling realm.cancelTransaction() in case an exception is thrown.
//Using retrolambda
try(Realm realmInstance = Realm.getDefaultInstance()) {
realmInstance.executeTransaction((realm) -> realm.insertOrUpdate(dog));
}
2. Close Realm after opening Realm instances
3. A tip: you should open your first Realm instance on the UI thread only after the first Activity has been created, just to be safe from context.getFilesDir() == null
4. using realmREsults.asObservable() or Observable.just(realm.where(...)).find*()
5. Using findAllSorted() instead of findAll.sort()
6. Using @Index to speed up

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@congnt24
congnt24 / SendSMSViewController.swift
Created August 28, 2017 15:13 — forked from soggybag/SendSMSViewController.swift
Send SMS Messages with Swift
import UIKit
import MessageUI // Import MessageUI
// Add the delegate protocol
class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {
// Send a message
func sendMessage() {
let messageVC = MFMessageComposeViewController()
messageVC.body = "Message String"
@congnt24
congnt24 / Lọc dấu
Last active September 22, 2017 04:32
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
var deburredLetters = {
// Latin-1 Supplement block.
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'C', '\xe7': 'c',
'\xd0': 'D', '\xf0': 'd',
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
@congnt24
congnt24 / docker-compose.yml
Created November 8, 2017 08:19 — forked from elleryq/docker-compose.yml
docker + node-exporter + prometheus + promdash
# Need to do the following steps:
# 1. create /var/prometheus first.
# 2. run: docker-compose run promdash ./bin/rake db:migrate
nodeexporter:
image: prom/node-exporter
ports:
- "9100:9100"
prometheus:
image: prom/prometheus
@congnt24
congnt24 / query
Last active November 22, 2017 07:18
SELECT
*,
(SELECT json_build_object('id', ref.user_id, 'email', ref.email)
FROM user_profile_with_referal ref
WHERE customer_id = 84061) AS referal_info
FROM user_profile_full
WHERE user_id = 84061;
@congnt24
congnt24 / gist:2bb4e861154f26659421fb8abee8e96c
Created December 6, 2017 08:30 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt