Skip to content

Instantly share code, notes, and snippets.

View spencerfeng's full-sized avatar

Spencer Feng spencerfeng

  • Sydney, Australia
View GitHub Profile
@spencerfeng
spencerfeng / .eslintrc.js
Created January 19, 2022 11:43 — forked from JirkaVebr/.eslintrc.js
Prettier with TypeScript
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
plugins: [
"react-hooks",
],
@spencerfeng
spencerfeng / rounded_uiimage.swift
Created January 28, 2021 10:46 — forked from brownsoo/rounded_uiimage.swift
Cut UIImage with rounded rectangle or circle
public extension UIImage {
func round(_ radius: CGFloat) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let renderer = UIGraphicsImageRenderer(size: rect.size)
let result = renderer.image { c in
let rounded = UIBezierPath(roundedRect: rect, cornerRadius: radius)
rounded.addClip()
if let cgImage = self.cgImage {
UIImage(cgImage: cgImage, scale: self.scale, orientation: self.imageOrientation).draw(in: rect)
}