Skip to content

Instantly share code, notes, and snippets.

View scottymac's full-sized avatar

Scott McMillin scottymac

View GitHub Profile
@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:
@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")
@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

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

// 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 / Events.cs
Last active August 29, 2015 14:08 — forked from wmiller/Events.cs
using System.Collections;
using System.Collections.Generic;
public class GameEvent
{
}
public class Events
{
static Events instanceInternal = null;
@scottymac
scottymac / Postgres Cast an Array Column for Comparison
Last active August 29, 2015 14:04
Postgres Cast an Array Column for Comparison
-- datetimes is an array column of strings (b/c ActiveRecord doesn't support arrays of datetimes just yet (but soon))
-- This is doing a date comparison
SELECT * FROM table WHERE now() ANY (CAST(datetimes as timestamp[]))
in ActiveRecord:
scope :past, lambda {
where(":now > ALL (CAST(datetimes as timestamp[]))", { now: Time.zone.now })
}