Skip to content

Instantly share code, notes, and snippets.

View ezirmusitua's full-sized avatar
🎯
Focusing

ezirmusitua ezirmusitua

🎯
Focusing
View GitHub Profile
@ezirmusitua
ezirmusitua / format-time-string.cs
Last active September 10, 2019 21:38
[Format time string] Format time string from milliseconds #C# #time
string FormatTimeString(int ms) {
TimeSpan t = TimeSpan.FromMilliseconds(ms);
return $"{t.Hours:D2}h:{t.Minutes:D2}m:{t.Seconds:D2}s:{t.Milliseconds:D2}ms";
}
@ezirmusitua
ezirmusitua / flatten-dict.py
Created May 17, 2019 02:33
[Flatten dict] flatten nested dict #python
# reference: https://stackoverflow.com/questions/6027558/flatten-nested-dictionaries-compressing-keys
import collections
def flatten_nested_dict(d, parent_key='', sep='_'):
items = []
for k, v in d.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, collections.MutableMapping):
items.extend(flatten(v, new_key, sep=sep).items())
else:
@ezirmusitua
ezirmusitua / format-string.py
Created May 17, 2019 02:31
[Format string] Format string(string template) #python
# referenece: https://realpython.com/python-string-formatting/
# 1. use % operator
'Hello, %s' % name
'Hey %s, there is a 0x%x error!' % (name, errno)
'Hey %(name)s, there is a 0x%(errno)x error!' % { "name": name, "errno": errno }
# 2. use `string.format`
'Hello, {}'.format(name)
'Hey {name}, there is a 0x{errno:x} error!'.format(name=name, errno=errno)
@ezirmusitua
ezirmusitua / enable-remote-desktop.md
Created May 17, 2019 02:27
[Enable remote desktop connection] Enable remote desktop connection in windows #windows
  1. Win + R 并输入 services.msc, 开启 Remote Desktop Services

  2. 我的电脑 -> 属性 -> 远程桌面 -> 勾选 允许运行任意版本远程桌面的计算机连接 并 设置 用户

@ezirmusitua
ezirmusitua / open-remote-desktop.md
Created May 17, 2019 02:22
[Open remote desktop] Open remote desktop in windows #windows
  1. Win + R 打开运行

  2. 输入 mstsc

@ezirmusitua
ezirmusitua / int-to-money.cs
Last active September 10, 2019 21:38
[Format integer to money] Format integer to money string #C#
string IntToMoney(int value) {
return $"$ {value:###,###}"
}
@ezirmusitua
ezirmusitua / pass-through-collider.md
Created May 10, 2019 04:09
[Pass collider and detect collision] Enable pass through colider and detect collision #unity
  1. Enable Pass Through
    Tick Trigger Of Collider In Inspector

  2. Detect Collision Implement OnTriggerEnter method

private void OnTriggerEnter (Collider col) {
  // do something
}
@ezirmusitua
ezirmusitua / remove-surveillance.sh
Last active May 10, 2019 04:03
[Remove Surveillance In VPS] remove surveillance while using aliyun & qcloud #vps #security
# Source https://51.ruyo.net/5369.html
# For Aliyun
## vim remove-aegis.sh
#!/bin/bash
## check linux Gentoo os
var=`lsb_release -a | grep Gentoo`
if [ -z "${var}" ]; then
var=`cat /etc/issue | grep Gentoo`
fi
@ezirmusitua
ezirmusitua / disable-multi-touch-in-phone.cs
Last active September 10, 2019 21:38
[Disable MultiTouch In Phone] Disable Multi Touch In Phone In Unity #unity #C#
Input.multiTouchEnabled = false; // disable
@ezirmusitua
ezirmusitua / mainTemplate.gradle
Last active April 12, 2019 02:29
[Use aliyun maven repo service] Replace default repo with aliyun maven repo service #unity #android #gradle
// If using unity, find mainTemplate.gradle in `Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates`
// If want add other maven repo, find in `https://maven.aliyun.com/mvn/view`
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
// google()
// jcenter()
}