This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool Raycast(Ray r, out float distance) | |
{ | |
Vector3 min = this.min; | |
Vector3 max = this.max; | |
float tmin = float.NegativeInfinity, tmax = float.PositiveInfinity; | |
Vector3 dir_inv = new Vector3(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Array { | |
func random2(_ lower: Int, _ upper: Int) -> Int { | |
return random() % (upper - lower) + lower | |
} | |
func randomTake<T>(_ n: Int) -> [T] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// 1. Wildcard Pattern | |
func wildcard(a: String?) -> Bool { | |
guard case _? = a else { return false } | |
for case _? in [a] { | |
return true | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Globalization; | |
using System.Text; | |
namespace Procurios.Public | |
{ | |
/// <summary> | |
/// This class encodes and decodes JSON strings. | |
/// Spec. details, see http://www.json.org/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
public class ReimportUnityEngineUI | |
{ | |
[MenuItem("Assets/Reimport UI Assemblies", false, 100)] | |
public static void ReimportUI() | |
{ | |
#if UNITY_4_6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UTF8 | |
{ | |
/// <summary> | |
/// 计算utf-8编码后的字节数 | |
/// </summary> | |
/// <param name="code">Unicode</param> | |
/// <returns>utf-8编码后的字节数</returns> | |
public static int GetByteCount(int code) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Ll]ibrary/ | |
[Tt]emp/ | |
[Oo]bj/ | |
[Bb]uild/ | |
[Dd]ebug/ | |
[Rr]elease/ | |
# Autogenerated VS/MD solution and project files | |
*.csproj | |
*.unityproj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getVersionCode(Context ctx) { | |
int versionCode = 0; | |
try { | |
PackageInfo pInfo = ctx.getPackageManager().getPackageInfo( | |
ctx.getPackageName(), 0); | |
versionCode = pInfo.versionCode; | |
} catch (PackageManager.NameNotFoundException e) { | |
e.printStackTrace(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T, T... _Rest> | |
struct array_pack; | |
template<typename T> | |
struct array_pack<T>{}; | |
template<typename T, T _This, T... _Rest> | |
struct array_pack<T, _This, _Rest...> : private array_pack<T, _Rest...> | |
{ | |
const T & operator[](const int pos) | |
{ | |
//as cpp memory layout, indexing reversely |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 32bit FNV-1 and FNV-1a string hasing (Fowler–Noll–Vo hash) | |
// | |
// Requires a compiler with C++11 support | |
// See main(...) for examples | |
#include <iostream> | |
#include <cassert> | |
namespace hash | |
{ |