Skip to content

Instantly share code, notes, and snippets.

View n-at-han-k's full-sized avatar
🚀

Nathan Kidd n-at-han-k

🚀
View GitHub Profile
@n-at-han-k
n-at-han-k / contact.rb
Created May 6, 2025 00:21 — forked from endymion/contact.rb
Example of integrating a Ruby on Rails app with Zapier using the REST hooks pattern. With support for triggering the REST hooks from Resque background jobs.
class Contact < ActiveRecord::Base
...
def after_create
if Hook.hooks_exist?('new_contact', self)
Resque.enqueue(Hook, self.class.name, self.id)
# To trigger directly without Resque: Hook.trigger('new_contact', self)
end
end
@n-at-han-k
n-at-han-k / yardoc_cheatsheet.md
Created April 22, 2025 12:15 — forked from phansch/yardoc_cheatsheet.md
Improved YARD cheatsheet
@n-at-han-k
n-at-han-k / battery.sh
Created April 22, 2025 03:26
Check battery on ubuntu
#!/bin/bash
upower -i $(upower -e | grep -i BAT)
@n-at-han-k
n-at-han-k / sexkbmap.sh
Created April 11, 2025 07:59
sexkbmap for Macbook Air 2015 GB (United Kingdom)
#!/bin/bash
setxkbmap gb mac
@n-at-han-k
n-at-han-k / vcf_to_csv.rb
Created March 30, 2025 10:16
Extract and convert data from VCF Vcards to CSV in Ruby
#!/usr/bin/env ruby
#require 'pp'
require 'vpim/vcard'
require 'csv'
COLUMN_ORDER = %w[
given_name
landline
mobile
@n-at-han-k
n-at-han-k / keyboard_backlight.sh
Created March 10, 2025 23:12
Script to enable keyboard backlight on Apple Macbook Air (Intel)
#!/bin/bash
set +o noclobber
modprobe applesmc
echo 10 > /sys/class/leds/smc::kbd_backlight/brightness
set -o noclobber
@n-at-han-k
n-at-han-k / cheatsheet.rb
Created November 19, 2024 16:00 — forked from mabenson00/cheatsheet.rb
Rails Postgres ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
@n-at-han-k
n-at-han-k / gitquick.sh
Last active August 4, 2024 14:38
Bash shell script to quickly push all changes to git in one command from any sub-directory.
#!/bin/bash
GIT=`which git`
REPO_DIR=`${GIT} rev-parse --show-toplevel`
cd ${REPO_DIR}
${GIT} add --all .
${GIT} commit -m "Quick Git Push"
${GIT} push
@n-at-han-k
n-at-han-k / action_mailbox.md
Created July 2, 2024 21:36 — forked from leastbad/action_mailbox.md
Action Mailbox: The Missing Manual

This is all you really need to know in order to make Action Mailbox work in development.

  1. Fire up ngrok http 3000 and make note of your subdomain for steps 3 and 8.
  2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard.
  3. Go into Receiving and create a catch-all route pointing to: https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime
  4. Add your Mailgun API key to your credentials:
action_mailbox:
 mailgun_api_key: API KEY HERE
@n-at-han-k
n-at-han-k / strftime_cheatsheet.rb
Last active May 12, 2024 07:13
Ruby strftime cheatsheet 💎⏰
# Additional reference here:
# https://strftime.org
require 'active_support/core_ext/integer/inflections' # To use .ordinalize() outside of rails
date = Time.now
date.strftime('%a %d %b %Y')
# => Sun 08 Sep 2024