Skip to content

Instantly share code, notes, and snippets.

View AmatsuZero's full-sized avatar
💭
I may be slow to respond.

Daubert Jiang AmatsuZero

💭
I may be slow to respond.
  • Tencent
  • Beijing, China
View GitHub Profile
extension UIImage {
func upFixedImage() -> UIImage? {
// No-op if the orientation is already correct
guard imageOrientation != .up else {
return nil
}
var transform = CGAffineTransform.identity
switch imageOrientation {
case .down, .downMirrored:
hdiutil create -o /tmp/HighSierra.cdr -size 5200m -layout SPUD -fs HFS+J
hdiutil create -o /tmp/HighSierra.cdr -size 5200m -layout SPUD -fs HFS+J
sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build
mv /tmp/HighSierra.cdr.dmg ~/Desktop/InstallSystem.dmg
hdiutil detach /Volumes/Install\ macOS\ High\ Sierra
hdiutil convert ~/Desktop/InstallSystem.dmg -format UDTO -o ~/Desktop/HighSierra.iso
@AmatsuZero
AmatsuZero / UICollectionViewLeftAlignedLayout.swift
Created June 18, 2019 09:30
UICollectionView 固定行距列表左排: 来一个自定制 Layout
// based on http://stackoverflow.com/questions/13017257/how-do-you-determine-spacing-between-cells-in-uicollectionview-flowlayout https://github.com/mokagio/UICollectionViewLeftAlignedLayout
import UIKit
extension UICollectionViewLayoutAttributes {
func leftAlignFrame(with sectionInset:UIEdgeInsets){
var tempFrame = frame
tempFrame.origin.x = sectionInset.left
frame = tempFrame
}
}
@AmatsuZero
AmatsuZero / RandomWaterfallLayout.swift
Last active April 30, 2020 03:32
iOS不规则瀑布流
import UIKit
public protocol RandomWaterfallLayoutDelegate: class {
/// 列数
func columnCount(_ layout: RandomWaterfallLayout) -> CGFloat
/// 列间距
func columnMargin(_ layout: RandomWaterfallLayout) -> CGFloat
/// 行间距
func rowMargin(_ layout: RandomWaterfallLayout) -> CGFloat
/// CollectionView 边距
import Foundation
enum RandomSource {
static let file = fopen("/dev/urandom", "r")!
static let queue = DispatchQueue(label: "random")
static func get(count: Int) -> [Int8] {
let capacity = count + 1 // fgets adds null termination
var data = UnsafeMutablePointer<Int8>.allocate(capacity: capacity)
defer {
@AmatsuZero
AmatsuZero / linkmap.js
Created January 15, 2021 08:10 — forked from bang590/linkmap.js
XCode Linkmap Parser
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {