Skip to content

Instantly share code, notes, and snippets.

@estum
estum / APN.md
Created December 15, 2019 09:33
Getting Your APNs Certificate

Getting Your APNs Certificate

These instructions come from another great gem, apn_on_rails.

Once you have the certificate from Apple for your application, export your key and the apple certificate as p12 files. Here is a quick walkthrough on how to do this:

  1. Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key.
  2. Right click and choose Export 2 items….
  3. Choose the p12 format from the drop down and name it cert.p12.
@estum
estum / .md
Created August 14, 2019 11:09 — forked from joepie91/.md
Running a Node.js application using nvm as a systemd service

Read this first!

Hi there! Since this post was originally written, nvm has gained some new tools, and some people have suggested alternative (and potentially better) approaches for modern systems. Make sure to have a look at the comments to this article, before following this guide!


The original article

Trickier than it seems.

@estum
estum / yieldable.rb
Created July 27, 2017 08:10
yieldable.rb: Memoized #to_proc for any callable object to use as a block argument with the "&" operator.
# This module can be used to easy make callable object or class
# to be used as a block argument with the <tt>&</tt> operator. It just
# implements the +to_proc+ method.
#
# == Examples:
#
# class Foo
# extend Yieldable
#
# def self.call(key, value)
@estum
estum / itunes-current_track-toggle_loved.applescript
Created May 26, 2017 13:51
iTunes: Toggle loved of the current track
on run {input, parameters}
tell application "iTunes"
set theTrack to get current track
if theTrack's loved then
set loved of theTrack to false
display notification "Now is not loved" with title ¬
"iTunes" subtitle theTrack's artist & " - " & theTrack's name ¬
sound name "Tink"
else
set loved of theTrack to true
@estum
estum / itunes-current_track-toggle_disliked.applescript
Last active May 26, 2017 13:52
iTunes: Toggle disliked of the current track
on run {input, parameters}
tell application "iTunes"
set theTrack to get current track
if theTrack's disliked then
set disliked of theTrack to false
display notification "Now is not disliked" with title ¬
"iTunes" subtitle theTrack's artist & " - " & theTrack's name ¬
sound name "Tink"
else
next track
require "erb"
module PostgreSQLTriggers
def create_trigger(name, **options, &block)
builder = TriggerBuilder.new(name, **options &block)
builder.each_trigger do |trigger|
reversible do |dir|
dir.up do
say "Create trigger #{trigger.name} on #{trigger.table}"
trigger.up(self)
@estum
estum / abstract_singleton.rb
Created September 7, 2016 05:53
Abstract Singleton Module Class
class AbstractSingleton < Module
def self.base_class
self < AbstractSingleton ? superclass : self
end
module SingletonInstanceMethods
::Singleton.instance_methods.each do |name|
define_method(name, ::Singleton.instance_method(name))
end
end
@estum
estum / swallow_reader.rb
Created September 4, 2016 10:24
Swallow Reader extension for Active Record Has One Through Association
# = Swallow Reader
#
# Adds <tt>:swallow</tt> option to <tt>has_one :through</tt> association builder.
# When this option set to <tt>true</tt> and through association was loaded, target record will
# be readed directly from parent without executing the join query.
#
# For example:
#
# class Review < ActiveRecord::Base
# belongs_to :song
@estum
estum / array_input.coffee
Created September 2, 2016 08:21
SimpleForm: Array Input
@Forms ?= {}
class Forms.ArrayInput
REMOVE_BUTTON_HTML = """<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>"""
ADD_ITEM_SELECTOR = "a.array-input-add-item"
getTargetFrom = (element) ->
el = ($ element)
el.closest(el.data("target"))
@estum
estum / pull_remote_db.sh
Last active April 22, 2022 10:28
Bash Script to dump remote db & restore on local
#!/usr/bin/env bash
##
# @section Variables
SOURCE_DB=
TARGET_DB=
REMOTE_USER=${REMOTE_USER:-"postgres"}
SSH_URI=
SSH_OPTIONS=${SSH_OPTIONS:-""}