Skip to content

Instantly share code, notes, and snippets.

View ruddfawcett's full-sized avatar

Rudd Fawcett ruddfawcett

View GitHub Profile
@ruddfawcett
ruddfawcett / start_spotify_private.scpt
Created January 9, 2021 17:48
Opens the Spotify desktop application in a private session.
tell application "Spotify" to activate
tell application "System Events"
tell process "Spotify"
click menu item "Private Session" of menu "Spotify" of menu bar 1
end tell
end tell
@ruddfawcett
ruddfawcett / Abstract - CachedProperties.md
Created October 5, 2020 20:12 — forked from pauljohanneskraft/Abstract - CachedProperties.md
cache a complicated computed property using the following pattern

Cached Properties

Complicated, time expensive computed properties can be cached using the following pattern.

var a = Cached(0) {
    (a: Int) -> Int in
    print("did calculate")
    return a + 100
}
{"openapi":"3.0.2","info":{"title":"Saturn API","description":"API Documentation for Saturn","version":"0.1"},"paths":{"/api/v2/auth/verify":{"post":{"tags":["Auth"],"summary":"Verify an user from an OAuth2 token","operationId":"verify_token_v2_auth_verify_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupView"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Verify Token V2 Auth Verify Post","anyOf":[{"type":"array","items":{"$ref":"#/components/schemas/SchoolViewPublic"}},{"$ref":"#/components/schemas/Token"}]}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v2/waitlist/schools":{"get":{"tags":["Waitlist"],"summary":"Get all the schools on waitlist","operationId":"get_waitlist_schools_public_info_v2_waitlist_schools_get","parameters":[{"required":false,"schema":{"title":"Query","
@ruddfawcett
ruddfawcett / APIClient+PromiseKit.swift
Created April 30, 2020 23:32 — forked from DanielCardonaRojas/APIClient+PromiseKit.swift
Custom API Client Abstractions inspired by http://kean.github.io/post/api-client but with no third party dependencies. As a lib over here -> https://github.com/DanielCardonaRojas/APIClient
import PromiseKit
extension APIClient {
func request<Response, T>(_ requestConvertible: T,
additionalHeaders headers: [String: String]? = nil,
additionalQuery queryParameters: [String: String]? = nil,
baseUrl: URL? = nil) -> Promise<T.Result>
where T: URLResponseCapable, T: URLRequestConvertible, T.Result == Response {
return Promise { seal in
self.request(requestConvertible, additionalHeaders: headers, additionalQuery: queryParameters, success: { response in
@ruddfawcett
ruddfawcett / simple-json-reponse.php
Created August 22, 2017 19:48 — forked from james2doyle/simple-json-reponse.php
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($message = null, $code = 200)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
@ruddfawcett
ruddfawcett / Gruntfile.js
Created November 9, 2016 01:36 — forked from inkbase/Gruntfile.js
A Gruntfile to set up a Sass/Pug project
module.exports = function(grunt) {
// configure the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// copy from the source directory to build
copy: {
build: {
cwd: 'source',
src: [ '**', '!**/*.pug', '!sass', '!sass/*', '!**/*.scss', '!partials', '!partials/*' ],
dest: 'build',
@ruddfawcett
ruddfawcett / Slimdown.md
Created August 5, 2016 19:38 — forked from jbroadway/Slimdown.md
Slimdown - A simple regex-based Markdown parser.

Slimdown

A very basic regex-based Markdown parser. Supports the following elements (and can be extended via Slimdown::add_rule()):

  • Headers
  • Links
  • Bold
  • Emphasis
  • Deletions
@ruddfawcett
ruddfawcett / enum-access.js
Created July 15, 2016 04:44 — forked from bnoguchi/enum-access.js
How to access enumValues in mongoose from a Model or Document
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
import UIKit
class ViewController: UIViewController {
let keyboard = KeyboardControl()
override func viewDidLoad() {
super.viewDidLoad()
@ruddfawcett
ruddfawcett / bones.html
Last active June 28, 2016 02:32
Barbones HTML file
<!DOCTYPE HTML>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>Title</title>
<link rel='stylesheet' href='assets/styles/index.css'>
</head>
<body>
<script src='js/scripts.js'></script>