Skip to content

Instantly share code, notes, and snippets.

View acalism's full-sized avatar
🏠
Working from home

Dawn Song acalism

🏠
Working from home
  • Tencent, Alibaba
  • Shenzhen City, Guangdong Province, China
View GitHub Profile
@DaveWoodCom
DaveWoodCom / set_swift_version.post_install.ruby
Created October 4, 2017 05:18
`post_install` hook to set the Swift version of pods (add to the end of your project's podfile)
post_install do |installer|
print "Setting the default SWIFT_VERSION to 4.0\n"
installer.pods_project.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
installer.pods_project.targets.each do |target|
if ['SomeTarget-iOS', 'SomeTarget-watchOS'].include? "#{target}"
print "Setting #{target}'s SWIFT_VERSION to 3.0\n"
target.build_configurations.each do |config|
@skabber
skabber / exportOptions.plist
Last active April 14, 2024 20:47
Export Options Plist Example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>uploadBitcode</key>
<true/>
@lattner
lattner / TaskConcurrencyManifesto.md
Last active April 25, 2024 18:22
Swift Concurrency Manifesto
@JScott
JScott / unxip.scpt
Created September 16, 2016 16:41
For unarchiving Apple's bad decisions
-- http://stackoverflow.com/questions/37812664/end-of-central-directory-signature-not-found-when-installing-xcode-8-beta-xip/37857162#37857162
on run argv
tell application "Archive Utility" to open POSIX path of (item 1 of argv)
repeat
delay 5
if application "Archive Utility" is not running then exit repeat
end repeat
end run
@MatiMax
MatiMax / DNSResolve.swift
Last active November 14, 2016 05:48
This Swift Playground shows how to use Core Foundation's CFHost in Swift 2 to try to produce an array of Strings containing the host name and all its aliases for a given IP address. Unfortunately, CFHostGetNames() does not supply the aliases of a host, so we're left alone with the gethostbyaddr() C function.
//: # How to retrieve a host name and associated aliases from an IP address using Core Fondation's `CFHost`
import Cocoa
import XCPlayground
//: In order to get the callback working we use a simple class to implement the showcase.
class DNSResolve {
//: The IP address may be a Swift `String` thanks to the toll-free bridging to C strings.
let ip: String = "17.172.224.47"
//: We use an optional `CFHost` variable because CFHost neither comes with an initializer nor is conforming to the Nullable protocol.
var host: CFHost?
//: We use this array of `String`s to store the resolved host names.
@akisute
akisute / iPad Air 2
Last active November 16, 2018 02:46
Handling Size Class, UITraitEnvironment, UIContentContainer on iOS 9 (beta 1)
////////////////
// on iPad Air 2
////////////////
// Boot as portrait
2015-06-15 19:57:47.597 ios9[16003:229076] viewDidLoad()
2015-06-15 19:57:47.598 ios9[16003:229076] viewWillAppear - false
2015-06-15 19:57:47.601 ios9[16003:229076] traitCollectionDidChange - nil
2015-06-15 19:57:47.602 ios9[16003:229076] viewWillLayoutSubviews()
2015-06-15 19:57:47.602 ios9[16003:229076] viewDidLayoutSubviews()
@rarylson
rarylson / automator_new_file.scpt
Last active March 1, 2024 01:03
AppleScript to create a new file in Finder (to be used in Automator)
-- AppleScript to create a new file in Finder
--
-- Use it in Automator, with the following configuration:
-- - Service receives: no input
-- - In: Finder.app
--
-- References:
-- - http://apple.stackexchange.com/a/129702
-- - http://stackoverflow.com/a/6125252/2530295
-- - http://www.russellbeattie.com/blog/fun-with-the-os-x-finder-and-applescript
@JadenGeller
JadenGeller / Unsafe Bit Cast.swift
Last active January 26, 2023 22:09
A Quick Overview of Unsafe Bit Cast
// Let's declare two structs that with different variables and different boolean values:
struct A {
let x = true
}
struct B {
let y = false
}
@martinnormark
martinnormark / updateConstraints.swift
Last active September 23, 2020 08:56
Example of updateConstraints using PureLayout
private var didUpdateConstraints: Bool = false
override func updateConstraints() {
if (!didUpdateConstraints) {
self.buildStatusIndicatorView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero, excludingEdge: ALEdge.Trailing)
self.buildStatusIndicatorView.autoSetDimension(ALDimension.Width, toSize: 10)
self.buildNumberLabel.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsets(top: 5, left: 15, bottom: 5, right: 5), excludingEdge: ALEdge.Bottom)
self.buildNumberLabel.autoSetDimension(ALDimension.Height, toSize: 23)
@benschw
benschw / git-origins.md
Last active September 20, 2023 08:54
fork a repo manually (set source as upstream origin) rather than with the "fork" button. e.g. for in github when you want to fork a project twice.

Ripped off from adrianshort.org

List curent remotes

$ git remote -v

origin  https://github.com/hakimel/reveal.js.git (fetch)
origin  https://github.com/hakimel/reveal.js.git (push)

Rename origin to upstream and add our new empty repo as the origin.