Skip to content

Instantly share code, notes, and snippets.

View gain620's full-sized avatar
:dependabot:
Not a bot!

Gain Chang gain620

:dependabot:
Not a bot!
View GitHub Profile
@gain620
gain620 / fast_inverse_sqrt.zig
Created February 21, 2025 09:45
Fast Inverse Square Root for Zig
const std = @import("std");
/// Compute the fast inverse square root of a given f32 number.
pub fn fastInvSqrt(number: f32) f32 {
// Interpret the floating-point number as an unsigned 32-bit integer.
var i: u32 = @bitCast(u32, number);
// Magic constant and bit manipulation.
i = 0x5f3759df - (i >> 1);
// Reinterpret the bits back into a floating-point value.
var y: f32 = @bitCast(f32, i);
@gain620
gain620 / config
Created February 6, 2025 12:42 — forked from adibhanna/config
Ghostty config
font-family = BerkeleyMono Nerd Font
#font-family = Iosevka Nerd Font
# font-family = SFMono Nerd Font
font-size = 20
theme = GruvboxDarkHard
shell-integration-features = no-cursor,sudo,no-title
cursor-style = block
adjust-cell-height = 35%
# background-opacity = 0.96
class FancyLogger {
constructor() {
if(FancyLogger.instance == null) {
this.logs = [];
FancyLogger.instance = this;
}
return FancyLogger.instance;
}
@gain620
gain620 / commandPattern.js
Last active March 12, 2021 06:49
command pattern
class Calculator {
constructor() {
this.value = 0;
this.historyStack = [];
}
executeCommand(command) {
this.value = command.execute(this.value);
this.historyStack.push(command);
}
@gain620
gain620 / gist:ac94f65068a42aec4557ab820805806d
Created April 21, 2019 13:34 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@gain620
gain620 / closure_retain_cycle.swift
Created April 21, 2019 10:32
closure_retain_cycle test
class HTMLElement {
let name: String
let text: String
lazy var asHTML: () -> String = { [weak self] in
guard let this = self else {return ""}
return "\(this.name)\(this.text)/\(this.name)"
}
init(name: String, text: String) {
@gain620
gain620 / pod_init.sh
Created April 16, 2019 16:03
Clean and easy pod update & install script for xcode behavior
#!/bin/bash
# move project dir
PROJECT_HOME=`pwd`
echo "cd $PROJECT_HOME" > /tmp/tmp.sh
# search .xcodeproj file and strip filename
PROJECT_NAME=""
for f in *.xcodeproj; do
PROJECT_NAME="${f%.*}"
@gain620
gain620 / pod_update.sh
Last active April 16, 2019 16:03
Clean and easy pod update & install script for xcode behavior
#!/bin/bash
# move project dir
PROJECT_HOME=`pwd`
echo "cd $PROJECT_HOME" > /tmp/tmp.sh
# pod init & update
echo "pod update" >> /tmp/tmp.sh
chmod +x /tmp/tmp.sh
@gain620
gain620 / open_terminal.sh
Created April 16, 2019 15:57
Easy terminal opening script for xcode behavior
#!/bin/bash
open -a Terminal `pwd`
@gain620
gain620 / debug_logger.swift
Created April 9, 2019 19:43
my simple swift debug logger :)
func DEBUG_LOG(_ msg: Any, file: String = #file, function: String = #function, line: Int = #line) {
#if DEBUG
let fileName = file.split(separator: "/").last ?? ""
let funcName = function.split(separator: "(").first ?? ""
print("❀️[\(fileName)] \(funcName)(\(line)): \(msg)")
#endif
}