Skip to content

Instantly share code, notes, and snippets.

View lewis-smith's full-sized avatar
👨‍💻

Lewis Smith lewis-smith

👨‍💻
View GitHub Profile
@kharrison
kharrison / CoreDataController.swift
Last active January 31, 2023 22:36
Swift wrapper for NSPersistentContainer - Easy Core Data Setup with iOS 10
//
// CoreDataController.swift
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@ollieatkinson
ollieatkinson / HTTPStatusCode.swift
Last active April 15, 2024 18:34
HTTP status codes as a Swift enum.
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
enum HTTPStatusCode: Int, Error {
/// The response class representation of status codes, these get grouped by their first digit.
enum ResponseType {
/// - informational: This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
case informational
@mobyjames
mobyjames / MovingAverage.swift
Created January 31, 2015 04:08
Moving Average
class MovingAverage {
var samples: Array<Double>
var sampleCount = 0
var period = 5
init(period: Int = 5) {
self.period = period
samples = Array<Double>()
}
@MattSurabian
MattSurabian / google-maps-loader.js
Last active June 26, 2019 16:07
Boilerplate RequireJS module to async load the google maps api and still be able to bundle with rjs. Cooked up with @adamjarret
/**
* GoogleMapsAPI Loader Module
*
* Returns a promise that resolves with the google.maps object when all of the google maps api loading process is complete
*
* Example Usage:
*
* define([ 'app/lib/google-maps-loader' ], function(GoogleMapsLoader){
* GoogleMapsLoader.done(function(GoogleMaps){
* // your google maps code here!
@adelevie
adelevie / md5.js
Created January 7, 2013 23:03
This should allow you create MD5 hashes within Parse Cloud Code. Just copy `md5.js` into the `cloud` folder. See `usage.js` for a basic example. I used the JS MD5 implementation found here: http://pajhome.org.uk/crypt/md5/md5.html
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*