Skip to content

Instantly share code, notes, and snippets.

View paxbun's full-sized avatar

Chanjung Kim paxbun

View GitHub Profile
@paxbun
paxbun / CGFontToFontData.m
Created June 26, 2023 05:50 — 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;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
// ==== Foo ====
// Foo.Nullable: Nullable
// Foo.NonNullable: NotNull
PrintNullabilityState(typeof(Foo));
// ==== DynamicFoo ====
@paxbun
paxbun / main.swift
Last active August 7, 2022 11:54
CoreML crashes with TensorFlow 2 models with multiple Conv1D and LayerNorm layers
import CoreML
let model = try! MyModel()
let inputData = [Float](repeating: 0.1, count: 4096 * 2)
let inputArray = MLShapedArray(scalars: inputData, shape: [1, 4096, 2])
let input = MyModelInput(input_1: inputArray)
let output = try! model.prediction(input: input)
print("\(output.IdentityShapedArray.shape)")
@paxbun
paxbun / fromdict.py
Created July 22, 2022 06:37
Python dataclass inverse of asdict
from dataclasses import is_dataclass, fields
from typing import TypeVar
T = TypeVar("T")
def fromdict(d: dict, ty: type[T]) -> T:
assert is_dataclass(ty)
for field in fields(ty):
if field.name in d:
using System.Collections.Concurrent;
using System.Text.RegularExpressions;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyHeader();
policy.AllowAnyMethod();
using System.Collections.Concurrent;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text.RegularExpressions;
using Microsoft.Azure.Management.Media.Models;
using Microsoft.IdentityModel.Tokens;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
@paxbun
paxbun / README.md
Created February 17, 2022 10:01
Share your GitHub contributions in Wordle style

Execute the JS code and you will get this:

image

@paxbun
paxbun / Program.cs
Created August 9, 2021 08:41
C# arbitrary type to dictionary
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
public class Foo
{
public string BarBar { get; set; }
public int BazBazBaz { get; set; }
}
module float32_add_4
(
input [31:0] args [3:0],
output [31:0] res
);
wire [31:0] add1_res, add2_res;
float32_add adder1 (.lhs(args[0]), .rhs(args[1]), .res(add1_res));
float32_add adder2 (.lhs(args[2]), .rhs(args[3]), .res(add2_res));
float32_add adder3 (.lhs(add1_res), .rhs(add2_res), .res(res));
endmodule
@paxbun
paxbun / float32.v
Last active July 7, 2021 17:58
IEEE single-precision floating-point format addition/multiplication implementation (not handling NaN and INF)
module float32_splitter
(
input [31:0] in,
output sgn,
output [8:0] exp,
output [23:0] man
);
assign sgn = in[31];
assign exp[8] = 0;
assign exp[7:1] = in[30:24];