Skip to content

Instantly share code, notes, and snippets.

View narath's full-sized avatar

Narath Carlile narath

View GitHub Profile
@narath
narath / obsidian_new.scpt
Created January 17, 2024 20:11
Update Obsidian New Hookmark Script so that the link and file title is not encoded
-- key change = line 57 instead of $encoded_title just use $title
use framework "Foundation"
use scripting additions
property NSString : a reference to current application's NSString
property NSMutableCharacterSet : a reference to current application's NSMutableCharacterSet
set sysinfo to system info
set osver to system version of sysinfo
@narath
narath / honeybadger_mock.rb
Created November 28, 2023 18:00
Simple Mock for Honeybadger.notify in Rails test
test "something" do
notified = false
Honeybadger.stub :notify, Proc.new { |s| notified = true } do
something_that_causes_honeybadger_notify_to_be_used
end
assert notified, "Honeybadger was not notified"
end
@narath
narath / README.md
Created October 14, 2023 15:54
Fix Hookmark Freeplane Get Address Script

To implement this:

  • add get_name.scp to the Get Name script in HookMark > Settings > Scripts > FreePlane > Get Name
  • update get_address.scp for the Get Address script
  • Save

Should work.

Nice to have: FreePlane has a Copy > Copy URI which copies a URI to the current node. It might be nice to copy this which would let you link directly to a particular node (as opposed to just the map).

@narath
narath / jekyll_clickable_image_to_show_full_size_example.md
Last active August 26, 2023 20:49
Jekyll - Click on image to show full size image in Jekyll (or Markdown) without plugins

Sketches of why we do this to maximize our productivity

@narath
narath / how_to_use_annotations_plugin_with_rails_7.md
Last active February 2, 2024 02:14
How to use the annotations plugin with Rails 7 using Webpacker and Chartkick
yarn add chartjs-plugin-annotation

Then edit app/javascript/application.js

import "chartkick/chart.js"

# Add these lines
@narath
narath / app_javascript_controllers_easysubmit.js
Created March 30, 2023 15:20
Stimulus JS TextArea Easy Submit with Cmd or Ctrl Enter
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
submit() {
event.currentTarget.form.requestSubmit()
}
}
@narath
narath / find_all_classes_in_a_directory.rb
Created January 9, 2023 15:43
Find all classes in a directory
# in order to support convention over configuration it can be useful to be able to find all the classes in a directory or
# subdirectory. This lets you have easy factories for subclasses in Rails.
# Requires that you are using Zeitwerk naming conventions for files and classes
class YourRootClass
# this does not work with rails because although the paths are autoloaded
# the objects are not in memory (and are only in memory when instantiated)
# and self.inherited is only called when the classes are put in memory
# note: this likely happens in production but not in development
# def self.inherited(klass)
@narath
narath / change_localhost_domain.rb
Created January 5, 2023 13:27
Regular expression for changing the localhost domain
# in general you should never need to use this in Rails
# since you should use the url helpers
# this is a really helpful post about how to do this elegantly with a concern
# https://andycroll.com/ruby/url-helpers-outside-views-controllers/
def change_localhost_domain(url, new_domain)
url.gsub(/http:\/\/localhost:3000|http:\/\/127.0.0.1:3000/, new_domain)
end
@narath
narath / README.md
Created October 4, 2022 13:24
Github action to deploy Jekyll + Tailwindcss with rsync

Read more about getting this working here.

@narath
narath / README.md
Created September 29, 2022 12:24
Mac Utility: Prevent Citrix Workspace from launching at startup

I only use Citrix occasionally on my Mac. I did not like having it launch at startup. Here's how I stop it from starting at launch time. Derived from this helpful forum post

cd /Library/LaunchAgents
sudo rm com.citrix.*
cd /Library/LaunchDaemons
sudo rm com.citrix.ctx*