Skip to content

Instantly share code, notes, and snippets.

View zackshapiro's full-sized avatar

Zack Shapiro zackshapiro

View GitHub Profile
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
// This gist explains how to setup scalable Parse LiveQuery server on Heroku
// Because there is one and only 'web' process on Heroku, it will divide into two Heroku apps: Main and LiveQuery.
// A: Main app - All features except for LiveQuery server
// Step A1. Setup a Parse app on Heroku
// Step A2. Add a Heroku Redis (free plan is enough for testing)
// Step A3. Configure Parse app, add redisURL for liveQuery
var api = new ParseServer({
...
liveQuery: {
@harperreed
harperreed / electric_objects.py
Last active August 11, 2022 10:02
Electric objects simple API wrapper
import requests
import urllib
import requests
import json
import random
"""
here is a wrapper for the *unreleased* electric objects API
Built by Harper Reed (harper@nata2.org) - @harper
@icoxfog417
icoxfog417 / NSDateExtension.swift
Created December 24, 2014 07:45
NSDate Extension(swift)
import Foundation
extension NSDate {
var calendar: NSCalendar {
return NSCalendar(identifier: NSGregorianCalendar)!
}
func after(value: Int, calendarUnit:NSCalendarUnit) -> NSDate{
return calendar.dateByAddingUnit(calendarUnit, value: value, toDate: self, options: NSCalendarOptions(0))!
}
@jbergen
jbergen / get-fonts
Created November 18, 2014 20:38
Print all available font families and font names (Swift)
for family in UIFont.familyNames() {
let sName: String = family as String
println("family: \(sName)")
for name in UIFont.fontNamesForFamilyName(sName) {
println("name: \(name as String)")
}
}
@genedelisa
genedelisa / AudioPlayer
Last active January 20, 2017 10:16
Swift AVAudioPlayer
class Sound : NSObject {
/// The player.
var avPlayer:AVAudioPlayer!
/**
Uses AvAudioPlayer to play a sound file.
The player instance needs to be an instance variable. Otherwise it will disappear before playing.
*/
func readFileIntoAVPlayer() {
@mbigatti
mbigatti / UIColor+RGB.swift
Last active February 14, 2021 07:22
UIColor extension that add a whole bunch of utility functions.
//
// UIColor+RGB.swift
// Copyright (c) 2014 Massimiliano Bigatti. All rights reserved.
//
import Foundation
import UIKit
/**
UIColor extension that add a whole bunch of utility functions like:
@arosenb2
arosenb2 / BasicChildBrowser.swift
Last active May 24, 2024 03:56
A child web browser without navigation features in iOS using WKWebView in Swift
import Foundation
import UIKit
import Webkit
class BasicChildBrowser:UIViewController, WKNavigationDelegate {
let web = WKWebView()
let toolbar = UIToolbar()
let progressSpinner = UIActivityIndicatorView(activityIndicatorStyle: .White)
let progressBar = UIProgressView(progressViewStyle: .Bar)
@alexstone
alexstone / slack_notification.php
Created March 3, 2014 06:54
Fire a Slack Notification via CURL
<?php
// (string) $message - message to be passed to Slack
// (string) $room - room in which to write the message, too
// (string) $icon - You can set up custom emoji icons to use with each message
public static function slack($message, $room = "engineering", $icon = ":longbox:") {
$room = ($room) ? $room : "engineering";
$data = "payload=" . json_encode(array(
"channel" => "#{$room}",
"text" => $message,
@ardcore
ardcore / atom-events
Last active October 13, 2021 20:35
atom.io events
application:open-your-keymap
application:open-your-stylesheet
autocomplete:attach
autoflow:reflow-paragraph
bookmarks:clear-bookmarks
bookmarks:jump-to-next-bookmark
bookmarks:jump-to-previous-bookmark
bookmarks:toggle-bookmark
bookmarks:view-all
check:correct-misspelling