Skip to content

Instantly share code, notes, and snippets.

View soffes's full-sized avatar

Sam Soffes soffes

View GitHub Profile
soffes / Decoders+JSON.swift
Last active January 8, 2021 12:51 — forked from loudmouth/Decode Array<Any> and Dictionary<String, Any> Swift
Decode Array<Any> and Dictionary<String, Any> Swift
import Foundation
// Inspired by
private struct JSONCodingKeys: CodingKey {
var stringValue: String
init?(stringValue: String) {
self.stringValue = stringValue
soffes / highlight.swift
Last active November 16, 2021 07:34 — forked from orta/highlight.swift
Swift implementation to highlight Cocoa UI elements (
// Taken from:
NSBezierPath(rect: rect).fill()
if rect.height > 1 {
let currentControlTint = NSColor.currentControlTint
let startingAlpha: CGFloat = currentControlTint == .blueControlTint ? 0.16 : 0.09
soffes / Readme.markdown
Created July 3, 2018 23:25 — forked from calebd/Readme.markdown
Run Loop Source

CFRunLoopSource is cool. It lets you build behavior similar to the mechanisms that drive setNeedsLayout and setNeedsDisplay in UIKit.

I found myself in need of something like this a couple of times. It's great to know that no matter how many times I say I need to update something, I will get a single callback at the end of the run loop that gives me a chance to perform my work.

Here is a little Swift wrapper that makes the API easier to deal with.

Updated for Swift 4

soffes / UIColorExtension.swift
Created July 21, 2015 15:48 — forked from asarode/UIColorExtension.swift
Swift extension to get luma value of a UIColor
import UIKit
extension UIColor {
var luminance: CGFloat {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
getRed(&red, green: &green, blue: &blue, alpha: nil)
soffes / html5_template.html
Created December 7, 2011 01:48 — forked from nathansmith/html5_template.html
Simple HTML5 Template
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="">
POST /book/:id/notes
selection[spine_item_id] or selection[spine_item_play_order]
// roommateappAppDelegate.m
// roommateapp
// Created by Court Simas on 4/4/10.
// Copyright Court Simas 2010. All rights reserved.
#import "roommateappAppDelegate.h"
#import "RootViewController.h"
class RenderDirectly < ActionController::Base
include ActionController::Rendering
include AbstractController::Layouts
append_view_path Rails.root.join("app", "views").to_s
layout "application"
def index
render *env["generic_views.render_args"]
// TinyMCE Settings.
extended_valid_elements: 'style',
mode: 'exact',
elements: 'id_name',
theme: 'advanced',
theme_advanced_toolbar_location: 'top',
theme_advanced_toolbar_align: 'left',
plugins: 'safari, style, table, paste, media',
theme_advanced_buttons1: 'bold, italic, underline, justifyleft, justifycenter, justifyright, justifyfull, formatselect, fontselect, fontsizeselect',
# Install ImageMagick on Snow Leopard: by kain, improved by mislav and samsoffes
# Work with 64bit kernel mode
set -e
# Passenger users: amend your Apache global configuration with the following directive
# SetEnv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin