Skip to content

Instantly share code, notes, and snippets.

View mataki's full-sized avatar

Akihiro Matsumura mataki

  • SonicGarden
  • Kanagawa, Japan
  • X @mat_aki
View GitHub Profile
@mataki
mataki / user.rb
Last active December 19, 2015 09:19
mailchimp sync sample
class User < ActiveRecord::Base
def subscribe_mailchimp_list(client = Gibbon.new)
if ENV["MAILCHIMP_LIST_ID"]
logger.info "add #{self.email} to list #{ENV["MAILCHIMP_LIST_ID"]}"
client.list_subscribe(id: ENV["MAILCHIMP_LIST_ID"],
email_address: self.email,
double_optin: false,
send_welcome: false,
update_existing: true,
merge_vers: {:FNAME => self.first_name,
@mataki
mataki / notify_command_finished.zsh
Last active February 21, 2025 07:18
Plays a sound to indicate completion or failure if a command takes a long time to execute on a Mac.
function save_command_start() {
COMMAND_START_TIME=$EPOCHSECONDS
}
function notify_command_end() {
local exit_status=$?
local duration=$(( EPOCHSECONDS - COMMAND_START_TIME ))
local last_command=$(fc -ln -1 | sed 's/^[ \t]*//')
if (( duration >= 30 )); then
if [ $exit_status -eq 0 ]; then