Skip to content

Instantly share code, notes, and snippets.

View thinkclay's full-sized avatar

Clayton (McIlrath) Unicorn thinkclay

View GitHub Profile
@thinkclay
thinkclay / Restricted.tsx
Created June 21, 2020 16:25
Restriction HOC
/** @jsx createElement **/
import { createElement, FC, Fragment } from 'react'
import { connect } from 'react-redux'
import { RootState } from '@/models/app'
import { Auth, Roles, roleOptions } from '@/models/auth'
interface Props {
children: React.ReactNode
role?: Roles
@thinkclay
thinkclay / FooService.swift
Last active May 12, 2020 17:26
Swift iOS Networking Service
import Foundation
struct VOService {
public var baseUrl: String
static let shared = VOService(mode: .production)
init(mode: AppMode) {
switch (mode) {
@thinkclay
thinkclay / debugger.ftl
Last active August 9, 2020 06:22
Debugging in Khoros/Freemarker
<#ftl strip_text=true />
<#---
@homepage https://github.com/ratherblue/freemarker-debugger/
@license MIT
@version 1.0
@name freemarker-debugger
@description Macros and functions used to generate a tabular view of the .locals, .main, and .data model.
@see http://freemarker.org/docs/ref_specvar.html
@namespace debugger
@thinkclay
thinkclay / object-to-json.ftl
Last active January 12, 2020 00:08
Khoros/Freemarker utility macro for converting objects to JSON
<#macro objectToJson object, key = "unknown">
<@compress single_line=true>
<#if object?is_method>
${key}: "is_method"
<#elseif object?is_hash || object?is_hash_ex>
<#assign first="true">
{
<#list object as key, val>
<#if first="false">,</#if>
<#assign value><@objectToJson object=val!"null" key=key /></#assign>
@thinkclay
thinkclay / mailer_injection.rb
Last active April 26, 2017 10:24
Rails Mailer Injection
# config/initializers/mailer_injection.rb
# This allows `request` to be accessed from ActionMailer Previews
# And @request to be accessed from rendered view templates
# Easy to inject any other variables like current_user here as well
module MailerInjection
def inject(hash)
hash.keys.each do |key|
define_method key.to_sym do

Keybase proof

I hereby claim:

  • I am thinkclay on github.
  • I am thinkclay (https://keybase.io/thinkclay) on keybase.
  • I have a public key ASC7hdnNRAeJLwErhAM6aCSlVsQ6hVO-GGH4s8pK0Kohcgo

To claim this, I am signing this object:

@thinkclay
thinkclay / NoAutocompleteInput.jsx
Created December 26, 2016 23:06
This react input gets rid of form autocomplete with some little hacks
const Input = (props) => {
const onFocus = (e) => {
let input = e.target
if (input.hasAttribute('readonly'))
{
input.removeAttribute('readonly')
input.blur()
input.focus()
}

Keybase proof

I hereby claim:

  • I am thinkclay on github.
  • I am unicorn (https://keybase.io/unicorn) on keybase.
  • I have a public key whose fingerprint is EAE4 4A12 A705 9427 1413 2E74 0F75 CB27 7787 5FA5

To claim this, I am signing this object:

import UIKit
class ViewController: UIViewController {
@IBOutlet weak var buttonWithBorderLeft: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
@thinkclay
thinkclay / Keychain.swift
Last active August 30, 2016 12:13
Dead simple keychain access
import Security
public class Keychain
{
public class func set(key: String, value: String) -> Bool
{
if let data = value.dataUsingEncoding(NSUTF8StringEncoding)
{
return set(key, value: data)
}