Skip to content

Instantly share code, notes, and snippets.

View x5lcfd's full-sized avatar
:octocat:
coding.

x5lcfd x5lcfd

:octocat:
coding.
View GitHub Profile
@x5lcfd
x5lcfd / Sublime.json
Created May 25, 2018 02:39
Sublime Configuration
// KeyBinding
[
{ "keys": ["ctrl+shift+i"], "command": "insert_date", "args": { "format": "%Y-%m-%d %I:%M"} },
{ "keys": ["ctrl+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["ctrl+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },
{ "keys": ["alt+left"], "command": "jump_back" },
{ "keys": ["alt+right"], "command": "jump_forward" },
]
void SyncGameObjectWithUIElement(Vector3 entityPos, Canvas canvas, RectTransform parentRectTransform, RectTransform targetRectTransform)
{
Vector3 screenPos = Camera.main.WorldToScreenPoint(entityPos);
entityPos = screenPos / canvas.scaleFactor;
Rect rect = parentRectTransform.rect;
entityPos.x = entityPos.x - rect.width * 0.5f;
entityPos.y = entityPos.y - rect.height * 0.5f;
entityPos.z = 0;
//targetRectTransform.anchoredPosition3D = entityPos;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// A base class for creating editors that decorate Unity's built-in editor types.
/// </summary>
public abstract class DecoratorEditor : Editor
@x5lcfd
x5lcfd / .clang-format
Last active August 30, 2018 16:48
clang format file
UseTab: Never
ColumnLimit: 0
IndentWidth: 4
AccessModifierOffset: -2
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
IndentCaseLabels: false
BreakConstructorInitializers: BeforeComma
IndentCaseLabels: true

// url => https://superuser.com/questions/723612/ping-and-nslookup-work-browsing-doesnt/723617

I believe that nslookup opens a winsock connection on the DNS port and issues a query, whereas ping uses the DNS Client service. You could try and stop this service and see whether this makes a difference.

Some commands that will reinitialize various network states :

Reset WINSOCK entries to installation defaults : netsh winsock reset catalog
Reset TCP/IP stack to installation defaults : netsh int ip reset reset.log
Flush DNS resolver cache : ipconfig /flushdns
Renew DNS client registration and refresh DHCP leases : ipconfig /registerdns

@x5lcfd
x5lcfd / tolua_GetCallStack.cs
Created December 29, 2017 12:32
tolua get call stack.
public static string tolua_GetCallStack(IntPtr L, string msg)
{
tolua_pushtraceback(L);
lua_pushstring(L, msg);
lua_pushnumber(L, 1);
if (lua_pcall(L, 2, -1, 0) == 0)
{
msg = lua_tostring(L, -1);
}
else
@x5lcfd
x5lcfd / lua-uuid.lua
Created October 20, 2017 08:24 — forked from jrus/lua-uuid.lua
quick lua implementation of "random" UUID
local random = math.random
local function uuid()
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
end)
end
@x5lcfd
x5lcfd / url_short.md
Last active October 5, 2018 09:11
url shortener
@x5lcfd
x5lcfd / gist:97b9002cf3218cb6a0d242a44945582e
Created July 23, 2017 16:25 — forked from ChickenProp/gist:3194723
The Liang-Barsky algorithm for line-rectangle collisions

The Liang-Barsky algorithm is a cheap way to find the intersection points between a line segment and an axis-aligned rectangle. It's a simple algorithm, but the resources I was pointed to didn't have particularly good explanations, so I tried to write a better one.

Consider a rectangle defined by x_min ≤ x ≤ x_max and y_min ≤ y ≤ y_max, and a line segment from (x_0, y_0) to (x_0 + Δ_x, y_0 + Δ_y). We'll be assuming at least one of Δ_x and Δ_y is nonzero.

Image depicting the situation

(I'm working with Flash, so I'll be using the convention that y increases as you go down.)

We want to distinguish between the following cases:

@x5lcfd
x5lcfd / vsvimrc.vim
Created July 23, 2017 02:43
rename to _vsvimrc for visual studio.
nnoremap h <NOP>
nnoremap j <NOP>
nnoremap k <NOP>
nnoremap l <NOP>
nmap <C-O> :vsc View.NavigateBackward<CR>
nmap <C-I> :vsc View.NavigateForward<CR>