Skip to content

Instantly share code, notes, and snippets.

View haijianliu's full-sized avatar

haijianliu haijianliu

View GitHub Profile
@swillits
swillits / Keycodes.swift
Last active March 26, 2024 23:20
Swift Keyboard Keycodes
struct Keycode {
// Layout-independent Keys
// eg.These key codes are always the same key on all layouts.
static let returnKey : UInt16 = 0x24
static let enter : UInt16 = 0x4C
static let tab : UInt16 = 0x30
static let space : UInt16 = 0x31
static let delete : UInt16 = 0x33
static let escape : UInt16 = 0x35
@mbehan
mbehan / ForcePanGestureRecognizer.swift
Created November 11, 2016 23:11
A UIPanGestureRecognizer subclass to get the force of the gesture's touch (assumes a single touch)
import UIKit.UIGestureRecognizerSubclass
class ForcePanGestureRecognizer : UIPanGestureRecognizer {
private(set) var force = CGFloat(0) {
didSet {
if force > maxForce {
maxForce = force
}
}
@unitycoder
unitycoder / if-branchless.shader
Last active April 3, 2024 11:20
Avoiding Branching / Conditionals in Shaders Fast No If
"The common wisdom of "don't use conditionals in shaders" is one of my biggest frustrations with how shaders are taught.
step(y, x) _is_ a conditional! It compiles to identical code as:
float val = (x >= y ? 1.0 : 0.0)
or
float val = 0.0;
if (x >= y) val = 1.0;"
https://twitter.com/bgolus/status/1235254923819802626
// Performing shader divisions without diving *rcp = approximation of 1/x
float myDividedVal = myValToDivide * rcp(myDivider);
@rxaviers
rxaviers / gist:7360908
Last active May 6, 2024 03:49
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: