Skip to content

Instantly share code, notes, and snippets.

Ben Dodson bendodson

Block or report user

Report or block bendodson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bendodson
bendodson / jQuery.consoleConfig.js
Created Jan 23, 2012
Basic jQuery plugin to allow console logging in browsers without JavaScript consoles
View jQuery.consoleConfig.js
jQuery.consoleConfig = function(useConsole,useAlert)
{
if (arguments.length == 0) {
var useConsole = true;
var useAlert = true;
} else if (arguments.length == 1) {
var useAlert = true;
}
if (!window.console || !useConsole) {
@bendodson
bendodson / HKHealthStore-DeleteObjects.swift
Last active Oct 6, 2015
A fix for the broken implementation of HKHealhStore.deleteObjectsOfType in iOS 9.0 (see radar 22977320)
View HKHealthStore-DeleteObjects.swift
//
// HKHealthStore-DeleteObjects.swift
// HealthKitTest
//
// Created by Ben Dodson on 06/10/2015.
// Copyright © 2015 Dodo Apps. All rights reserved.
//
import Foundation
import HealthKit
@bendodson
bendodson / RandomColorWithSeed (Swift 3)
Last active Apr 24, 2018
Generate a random color with a seed string using Swift 3
View RandomColorWithSeed (Swift 3)
import UIKit
func randomColor(seed: String) -> UIColor {
var total: Int = 0
for u in seed.unicodeScalars {
total += Int(UInt32(u))
}
View gist:d842769c2d6f29280e55231e3c0cc5f8
func runMediaLibraryQuery() {
let query = MPMediaQuery.playlists()
if let playlists = query.collections {
for playlist in playlists {
if let playlistName = playlist.value(forKey: MPMediaPlaylistPropertyName) {
NSLog("Playlist: \(playlistName)")
if let item = playlist.items.first, let title = item.title {
NSLog("First track: \(title)")
}
}
You can’t perform that action at this time.