Skip to content

Instantly share code, notes, and snippets.

View dev-chee's full-sized avatar

chi.zheng dev-chee

View GitHub Profile
@dev-chee
dev-chee / revert.cs
Created November 1, 2021 08:47
revert a list
using System;
namespace hello_csharp
{
class Program
{
class Node
{
public int val;
public Node next;
@dev-chee
dev-chee / permutation.rs
Created June 28, 2020 02:41
排列算法
// 排列算法 P_{cnt}^{nums.len()}
fn permutation(nums: Vec<i32>, cnt: usize) -> Vec<Vec<i32>> {
fn helper(result: &mut Vec<Vec<i32>>, nums: &mut Vec<i32>, cnt: usize, idx: usize) {
if idx == cnt {
result.push(Vec::from(&nums[..idx]));
return;
}
// 第idx个元素可选择的方法
for i in idx..nums.len() {
@dev-chee
dev-chee / HOWTO-UpdateMusicAssets.md
Created November 20, 2019 03:51
Update level music assets.

修改场景音乐

  1. 在Music.xls配置对应的音乐资源名称(注意,不含路径和扩展名)
  2. 在Levels.xls中关联对应的音乐ID到场景
  3. 如果音乐资源文件路径与扩展名已经更改,请修改如下代码
   // File: Assets/GamePlay/Basic/AssetUtility.cs

   public static string GetMusicAsset(string assetName)
   {
@dev-chee
dev-chee / MainBuild.gradle
Last active November 6, 2019 02:37
unity build script for android
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com'
name 'Google'
}
}
class Vec
{
public:
virtual ~Vec()
{
std::cout << "Call ~Vec" << std::endl;
}
};
class VecL : public Vec
@dev-chee
dev-chee / gist:e6bd4b36f690c420d55f570619c5c652
Created May 29, 2018 09:39
Best way to create an ISO for macOS High Sierra 5.23 GB
hdiutil create -o /tmp/HighSierra.cdr -size 5130m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -mountpoint /Volumes/install_build
sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build
mv /tmp/HighSierra.cdr.dmg ~/Desktop/InstallSystem.dmg
hdiutil detach /Volumes/Install\ macOS\ High\ Sierra
hdiutil convert ~/Desktop/InstallSystem.dmg -format UDTO -o ~/Desktop/HighSierra.iso
@dev-chee
dev-chee / gist:bda0384db951eaddfb6444209d397a48
Created May 14, 2018 07:21
Difference between enabled, isActiveAndEnabled and activeInHierarchy in Unity
isActiveAndEnabled and enabled seems very confusing to beginners and I bet most people still don't know the difference and when to use each one. I was one of these people.
Two things to understand:
A.GameObjects can be activated and de-activated.
B.Scripts can be enabled and disabled.
The keyword in isActiveAndEnabled should explains it all.
@dev-chee
dev-chee / UnityProfiler-1.md
Created March 9, 2018 03:07
WaitForTargetFPS Gfx.WaitForPresent Graphics.PresentAndSync

WaitForTargetFPS

该参数一般出现在CPU开销过低,且通过设定了目标帧率的情况下(Application.targetFrameRate)。 当上一帧低于目标帧率时,将会在本帧产生一个WaitForTargetFPS的空闲等待耗时,以维持目标帧率。

该项在Unity引擎的主循环中其实是最早执行的,即引擎实际上是根据上一帧的CPU耗时,在当前帧中通过增补WaitForTargetFPS的方式来将运行FPS维持到目标值。 比如,目标帧率为30帧/秒,上一帧耗时15ms,那么当前帧中WaitForTargetFPS将会是18(33-15)ms, 但是这一帧中其他耗时为28ms,那么在Profiler中这一帧的总耗时就变成了46(18+28)ms。

Gfx.WaitForPresent && Graphics.PresentAndSync

@dev-chee
dev-chee / PBR_BRDF.md
Last active November 7, 2017 12:40
PBR BRDF
$$Light Vector: \$l\$, View Vector: \$v\$ Halfway Vector: \$h=\frac{l+v}{\|l+v\|}\$ Radient Flux: \$\Phi\$, Radiance: \$L=\frac{\mathrm{d^2}\Phi}{\mathrm{d}A\mathrm{d}\omega\cos{\theta}}\$ Irradiance: \$E_i(\omega_{i})\$, Radiance: \$L_o(\omega_{o})\$ BRDF: \$f_{r}(\omega_{i},\omega_{o})=\frac{\mathrm{d}L_o(\omega_{o})}{\mathrm{d}E_i(\omega_{i})}=\frac{\mathrm{d}L_o(\omega_o)}{L_i(\omega_i)\cos\theta_i\mathrm{d}\omega_i}\$ Reflectance Equation:$$
@dev-chee
dev-chee / MainprocedureInVB.md
Last active August 11, 2016 03:41
Visual Basic主过程

Visual Basic主过程(Main Procedure)

除非你正在创建一个窗体应用程序,否则每个Visual Basic应用程序都应该包含一个主过程。该过程作为应用程序的入口点,当应用程序运行时,.NET框架调用这个主过程并赋予其执行权。

在应用程序运行时,主过程内的代码将首先执行。在主过程中,你能决定应用程序开始运行时,加载哪些Form,是否已经运行了该应用程序的副本,创建变量,又或是打开数据库等。

主过程(Main Procedure)的基本要求

应用程序(通常以.exe作为扩展名)必须包含一个主过程,而库(通常以.dll作为扩展名)并不能运行自己因此并不需要主过程。根据项目的类型,主过程存在下列基本要求:

  • 控制台应用程序,必须至少包含一个主过程;