Skip to content

Instantly share code, notes, and snippets.

View stanleytangerror's full-sized avatar

stanley stanleytangerror

View GitHub Profile
@stanleytangerror
stanleytangerror / StatelessCalender.cs
Last active January 11, 2025 04:36
Inspired by [CppCon 2015: Eric Niebler "Ranges for the Standard Library"](https://www.youtube.com/watch?v=mFUXNMfaciE&ab_channel=CppCon)
// Inspired by CppCon 2015: Eric Niebler "Ranges for the Standard Library", https://www.youtube.com/watch?v=mFUXNMfaciE&ab_channel=CppCon
using System.Globalization;
public static class Program
{
static IEnumerable<IEnumerable<T>> Transpose<T>(this IEnumerable<IEnumerable<T>> source)
=> source
.SelectMany(inner => inner.Select((item, index) => new { item, index }))
.GroupBy(i => i.index, i => i.item)
@stanleytangerror
stanleytangerror / Feeds.opml
Last active March 6, 2025 14:11
RSS feeds
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<head>
<title>Feeds</title>
</head>
<body>
<outline title=".NET" text=".NET">
<outline xmlUrl="https://devblogs.microsoft.com/dotnet/feed/" text=".NET Blog"
type="rss" htmlUrl="https://devblogs.microsoft.com/dotnet/" title=".NET Blog" />
<outline htmlUrl="https://devblogs.microsoft.com/dotnet-ch/"
@stanleytangerror
stanleytangerror / Countdown.js
Last active February 25, 2024 12:41
Countdown widget in iOS Scriptable
class ComingEvent {
constructor(name, description, countDownTime, happenTime) {
this.name = name;
this.description = description || '✏️';
this.countDownTime = countDownTime;
this.happenTime = happenTime;
}
get percentage() {
var total = this.happenTime - this.countDownTime;
@stanleytangerror
stanleytangerror / buildout-vm.ps1
Last active August 27, 2023 11:38
[Azure VM] Renew public ip
param (
[string]$vmName,
[string]$vmSize,
[string]$ubuntuOSVersion,
[string]$location
)
$resourceGroupName = $vmName
New-AzResourceGroup -Name $resourceGroupName -Location $location
@stanleytangerror
stanleytangerror / GradientNoise.py
Last active April 6, 2025 08:13
Implement gradient noise by taichi
import taichi as ti
from taichi.math import *
import time
import numpy as np
@ti.func
def _Gradient3D(h):
h = h & 15
d = GradientNoise.v3f(0, 0, 0)
@stanleytangerror
stanleytangerror / RayTracingInOneWeekend.py
Last active May 9, 2022 10:44
Implement RayTracingInOneWeekend by Taichi
import taichi as ti
from taichi.math import *
import numpy as np
from pyquaternion import Quaternion
import math
import random
# ---------------------------------------------------------------------
Vec2i = ti.types.vector(2, ti.i32)
@stanleytangerror
stanleytangerror / GaussianBlur.py
Created February 19, 2020 10:38
Generate gaussian blur kernel sample uvs and weights
# according to http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
# generate gaussian blur kernel sample uvs and weights
DropWeightThreshold = 13.1 / 4096
def NextLevel(lastLevel):
thisLevel = [lastLevel[i] + lastLevel[i + 1] for i in range(len(lastLevel) - 1)]
thisLevel.insert(0, 1)
thisLevel.append(1)
return thisLevel