Skip to content

Instantly share code, notes, and snippets.

View scottymac's full-sized avatar

Scott McMillin scottymac

View GitHub Profile
@scottymac
scottymac / gist:1810536
Created February 12, 2012 20:01
Custom validators for jQuery Tools
// custom validators
// generic validator for required input fields to work with validator() & [placeholder]
$.tools.validator.fn("input[required]", "Please complete this mandatory field.", function(input, value) {
var pass;
if ((value == "") || (value == $(input).attr("placeholder"))) {
$(input).addClass("invalid");
pass = false;
} else {
$(input).removeClass("invalid");
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@scottymac
scottymac / UnixTimeCodedDate.swift
Created December 16, 2021 19:46
Decodable Property Wrapper
import Foundation
@propertyWrapper
struct UnixTimeCodedDate {
var wrappedValue: Date?
init(wrappedValue: Date?) {
self.wrappedValue = wrappedValue
}
}
// The MIT License
//
// Copyright (c) 2015-2021 Scott McMillin
//
// 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 permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The MIT License
//
// Copyright (c) 2015-2017 Scott McMillin
//
// 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 permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@scottymac
scottymac / Toggleable.swift
Created February 19, 2021 15:57
Swift Toggleable Enum protocol extension
import Foundation
protocol Toggleable: CaseIterable, Equatable {
mutating func toggle()
}
extension Toggleable {
mutating func toggle() {
guard Self.allCases.count == 2, let firstCase = Self.allCases.first else {
fatalError("Enum must have only two elements")

I was chasing down another issue (slow "Save As") and thought these two issues may have been related (with QuickLook being the common broken link). Unfortunately, my "Save As" dialog is still miserably slow on the initial load; but IconServicesAgent hasn't gone above 30MB and he rarely makes an appearance in the Console!

Some of these steps may not be necessary, but here are all of the steps I took that inadverdently put IconServicesAgent back in its place. Note: all commands are a single-line, if they appear to be multiple that's just the forum formatting.

  1. Check for any QuickLooks related .plist files. In a terminal: mdfind com.apple.quicklook. -name .plist

  2. I only had files at the system level (specifically within /System/Library/LaunchAgents/). If you have others, modify the directions below to take that into account (re-introducing plist files from the system level back up to the user).

  3. Make some temporary directories to store these plist files, just in case: mkdir ~/tmp-quicklook

@scottymac
scottymac / lucky_crud.cr
Created November 20, 2018 21:51
Lucky Framework (Crystal) Basic CRUD setup
# MODEL
class Foo < BaseModel
table :foos do
column name : String
end
end
# FORM
class FooForm < Foo::BaseForm
fillable name
var current_url = window.location.href;
var feedbin_url = "https://feedbin.me/?subscribe="
var inst_regex = new RegExp("https:\/\/www\.instagram\.com\/(.*)\/");
var inst_username = inst_regex.exec(current_url)[1];
if (inst_username !== "" || inst_username !== undefined) {
var feed_url = "https://rsshub.app/instagram/user/" + inst_username;
window.location = feedbin_url + feed_url;
}
// The bookmarklet
Verifying my Blockstack ID is secured with the address 1C6zqdybJmBASXyRvxUeTpDWjeEodyHykQ https://explorer.blockstack.org/address/1C6zqdybJmBASXyRvxUeTpDWjeEodyHykQ