Skip to content

Instantly share code, notes, and snippets.

View RNHTTR's full-sized avatar

Ryan Hatter RNHTTR

  • Astronomer
View GitHub Profile
@RNHTTR
RNHTTR / yaml_string_to_dictionary.py
Last active November 12, 2019 17:07
Simple recursive function to convert a yaml literal block string ("|-") to yaml-valid python dictionary
def dictionarize(s, d={}, key=None):
"""
Simple recursive function to convert a yaml literal block string ("|-") to yaml-valid python dictionary
Args:
s, str: yaml-valid input string
d, dict: output dictionary
key, str: key in the dictionary at which to add nested values
Returns:
@RNHTTR
RNHTTR / AzureUploadLargeBlob.sh
Last active February 23, 2024 19:35
A simple shell script using cURL and the Azure REST API to upload large files (> 100MB) to Azure Storage
#!/bin/bash
echo "\nEnter your storage account name:"
read AZ_ACCOUNT_NAME
echo "\nEnter your container name:"
read AZ_BLOB_CONTAINER
echo "\nEnter your SAS token (just hit ENTER/RETURN if not applicable):"
read AZ_SAS_TOKEN
DATE_NOW=$(date -Ru | sed 's/\+0000/GMT/')
@RNHTTR
RNHTTR / SwiftyFonts.txt
Created September 28, 2017 12:30
About Swifty Fonts in Swifty Docs!
Swifty Fonts allows iOS developers (i.e. you) to view all fonts that are
natively available in Swift. You can see each font against various
background colors to see if a particular font is available by default in
Swift and to see if it is a font that you would like to employ in your
app(s).
Instead of Swifty Fonts being a standalone app, it is now a part of Swifty
Docs to allow Swift coders (especially noobs) to have access to more tools,
including notes on how to get started developing augmented reality
applications.
@RNHTTR
RNHTTR / UITableView.txt
Last active September 28, 2017 00:39
Learn about how UITableViews are used in Swifty Docs
UITableView is a fundamental tool within the UIKit framework that all Swift
developers should be familiar with. Table views are all over iOS apps,
including several apps that shipped natively on your iPhone. Your inbox on
the Mail app makes use of a UITableView. The Settings app is riddled with
UITableViews. The Notes, Contacts, and Reminders apps all use UITableViews,
too. I think you get it - table views are all over the place!
Check out the table views in this app and see how they were created by the
"About" button in the top-right corner of each view controller.
@RNHTTR
RNHTTR / AR.txt
Last active September 28, 2017 00:36
About augmented reality in Swifty Docs
Augmented reality is a game changer. From gaming and entertainment to
navigation to medical training and beyond, AR will change the way we
interact with the world. Whether it’s on our smartphones or some kind of
smart glasses is yet to be determined, but some of the world’s biggest
companies (Apple and Google, for example) are investing heavily in the
technology. The world will need talented developers (like you, obviously) to
move the industry forward.
It’s surprisingly easy to get started building AR applications using ARKit
(Apple’s framework for creating augmented reality experiences), and very
@RNHTTR
RNHTTR / cellForRowAt.swift
Created September 25, 2017 02:53
Customize the cells in a UITableView
// Use tableView(_:cellForRowAt:) to customize the cells in a table view.
// This example demonstrates an instance of how one of this app's table views uses this method.
// Create some sort of data source. This is often an array or, in this case, a dictionary.
var dataSource: [String: String] {
return ["cellForRowAt: indexPath": "Update cell information based on the data source\nReturns a UITableViewCell.",
"numberOfRowsInSection: Int": "Determine the number of rows needed for each section of the tableView\nReturns an Int",
"titleForHeaderInSection: Int": "Set the title for a particular section of your tableView\nReturns a String"]
}
@RNHTTR
RNHTTR / titleForHeaderInSection.swift
Created September 25, 2017 02:44
Determine the title for each section in a UITableView.
// Use tableView(_:titleForHeaderInSection:) to set the title for each section in a table view.
// This example exhibits two instances of this method used in this app.
// This demonstrates the use of this method in this app's UITableViewDataSource view controller.
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch section {
case 0:
return "Configuring a Table View"
default:
print("out of index")
@RNHTTR
RNHTTR / numberOfRowsInSection.swift
Created September 25, 2017 02:30
Determine the number of rows in each of a UITableView's sections
// Use tableView(_:numberOfRowsInSection:) to determine the number of rows each section of a UITableView should display.
// This example exhibits how this app makes use of this method.
// Create some sort of data source. This is often an array or, in this case, a dictionary.
var dataSource: [String: String] {
return ["cellForRowAt: indexPath": "Update cell information based on the data source\nReturns a UITableViewCell.",
"numberOfRowsInSection: Int": "Determine the number of rows needed for each section of the tableView\nReturns an Int",
"titleForHeaderInSection: Int": "Set the title for a particular section of your tableView\nReturns a String"]
}
@RNHTTR
RNHTTR / editActionsForRowAt.swift
Created September 23, 2017 20:14
Use tableView(_:editActionsForRowAt:) to implement swipe actions for a UITableView's cells.
// Use tableView(_:editActionsForRowAt:) to implement swipe actions for a UITableView's cells.
// This example exhibits how this app makes use of this method.
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
// Get the title of each section to notify the user that a cell in a particular section was swiped.
let sectionHeaderView = tableView.headerView(forSection: indexPath.section)
let sectionTitle = sectionHeaderView?.textLabel?.text
// Create an action. Create custom actions in the UITableViewRowAction's closure.
@RNHTTR
RNHTTR / didSelectRowAtIndexPath.swift
Created September 23, 2017 20:01
An example of how to use tableView(_:didSelectRowAt:) to manage what happens when users select a UITableViewCell
// Use tableView(_:didSelectRowAt:) to manage what happens when a user selects a UITableViewCell.
// This example exhibits how this app makes use of this method.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Determine what to do when a cell in a particular section is selected.
switch indexPath.section {
case 0:
// If the cell in the first section is selected, this will trigger the segue with the "toHeightForRowAt" identifier
self.performSegue(withIdentifier: "toHeightForRowAt", sender: nil)