Skip to content

Instantly share code, notes, and snippets.

View xiaoxidong's full-sized avatar
🎯
Focusing

XiaoDong xiaoxidong

🎯
Focusing
View GitHub Profile
@lexrus
lexrus / HD.txt
Last active July 20, 2023 08:11
All WWDC 2013 Session Videos URLs in https://developer.apple.com/wwdc/videos/ dumped with Chrome. You can download these videos **without** a Apple developer account by running the download.sh script. There is also a sample code downloader here: https://github.com/jfahrenkrug/WWDC-Downloader
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1
@unnamedd
unnamedd / ReplaceChar.swift
Created August 22, 2016 06:41
NSTextAttachment
// MARK: - String Extension
private extension String {
/**
replace characters from the original text to some image
- parameter character: the character that will be used to be replaced by image
- parameter image: image name that will replace the character
*/
func replace(char character: String, image: String) -> NSAttributedString {
@ethanhuang13
ethanhuang13 / HexColor.swift
Created January 2, 2019 06:44
@dynamicMemberLookup example
// An (useless) example of Swift 4.2 @dynamicMemberLookup attributes.
// let color1 = HexColor().cbcbcb
// let color2 = HexColor().000000 // This can also be built. Will be treat as "000000"
import Foundation
@dynamicMemberLookup
struct HexColor {
subscript(dynamicMember member: String) -> UIColor? {
do {
@timothycosta
timothycosta / UIViewController+SwiftUI.swift
Last active November 9, 2024 23:09
Using UIViewController via the SwiftUI Environment
struct ViewControllerHolder {
weak var value: UIViewController?
init(_ value: UIViewController?) {
self.value = value
}
}
struct ViewControllerKey: EnvironmentKey {
static var defaultValue: ViewControllerHolder { return ViewControllerHolder(UIApplication.shared.windows.first?.rootViewController ) }
@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 26, 2024 17:49
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
@SatoTakeshiX
SatoTakeshiX / convert.swift
Last active June 6, 2024 12:25
Take capture a view by SwiftUI
//
// ContentView.swift
// TryGeometryReader
//
// Created by satoutakeshi on 2019/12/07.
// Copyright © 2019 satoutakeshi. Licensed under MIT.
//
import SwiftUI
@jmcd
jmcd / MacOSDrawPNG.swift
Created January 24, 2020 08:45
Drawing to a PNG
func makePNG(_ size: NSSize, by drawing: (CGContext) -> ()) -> Data? {
guard let bitmapImageRep = NSBitmapImageRep(bitmapDataPlanes: nil,
pixelsWide: Int(size.width),
pixelsHigh: Int(size.height),
bitsPerSample: 8,
samplesPerPixel: 4,
hasAlpha: true,
isPlanar: false,
colorSpaceName: NSColorSpaceName.deviceRGB,
bytesPerRow: 0, bitsPerPixel: 0) else {
@jmcd
jmcd / Dnd.swift
Created February 14, 2020 18:21
Checking out drag n' drop in Swift UI
import SwiftUI
struct AnimalView: View {
var model: Animal
var body: some View {
VStack {
Image(systemName: model.systemImageName)
.resizable()
.scaledToFit()
import SwiftUI
struct ContentView: View {
@State var gradient = [
Color.red, .orange, .yellow, .green, .blue, .purple, Color.red, .orange, .yellow, .green, .blue, .purple,
]
@State var startPoint = UnitPoint(x: 0, y: -1)
@State var endPoint = UnitPoint(x: 0, y: 1)
@unnamedd
unnamedd / PreviewDevice+ListOfPads.swift
Created April 25, 2020 18:19
A small extension for PreviewDevice to avoid enter the values in the SwiftUI previews manually
/**
* PreviewDevice+ListOfPads.swift
* Copyright (c) Thiago Holanda 2020
* https://twitter.com/tholanda
*
* MIT license
*/
import SwiftUI