Skip to content

Instantly share code, notes, and snippets.

leogdion leogdion

Block or report user

Report or block leogdion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View split_swift.sh
awk '
/^(class|protocol|extension|struct|enum) ([a-zA-Z]+)/ {close(file); ++count; file=$2"."$1".swift"; print file; close file;}
file {print line > file}
{line=$0}
' RssReader.swift
View resume.md
@leogdion
leogdion / .gitignore
Last active Jul 20, 2019
An example of turning podcast clip into a video clip for empowerapps.show
View .gitignore
# Created by https://www.gitignore.io/api/macos
# Edit at https://www.gitignore.io/?templates=macos
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
View medium.codable-4-ways-improve-decode-json.01.tweet.swift
public struct Tweet : Codable {
public let created_at : Date
public let id : Int
public let full_text : String
public let display_text_range : [Int]
public let entities : TweetEntities
public let source : String
public let in_reply_to_status_id : Int?
public let in_reply_to_user_id : Int?
public let in_reply_to_screen_name : String
@leogdion
leogdion / fix_dylibs.sh
Last active Jan 15, 2019
Fixing Dynamic Library References in Xcode Projects https://learningswift.brightdigit.com/?p=195
View fix_dylibs.sh
#!/bin/sh
FRAMEWORKS_FOLDER_PATH="`dirname $1`/Frameworks/"
LIBS=`otool -L "$1" | grep "/opt\|Cellar" | awk -F' ' '{ print $1 }'`
for lib in $LIBS; do
EXPECTED_PATH="`dirname $1`/Frameworks/`basename $lib`"
if [ ! -f $EXPECTED_PATH ]; then
IFS='.' read -ra FILENAME_COMPS <<< "`basename $lib`"
ACTUAL_PATH=`find $FRAMEWORKS_FOLDER_PATH -name "${FILENAME_COMPS[0]}*.*"`
install_name_tool -id @rpath/`basename $ACTUAL_PATH` "`dirname $1`/Frameworks/`basename $ACTUAL_PATH`"
@leogdion
leogdion / Mail-Merge-Template.scpt
Created Jan 2, 2019
Creating A Mailchimp Subscription Form and Email Invite using AppleScript
View Mail-Merge-Template.scpt
set mol_list to {}
-- This will ask you to select a file containing the intended recepients and their emails --
-- I also include in this file information needed to link to an attachment --
set theFile to choose file with prompt "Select a text file:"
set theFileReference to open for access theFile
-- Note that the line end here is an old Mac return (not MSFT carriage return) --
set theFileContents to read theFileReference using delimiter linefeed
close access theFileReference
-- Now parse the file that was selected. Here I'm parsing a tab-delimited file. --
View querying-changes-watchOS4.swift
func startWorkoutWithHealthStore(_ healthStore: HKHealthStore,
andActivityType activityType: HKWorkoutActivityType,
withSampleTypes sampleTypes: [HKSampleType]) -> HKWorkoutSession {
let configuration = HKWorkoutConfiguration()
configuration.activityType = activityType
let session : HKWorkoutSession
do {
session = try HKWorkoutSession(configuration: configuration)
} catch let error {
@leogdion
leogdion / HealthKit.AppleWatch.iPhone.swift
Last active Jun 11, 2018
Handle AppleWatch Request For Authorization on iPhone
View HealthKit.AppleWatch.iPhone.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
...
func applicationShouldRequestHealthAuthorization(_ application: UIApplication) {
let healthStore = HKHealthStore()
healthStore.handleAuthorizationForExtension {
(success, error) -> Void in
}
}
@leogdion
leogdion / HKHealthStore.Authorization.Example.swift
Last active Jun 11, 2018
HealthKit – Apple Watch – Data and Authorization
View HKHealthStore.Authorization.Example.swift
if HKHealthStore.isHealthDataAvailable() {
let healthStore = HKHealthStore()
let heartRateQuantityType = HKObjectType.quantityType(forIdentifier: .heartRate)!
let allTypes = Set([HKObjectType.workoutType(), heartRateQuantityType ])
healthStore.requestAuthorization(toShare: nil, read: allTypes) { (result, error) in
if let error = error {
// deal with the error return
}
guard result else {
// deal with the failed request return
@leogdion
leogdion / ShufflingPlayingCards-Swift4.2.swift
Created Jun 5, 2018
How to create playing cards and shuffling them in Swift 4.2
View ShufflingPlayingCards-Swift4.2.swift
// CaseIterable gives us the allCases properties
enum Suit : CaseIterable {
case clubs, hearts, diamonds, spades
}
// CaseIterable gives us the allCases properties
enum Rank : CaseIterable {
case two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace
}
You can’t perform that action at this time.