Skip to content

Instantly share code, notes, and snippets.

View geniuszxy's full-sized avatar
🍋
Focusing

Shingo geniuszxy

🍋
Focusing
View GitHub Profile
@geniuszxy
geniuszxy / Two point line formula
Created July 30, 2022 07:36
Two point line formula
(y₂-y₁)x - (x₂-x₁)y - x₁y₂ + x₂y₁ = 0
@geniuszxy
geniuszxy / GetPrimes.cs
Last active February 13, 2022 13:24
Get Primes
#define PROFILE
//#define OUTPUT
//#define USE_BITS
//#define SHIFT
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
class Program
@geniuszxy
geniuszxy / RoundedRectangle.shader
Last active December 30, 2021 06:06
Rounded corner rectangle shader (support different radius for each corner), idea from https://www.shadertoy.com/view/WtdSDs
Shader "Hidden/RoundedRectangle"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Radius("Radius %", Range(0, 0.5)) = 0.2
}
SubShader
{
Tags
@geniuszxy
geniuszxy / userChrome.css
Last active February 4, 2022 14:29
Backup of my userChrome.css for firefox
/*** BEGIN Firefox 77 (June 2, 2020) Override URL bar enlargement ***/
/* Compute new position, width, and padding */
#urlbar[breakout][breakout-extend] {
top: 5px !important;
left: 0px !important;
width: 100% !important;
padding: 0px !important;
}
@geniuszxy
geniuszxy / love_orgplayer_thread.lua
Last active July 9, 2021 14:19
An org player written in love
--[[
== Usage ==
1. Get the control channel
ch = love.thread.getChannel('orgplayer')
2. Create a thread and start it
th = love.thread.newThread('love_orgplayer_thread.lua')
th:start()
@geniuszxy
geniuszxy / EmojiIterator.cs
Last active July 27, 2023 11:26
A simple class iterates over a string that accounts an emoji sequence as a single character.
public class EmojiIterator
{
private string _text;
private int _head, _next;
private int _index, _length;
public EmojiIterator(string text)
{
_text = text;
Reset();
@geniuszxy
geniuszxy / CGFontToFontData.m
Created October 24, 2020 04:36 — forked from Bokugene/CGFontToFontData.m
Read Table Data from a CGFont, then wrap them into a OTF/TTF font.
typedef struct FontHeader {
int32_t fVersion;
uint16_t fNumTables;
uint16_t fSearchRange;
uint16_t fEntrySelector;
uint16_t fRangeShift;
}FontHeader;
typedef struct TableEntry {
uint32_t fTag;
@geniuszxy
geniuszxy / Trie.cs
Last active February 28, 2020 08:11
Efficient trie implemention without multiple dictionaries (or linked lists)
using System;
using System.Collections;
using System.Collections.Generic;
namespace Filter
{
using NodeKey = System.UInt64;
public class Trie
{
@geniuszxy
geniuszxy / QuickSort.cpp
Last active June 17, 2019 06:29
Quick Sort
void Swap(int array[], int a, int b)
{
int tmp = array[a];
array[a] = array[b];
array[b] = tmp;
}
void PrintArray(int array[], int length, int lower, int upper)
{
for (int i = 0; i < length; ++i)
@geniuszxy
geniuszxy / BetterHashSet.cs
Created May 30, 2019 14:57
BetterHashSet
using System;
using System.Collections;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Security.Permissions;
using System.Text;
using System.Diagnostics.CodeAnalysis;
using System.Security;
namespace System.Collections.Generic