Skip to content

Instantly share code, notes, and snippets.

View topherPedersen's full-sized avatar
💭
Rolling my katamari ball

Christopher Pedersen topherPedersen

💭
Rolling my katamari ball
View GitHub Profile
@topherPedersen
topherPedersen / learn_python_in_20_minutes.py
Last active March 21, 2019 19:29
Learn Python in 20 Minutes
# Concept No. 1: Functions
print("Print is a function.")
print("Functions are commands that instruct the computer to do things.")
print("Although, sometimes they are used to return values as well.")
# Concept No. 2: Variables
my_variable = "Variables are simply containers which hold values."\
# Concept No. 3: Lists
my_list = []
@topherPedersen
topherPedersen / timestamp.swift
Created November 7, 2018 18:52
Unix Timestamps in Swift
import Foundation
var timestamp: Int = Int(NSDate().timeIntervalSince1970)
var timestampPrecise: Double = NSDate().timeIntervalSince1970
print("Timestamp Cast as Integer (not precise): " + String(timestamp))
print("Timestamp left as Double (precise): " + String(timestampPrecise))
@topherPedersen
topherPedersen / wcsession_example.swift
Last active November 8, 2018 03:03
Code Snippet from Page 32 of "Swift Development for the Apple Watch" (modified to accommodate breaking changes in swift/iOS since book was published)
//
// InterfaceController.swift
// Yo WatchKit Extension
//
// Created by Christopher Pedersen on 11/7/18.
// Copyright © 2018 Christopher Pedersen. All rights reserved.
//
import WatchKit
import Foundation
@topherPedersen
topherPedersen / todo.html
Created November 8, 2018 23:06
Vanilla JavaScript Todo App
<!DOCTYPE html>
<html>
<head>
<title>This is Jack's Wish List</title>
</head>
<body>
<h1>Jack's List</h1>
@topherPedersen
topherPedersen / watchConnectivityDemo.swift
Last active November 12, 2018 20:17
WatchConnectivity Demo
// Source Code by Nick Hanan @ codingexplorer.com
// https://www.codingexplorer.com/watch-connectivity-swift-application-context/
// Additional Code from Stack Overflow User 'Gati'
// https://stackoverflow.com/questions/48131924/watchkit-extension-interfacecontroller-does-not-implement-delegate-method
//
// ViewController.swift
// Yo3
@topherPedersen
topherPedersen / watchPingPhone.swift
Created November 13, 2018 02:17
WatchConnectivity Demo (Send Message from Watch to iPhone)
//
// ViewController.swift
// WatchPingPhone
//
// Created by Christopher Pedersen on 11/12/18.
// Copyright © 2018 Christopher Pedersen. All rights reserved.
//
import Foundation
import UIKit
@topherPedersen
topherPedersen / makeHttpPostRequest.swift
Created November 19, 2018 00:48
Making HTTP POST Requests with Form Data in Swift on iOS
// Example code demonstrating how to make a simple http post request with form data in swift on iOS.
// Swift source code from the blog NewFiveFour.com (https://newfivefour.com/swift-ios-formurlencoded-post.html)
// XML work around for using HTTP instead of HTTPS from the public domain
// NOTE: You must include the work around if you would like to use HTTP instead of HTTPS
//
// ViewController.swift
// PostMaphone2
//
// Created by Christopher Pedersen on 11/18/18.
@topherPedersen
topherPedersen / project_links.txt
Created November 30, 2018 01:22
Project Links for my Students
@topherPedersen
topherPedersen / AppDelegate.swift
Created December 5, 2018 07:59 — forked from phatblat/AppDelegate.swift
Example of creating HKObserverQuery and enabling background delivery for multiple HKObjectType
@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
let healthKitManager = HealthKitManager()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if onboardingComplete {
healthKitManager.requestAccessWithCompletion() { success, error in
if success { print("HealthKit access granted") }
else { print("Error requesting access to HealthKit: \(error)") }
}
@topherPedersen
topherPedersen / cookieclicker.html
Last active December 8, 2018 20:51
CookieClicker-- a Basic HTML & JavaScript Example by Grace (a Rockstar Coding Student at theCoderSchool)
<!DOCTYPE html>
<html>
<!--CookieClicker by Grace (a Rockstar Coding Student at theCoderSchool) Copyleft 2018, All Rights Reversed -->
<body>
<p id="cookieNumber">Cookies: 0</p>
<button onclick="makeCookie()">Make Cookie</button>
<script>
var cookies = 0;