Skip to content

Instantly share code, notes, and snippets.

View pbonneville's full-sized avatar

Paul Bonneville pbonneville

View GitHub Profile
@pbonneville
pbonneville / gist:a26176b2477c43f597a00ca0fa6e3f28
Created February 28, 2018 22:27 — forked from tobyhede/gist:3179978
Ruby/Rails date format cheat sheet
From http://linux.die.net/man/3/strftime
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%e - Day of the month without leading 0 (1..31)
%g - Year in YY (00-99)
import UIKit
@IBDesignable
class RoundedButton: UIButton {
@IBInspectable var cornerRadius: CGFloat = 0 {
didSet {
layer.cornerRadius = cornerRadius
layer.masksToBounds = cornerRadius > 0
}
@pbonneville
pbonneville / computed_value.swift
Last active June 29, 2016 20:52
Sample code for a basic computed value for Swift
// This code is designed to be dropped into Xcode snippets. Paste the code into an Xcode document
// and then drag it onto the Code Snippet library to create a snippet with prompts.
var <# variable name #>: <# variable type #> {
get {
return <# value to return #>
}
set {
// "newValue" is the value that was passed into this variable to be set and is automagically available to you
var <# value to set #> = newValue
@pbonneville
pbonneville / code_structure_comments.swift
Created June 29, 2016 20:33
Some basic comment MARK: statements to help organization code in a Swift file
// MARK: - VARIABLES -
// MARK: - INITIALIZATION -
// MARK: - PUBLIC METHODS -
// MARK: - PRIVATE METHODS -
// MARK: - DELEGATE METHODS -
@pbonneville
pbonneville / index.json.jbuilder
Last active June 3, 2016 16:33
Sample of Rails jbuilder template to create customized JSON output. This also shows how to access related object values and how to iterate over a has_many relationship in order to get to nested values. This is verified to work in Rail 4+ and 5rc1.
# app/views/controller_name/index.json.jbuilder
json.array!(@pose_blocks) do |pose_block|
if pose_block.published == true
json.extract! pose_block, :unique_id, :name, :pose_id_for_cover_image, :video_duration, :video_size, :duration
json.focus_type pose_block.focus_type.name
json.ability_type pose_block.ability_type.name
json.poses pose_block.pose_block_poses.each do |pose_block_pose|
json.unique_id pose_block_pose.pose.unique_id
json.duration pose_block_pose.duration