Skip to content

Instantly share code, notes, and snippets.

View muizidn's full-sized avatar
👨‍🚀
Working between Tiangong and Mir

Former Not Wannabe Lord Paramount of the Wkwkland muizidn

👨‍🚀
Working between Tiangong and Mir
  • Indian Ocean
View GitHub Profile
@muizidn
muizidn / README.md
Last active June 13, 2023 07:21
Convert h2 and h3 heading into table of content convertible structure in WIX

Use convertToToc.js to parse blog post to toc then generate toc html file with table_of_content_template.html.

What must be changed?

H2 Heading

id, innerText

H3 Heading

@muizidn
muizidn / DOWNLOAD_ARIA2.rb
Created October 12, 2021 09:43
Download Helper Using Ruby
#!/usr/bin/env ruby
print "What is the URL of your Downloads resource?\nURL:"
url = gets.strip
command = "aria2c -x 16 -s 16 #{url} -d ~/Downloads"
exec(command)
@muizidn
muizidn / SectionedArrayFiltering.swift
Last active June 23, 2021 08:32
Performs filter on a sectioned array
struct SectionedArrayFiltering<T> {
struct Result {
let filteredSection: [Int]
let filteredItemsBySection: [Int:[T]]
}
let input: [[T]]
func filter(
sectionFilter: (Int) -> Bool = {_ in true},
@muizidn
muizidn / PagingEasy-README.md
Last active April 2, 2021 01:17
Paging Easy Swift

Paging Easy

  • Store nextPage and total
  • Only fetch in the last cell if dataSource.count < paging.total
  • Only assign nextPage if resp.data is not empty
@muizidn
muizidn / SwiftUI-SymbolTable.swift
Created January 30, 2020 04:30 — forked from Cosmo/SwiftUI-SymbolTable.swift
Name List / Symbol Table of SwiftUI
(extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.getter : EmptyAnimatableData
(extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.modify : EmptyAnimatableData
(extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.setter : EmptyAnimatableData
(extension in :Animatable< where A: VectorArithmetic>.animatableData.getter : A
(extension in :Animatable< where A: VectorArithmetic>.animatableData.modify : A
(extension in :Animatable< where A: VectorArithmetic>.animatableData.setter : A
(extension in :Button< where A == PrimitiveButtonStyleConfiguration.Label>.init(PrimitiveButtonStyleConfiguration) -> Button<PrimitiveButtonStyleConfiguration.Label>
(extension in :Button< where A == Text>.init(_: LocalizedStringKey, action: () -> ()) -> Button<Text>
(extension in :Button< where A == Text>.init<A where A1: StringProtocol>(_: A1, action: () -> ()) -> Button<Text>
(extension in :CoreGraphics.CGFloat.magnitudeSqu
@muizidn
muizidn / canvas-core-graphics-api.js
Last active September 19, 2019 22:59
HTML5 Canvas using Core Graphics API
export class CGContext {
constructor(document, id) {
const c = document.getElementById(id)
this.ctx = c.getContext("2d")
}
move(cgPoint) {
console.log("I am ${cgPoint}")
}
}
@muizidn
muizidn / DataCodable.swift
Created September 2, 2019 06:04
Encode and Decode to Data object in Swift 5.0
protocol DataCodable {
func toData() -> Data
init(data: Data)
}
extension Data: DataCodable {
func toData() -> Data {
return self
}
init(data: Data) {

Convert SVG file to UIBezierPath

Currently we do these steps manually but we are moving to automate it.

Browser

  1. Open Svgson
  2. Open Regexr
  3. Open Swiftsvg

Svgson

@muizidn
muizidn / CanvasRenderingContext2D.swift
Created August 21, 2019 06:21
Canvas API using CoreGraphics
import UIKit
final class CanvasRenderingContext2D {
private let ctx: CGContext
private let bounds: CGRect
init?(fitIn bounds: CGRect = .zero) {
guard let ctx = UIGraphicsGetCurrentContext() else { return nil }
self.ctx = ctx
self.bounds = bounds
@muizidn
muizidn / FontLoader.swift
Last active December 21, 2023 09:59
Using custom font in iOS without register to Info.plist
public class FontLoader {
private enum Error: Swift.Error {
case error(String)
}
/// Register fonts
///
/// - Parameter fonts: Font names
static func registerFonts(fonts: [String]) throws {
let bundle = Bundle(for: FontLoader.self)