Skip to content

Instantly share code, notes, and snippets.

View Meigyoku-Thmn's full-sized avatar
👋
I may be slow to respond.

Meigyoku Thmn Meigyoku-Thmn

👋
I may be slow to respond.
  • Nha Trang, Việt Nam
View GitHub Profile
@Meigyoku-Thmn
Meigyoku-Thmn / line-breaking-algorithm.js
Last active July 9, 2018 12:28
Greedy Line Breaking Algorithm
var LineBreaker = require('@rkusa/linebreak');
// https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Unicode
// for emoji and some special cases: https://getdango.com/unbreakable-kaomoji/
var input = `Chém gió:
Từ này được dùng để miêu tả hành động vừa phát biểu vừa vung bàn tay về một phía (thường là vung tay lên, xuống) mỗi khi muốn nhấn mạnh, bày tỏ cảm xúc, thể hiện quyết tâm hay phản bác một điều gì đó, trông như đang dùng tay chém vào gió nên gọi là chém gió.`;
var breaker = new LineBreaker(input);
var last = 0;
var bk;
var state = {
maxChar: 51,
@Meigyoku-Thmn
Meigyoku-Thmn / How to pull, commit and push to remote branch in submodule.md
Last active October 7, 2019 16:10
How to pull, commit and push to remote branch in submodule

Submodule in git is always in detached state, there is no other way.

If you want to update submodule:

git checkout master #or <your remote branch name>

If you want to pull and merge submodule:

git pull origin master #or 
@Meigyoku-Thmn
Meigyoku-Thmn / How to debug Renpy's python code by using remote debugging.md
Last active July 7, 2021 10:13
How to debug Renpy's python code by using remote debugging

Update 2021: This can only work with Ren'Py 7.3, the newer versions use a vastly different type of built-in Python interpreter that are completely incompatible with any canonical Python interpreter.


The problem is that the Python runtime in RenPy is a stripped one. It's not the full Python. Don't even try to replace it with a full python runtime, you would have a really bad time.

The only feasible way is to use remote debugging. I assume you use Windows OS and have knowledge about programming, file system.


Demonstration Video <Will add later>


@Meigyoku-Thmn
Meigyoku-Thmn / introrx.md
Created March 16, 2020 08:14 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@Meigyoku-Thmn
Meigyoku-Thmn / typescript-decorators.ts
Created August 12, 2020 08:52
How do typescript decorators work?
// Typescript 3.9.6
@classDeco
class ABC {
@propDeco
data: string;
@propDeco
static data2: string;
@Meigyoku-Thmn
Meigyoku-Thmn / css-rules.css
Last active October 27, 2020 17:50
CSS rules for Discord font customing
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap');
.da-messageContent .emoji {
width: 2.5em;
height: 2.5em;
vertical-align: middle;
}
.da-messageContent, .da-username,
.da-headerName, .da-roleName, .da-title,
.da-topic, .da-name, .da-guildNameText, .da-markup {
font-family: "Roboto", "Segoe UI", Tahoma, Arial, sans-serif;
@Meigyoku-Thmn
Meigyoku-Thmn / DecoderCP1252Fallback.cs
Created March 28, 2021 11:10
C# UTF8 Encoding with CP1252 Fallback
public class DecoderCP1252Fallback : DecoderFallback
{
public override DecoderFallbackBuffer CreateFallbackBuffer()
{
return new DecoderCP1252FallbackBuffer();
}
public override int MaxCharCount {
get {
return 1;
@Meigyoku-Thmn
Meigyoku-Thmn / LinqEx.cs
Created April 27, 2021 03:58
Some convenient custom-defined extension method for Linq
public static class Helper
{
public static int FindIndex(this string text, Predicate<char> match, int startIndex = 0, int count = -1)
{
if (count < 0)
count = text.Length;
return text
.Select((chr, idx) => (chr, idx: idx as int?))
.Skip(startIndex)
@Meigyoku-Thmn
Meigyoku-Thmn / Overflow.js
Last active May 17, 2021 04:15
Integer overflow wrapping for Javascript (for browsers that can optimize double to integer)
const IntMask = 0xFFFFFFFF;
function iadd(a, b) {
return ((a & IntMask) + (b & IntMask)) & IntMask;
}
function isubt(a, b) {
return iadd(a, -b);
}
@Meigyoku-Thmn
Meigyoku-Thmn / STARTUPINFO_secret.md
Last active May 19, 2021 04:25
Pass arbitrary data to a child process! (Archived from an old article)

Taken from https://is.muni.cz/el/1433/jaro2010/PB167/um/cv5/undocumented_CreateProcess.pdf

libuv has utilized this to pass file descriptors to child process (remember that Windows doesn't have file descriptor concept):


Pass arbitrary data to a child process!

The last undocumented trick is quite different to the previous ones so I thought I'd save it until last. The STARTUPINFO structure contains two members, lpReserved2 and cbReserved2: