Skip to content

Instantly share code, notes, and snippets.

View TranHaiQuan's full-sized avatar
🏆
Vượt Cạn

Tran Hai Quan TranHaiQuan

🏆
Vượt Cạn
View GitHub Profile
@TranHaiQuan
TranHaiQuan / ISAdsManager.cs
Last active April 14, 2023 04:33
Docs Push Revenue Ironsource of Firebase
/*
All docs get from
Adjust:
https://github.com/adjust/unity_sdk/blob/master/doc/english/sdk-to-sdk/ironsource.md
Ironsource push Rev
https://developers.is.com/ironsource-mobile/unity/ad-revenue-measurement-integration/#step-1
Note: Không push rev ở event onImpressionDataSuccessEvent mà push rev ở event onImpressionDataReadyEvent
*/
@TranHaiQuan
TranHaiQuan / CameraBillboard.cs
Created September 27, 2021 03:31 — forked from ditzel/CameraBillboard.cs
Rotates an object (e.g. a canvas) to face it towards the camera
/*
* Rotates an object towards the currently active camera
*
* 1. Attach CameraBillboard component to a canvas or a game object
* 2. Specify the offset and you're done
*
**/
using UnityEngine;
@TranHaiQuan
TranHaiQuan / Vibration.cs
Created May 17, 2021 11:50 — forked from aVolpe/Vibration.cs
Vibration for Unity3d with Android native Call, with fallback to Handlheld.Vibrate()
using UnityEngine;
using System.Collections;
public static class Vibration
{
#if UNITY_ANDROID && !UNITY_EDITOR
public static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
public static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
public static AndroidJavaObject vibrator = currentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator");
@TranHaiQuan
TranHaiQuan / Note.md
Last active October 8, 2019 03:37
Set up Rails project internal step by step

Init new project

Setting rubocop

Setting database, config

Setting nginx, subdomain

# in routes.rb
Rails.application.routes.draw do
  constraints subdomain: /(subdomain1|subdomain2|subdomain_n)/ do
    constraints subdomain: /^subdomain1/ do
 root to: "subdomain1/homes#show", as: :subdomain1_root
@TranHaiQuan
TranHaiQuan / product.js
Last active August 24, 2019 08:54
For first submit ajax CKEDITOR
/*
Before serialize data must update element of instance CKEDITOR
*/
$(function() {
$("#form-submit-ajax-has-multi-image").on("submit", function(e) {
for (instance in CKEDITOR.instances ) {
CKEDITOR.instances[instance].updateElement();
}
e.preventDefault();
@TranHaiQuan
TranHaiQuan / Note.md
Last active August 21, 2019 04:39
Sort kết hợp 1 trong 2 field null, sử dụng select if or select IFNULL
@TranHaiQuan
TranHaiQuan / Note.txt
Created August 17, 2019 01:23
About CKeditor
<%= javascript_include_tag Ckeditor.cdn_url %>
phải ở trước html content để load ckeditor trước
<!DOCTYPE html>
<html>
<head>
<title>DemoCkeditor</title>
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="05DsTmL/Ex9rB0qdNh/D6ArOrdNb/ZyoEMj84Mkfsk48JG2QzhK6Ytd/se94FsEsQfYozAwiyvBr5cEXa0pEXw==" />
@TranHaiQuan
TranHaiQuan / vim
Created August 20, 2018 14:33
Install ZSH
sudo apt-get install zsh
sudo apt-get install git-core
Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
and then you change your shell to zsh
chsh -s `which zsh`
and then restart
@TranHaiQuan
TranHaiQuan / valid_date_validator.rb
Created July 15, 2018 01:10
Valid date by format dd/mm/yyyy or yyyy/mm/dd
class ValidDateValidator < ActiveModel::EachValidator
# format dd/mm/yyyy
DATE_FORMAT_REGEX = /^\s*(3[01]|[12][0-9]|0?[1-9])\/(1[012]|0?[1-9])\/((?:19|20)\d{2})\s*$/
# format yyyy/mm/dd
# DATE_FORMAT_REGEX = /\A[0-9]{4}(\/|\-)(0[1-9]|1[0-2])(\/|\-)(0[1-9]|[1-2][0-9]|3[0-1])\z/
def validate_each record, attribute, _value
records = if record.is_a?(ActiveRecord::Base)
record.attributes_before_type_cast
else
record.as_json
@TranHaiQuan
TranHaiQuan / devise.rb
Created June 26, 2018 04:01
Add time out devise
# add config 30 day so logout
config.timeout_in = 30.days