Skip to content

Instantly share code, notes, and snippets.

View KrisYu's full-sized avatar

Xue Yu KrisYu

View GitHub Profile
@KrisYu
KrisYu / Eigen Cheat sheet
Created September 25, 2020 15:25 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@KrisYu
KrisYu / UIImage+PixelColor.swift
Created September 29, 2017 01:49 — forked from marchinram/UIImage+PixelColor.swift
iOS Swift UIImage subscript extension to get pixel color
import UIKit
extension UIImage {
subscript (x: Int, y: Int) -> UIColor? {
if x < 0 || x > Int(size.width) || y < 0 || y > Int(size.height) {
return nil
}
@KrisYu
KrisYu / observer.swift
Created March 13, 2017 20:43 — forked from starhoshi/observer.swift
Swift observer pattern.
import Foundation
protocol Observer {
var id: String { get }
func update(_ string: String)
}
extension Observer {
func update(_ string: String) {
print("\(type(of: self)) に届いた新しい値は \(string) です。")
@KrisYu
KrisYu / observer.swift
Created March 13, 2017 20:43 — forked from starhoshi/observer.swift
Swift observer pattern.
import Foundation
protocol Observer {
var id: String { get }
func update(_ string: String)
}
extension Observer {
func update(_ string: String) {
print("\(type(of: self)) に届いた新しい値は \(string) です。")
@KrisYu
KrisYu / RW.swift
Created February 14, 2017 00:09 — forked from mchirico/RW.swift
RW to file in swift
//
// RW.swift
// Web
//
// Created by Mike Chirico on 10/15/15.
// Copyright © 2015 Mike Chirico. All rights reserved.
//
import UIKit