Skip to content

Instantly share code, notes, and snippets.

Kyle Fox kylefox

Block or report user

Report or block kylefox

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
kylefox / color.m
Created Jan 27, 2012
Generate a random color (UIColor) in Objective-C
View color.m
Distributed under The MIT License:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
kylefox / 001_add_record_uuid_to_active_storage_attachments.rb
Last active Jan 13, 2020
Migrations that make ActiveStorage attachments work with UUID primary keys.
View 001_add_record_uuid_to_active_storage_attachments.rb
class AddRecordUuidToActiveStorageAttachments < ActiveRecord::Migration[5.2]
def change
# After applying this migration, you'll need to manually go through your
# attachments and populate the new `record_uuid` column.
# If you're unable to do this, you'll probably have to delete all your attachments.
# You've pretty much got useless garbage data if that's the case :(
add_column :active_storage_attachments, :record_uuid, :uuid
kylefox / gist:4512777
Created Jan 11, 2013
If you want to use Xcode's FileMerge as your git mergetool, this is how you set it up.
View gist:4512777
# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff
kylefox / currency.js
Created Jan 14, 2011
Format currency with JavaScript
View currency.js
// Takes a Number and returns a US/CAN currency string.
function toCurrency(amount) {
return "$" + amount.toFixed(2);
// Adds a .toCurrency() method to Numbers.
Number.prototype.toCurrency = function() {
return toCurrency(this);
kylefox / attachment-utils.js
Created Oct 17, 2018
Convert Base64 data URLs to File objects for Trix attachments
View attachment-utils.js
window.AttachmentUtils = (function() {
var BASE64_MARKER = ';base64,';
var Utils = {
// Takes a file size (in bytes) and returns a human-friendly string representation.
humanFileSize: function(size) {
if(size < 1) return "0 bytes";
kylefox / find_unused_helpers.rb
Created Mar 28, 2019 — forked from kennethkalmer/find_unused_helpers.rb
Find unused helpers in a Rails app
View find_unused_helpers.rb
#!/usr/bin/env ruby
# Shotgun approach (read: slow and dirty hack) to help find unused helpers in a Rails application
start =
# Build an array of filename globs to process.
# Only search file types that might use or define a helper.
extensions = %w[rb js haml erb jbuilder].map { |ext| "app/**/**/*.#{ext}" }
default_app_config = 'cn.apps.users.config.UsersAppConfig'
kylefox /
Last active Aug 30, 2019
Run Django database migrations after deploy to Heroku. This file must live at `bin/post_compile` within your root project directory.
# !/usr/bin/env bash
# File path should be ./bin/post_compile
# (.sh extension added in Gist just to enable shell syntax highlighting.
echo "=> Performing database migrations..."
python migrate
View subscription.json
"object": {
"id": "sub_Ees5zGujQ85DxG",
"object": "subscription",
"application_fee_percent": null,
"billing": "charge_automatically",
"billing_cycle_anchor": 1554603702,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
kylefox / .gitignore
Created Dec 9, 2018 — forked from jbergler/.gitignore
Acestream on Mac
You can’t perform that action at this time.