Skip to content

Instantly share code, notes, and snippets.

@mjm
mjm / LinkedText.swift
Created May 21, 2020 03:56
Tappable links in SwiftUI Text view
import SwiftUI
private let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
struct LinkColoredText: View {
enum Component {
case text(String)
case link(String, URL)
}
@yosukehasumi
yosukehasumi / readme.md
Last active October 22, 2021 15:12
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Postgres
  8. Capistrano
@javan
javan / bc_require_element.coffee
Created November 28, 2016 20:24
<bc-require>: Basecamp 3's lazy JavaScript loader
BC.registerElement "bc-require",
createdCallback: ->
@setAttribute("pending", "")
attachedCallback: ->
BC.ready =>
if Loader.find(@script)?.loaded
@activate()
else
@deactivate()
addEventListener "trix-initialize", (event) ->
new TrixAutoLinker event.target
class TrixAutoLinker
constructor: (@element) ->
{@editor} = @element
@element.addEventListener("trix-render", @autoLink)
@autoLink()
autoLink: =>
@tomichj
tomichj / toggle_bluetooth.sh
Last active August 29, 2015 14:02
Mac OS X Keyboard Maestro script to toggle bluetooth on and off
# first install blueutil, 'brew install blueutil'
# next create a new Keyboard Maestro macro
# add a Execute Shell Action action to script and paste in the following:
bluetooth=$(/usr/local/bin/blueutil)
is_on="Power: 1"
if [[ "$bluetooth" =~ "$is_on" ]];
then
/usr/local/bin/blueutil power 0
else
@bigglesrocks
bigglesrocks / README.md
Last active February 24, 2023 05:51
Rails Scoped Invitation System

#Scoped Invitation System for User Groups with Rails#

Starting out with the following models and associations:

####User

  • has_many :memberships
  • has_many :organizations through :memberships

####Organization (User Group)

  • has_many :memberships