Skip to content

Instantly share code, notes, and snippets.

View astericky's full-sized avatar

Chris Sanders astericky

View GitHub Profile
@astericky
astericky / Date.swift
Created October 7, 2020 19:44 — forked from alexpaul/Date.swift
Using Date in Swift, using ISO8601DateFormatter() and DateFormatter()
// Date extension
extension Date {
static func getStringFromDate(date: Date) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "EEEE, MMM d, yyyy"
let dateString = dateFormatter.string(from: date)
return dateString
}
static func getDateFromString(dateString: String) -> Date? {
let formatter = ISO8601DateFormatter()
@astericky
astericky / SwiftUI+HexColors.swift
Last active June 22, 2019 20:36 — forked from aChase55/SwiftUI+HexColors.swift
SwiftUI Hex Colors
//Trying out a prefix operator
//I thought vertical elipses made sense, representative of rbg
prefix operator ⋮
prefix func ⋮(hex:UInt32) -> Color {
return Color(hex)
}
extension Color {
init(_ hex: UInt32, opacity:Double = 1.0) {
let red = Double((hex & 0xff0000) >> 16) / 255.0
@astericky
astericky / SwiftUICollectionChanges.md
Created June 12, 2019 16:23 — forked from epatey/SwiftUICollectionChanges.md
Refreshing SwiftUI on changes within objects in a collection.

Refreshing SwiftUI on changes within objects in a collection.

How to approach updating UI for changes within objects held within a collection? After experimenting a bit, I think there are basically two approaches.

  1. The conformance to BindableObject by the object that contains the collection needs to be deep and not shallow. It needs to fire didChange if the collection, or anything recursively within the collection, changes. In my example from yesterday, this means that MainViewModel would need to figure out how to fire didChange if anything within any of its existing rows changes - not just changes to the collection itself. or
  2. The parent/container can have shallow conformance to BindableObject if the row model themselves conform to BindableObject and the row view declares the dependency with @ObjectBinding.

You must do one or the other if you want a row to refresh when isTyping changes value. I suspect that in the general case, #2 will be simpler.

@astericky
astericky / examples.md
Created May 29, 2019 00:00 — forked from ErisDS/examples.md
Ghost Filter Query examples

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>openweathermap.org</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
# Run this from the parent directory
FROM golang:1.9-alpine as build_container
ENV APP_NAME my-app
ENV TARGET_DIR /go/src/github.com/MediaMath/${APP_NAME}
COPY . ${TARGET_DIR}
WORKDIR ${TARGET_DIR}
@astericky
astericky / curl.md
Created February 7, 2018 23:22 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@astericky
astericky / .babelrc
Created March 3, 2017 15:28
Babel Config
{
"presets": ["latest"],
"plugins": ["transform-object-rest-spread", "babel-plugin-transform-react-jsx"]
}