Skip to content

Instantly share code, notes, and snippets.

@xiangyuan
xiangyuan / CinemachineCameraShaker.cs
Created September 19, 2018 07:12 — forked from reunono/CinemachineCameraShaker.cs
Cinemachine camera shake
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Add this component to your Cinemachine Virtual Camera to have it shake when calling its ShakeCamera methods.
/// </summary>
public class CinemachineCameraShaker : MonoBehaviour
{
@xiangyuan
xiangyuan / NotchUtil.java
Created August 22, 2018 08:11 — forked from Jayatubi/NotchUtil.java
Detect notch on Android devices for Huawei, Oppo, Vivo
package com.actgames.fci.util;
import android.app.Activity;
import com.unity3d.player.UnityPlayer;
import java.lang.reflect.Method;
/**
* Created by mofei on 2018/5/11.
using UnityEngine;
using System.Collections;
namespace UnityEngine.UI
{
public class Empty4Raycast : MaskableGraphic
{
protected Empty4Raycast()
{
useLegacyMeshGeneration = false;
@xiangyuan
xiangyuan / timezone.lua
Created August 23, 2017 02:40 — forked from 1901/timezone.lua
lua中获取本地时区(timezone)的方法
--[[
打印时区信息
--]]
function os.printTimezone()
local t = os.time()
local ut = os.date('!*t',t)
local lt = os.date('*t',t)
local tzdt = (lt.hour - ut.hour) * 3600 + (lt.min - ut.min) * 60
print(string.format("本地时间与标准时间差 %d(%.1f小时) 分钟", tzdt, tzdt / 3600))
end
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@xiangyuan
xiangyuan / Liberal Regex Pattern for Web URLs
Created June 1, 2016 05:53 — forked from gruber/Liberal Regex Pattern for Web URLs
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@xiangyuan
xiangyuan / Liberal Regex Pattern for All URLs
Created June 1, 2016 05:52 — forked from gruber/Liberal Regex Pattern for All URLs
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:[email protected]", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
@xiangyuan
xiangyuan / UsefulUnityAssets.md
Created May 5, 2016 07:52 — forked from terrehbyte/UsefulUnityAssets.md
Useful Open-Source Unity Assets

Useful Open-Source Unity Assets

This is a compilation of various open-source Unity plugins, codebases, or utility scripts that may aid in expediting the development process.

Art / Design Tools

ProbePolisher - Light Probe Editor - keijiro

"ProbePolisher is a Unity Editor plugin for editing light probes. It works both on Unity Basic (free) and Unity Pro."

Code
Releases

local ClientSocket = {}
local socket = require("socket.core")
local sockInst = nil
-- ------------------------------------------------
local connStatus = nil
local SOCK_STATUS={INIT=1, CONNECTING=2, CONNECTED=3,DISCONNECT=4,FORCEDISCONNECT=5}
local connTime = nil
local tryConnTimes = 0
@xiangyuan
xiangyuan / SmartBarUtils.java
Created November 30, 2015 03:08 — forked from shawnlinboy/SmartBarUtils.java
一个扩展后的魅族SmartBar工具类,增加三种隐藏SmartBar的方法,过期一种方法。
package in.mobilelin.smartbar;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.ActionBar;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;