Skip to content

Instantly share code, notes, and snippets.

View terrcin's full-sized avatar

terrcin terrcin

View GitHub Profile
@terrcin
terrcin / appsignal_telemetry.ex
Last active April 4, 2022 11:03 — forked from cblavier/appsignal_telemetry.ex
A Phoenix Telemetry agent to monitor all LiveView events & errors
# Add after ExampleWeb.Telemetry to the list of children to be supervised in Application.start
defmodule ExampleWeb.AppsignalTelemetry do
use GenServer
require Appsignal.Utils
import Appsignal.Utils, only: [module_name: 1]
@tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer)
@span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span)
@appsignal_namespace "live_view"
> gem list
*** LOCAL GEMS ***
bigdecimal (1.2.8)
bundler (1.13.6)
bundler-unload (1.0.2)
did_you_mean (1.0.0)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
@terrcin
terrcin / gist:dee008b594bda7c3703d
Created March 17, 2016 20:15
NZ Rails Camp 2016 Travel Information
** Friday Bus Pickup **
All buses will be leaving at their scheduled time fromPlatform 9 at the Wellington train station (http://goo.gl/maps/MKjjW) note that’s not the Bus Terminal but the Train Station. Please don’t be late, and please don’t turn up to a different time than what you selected as space is limited and it always causes us organisers headaches waiting for people who are already at camp. If for what ever reason you decide to not take the bus you have booked you need to let us know.
If you’re arriving from out of town there is a service from the airport called the Airport Flier, it will take you straight to the train station: https://www.wellingtonairport.co.nz/parking-and-transport/airport-flyer-bus/
** Driving there yourself **
You’re more than welcome to drive yourself there, please don’t turn up before 3:30pm. http://camp.ruby.nz has a link to where the camp is. Please make sure you tell us that you don’t need a seat on a bus.
@terrcin
terrcin / gist:0745f2c6240aad291077
Last active August 29, 2015 14:17
Granting readonly access to rails production console by default
# In our config/deploy.rb we have the below for an easy prod console.
# There are various ways of doing it.
desc "Remote console"
task :console, roles: :app do
server = find_servers(roles: [:app]).first
run_with_tty server, %W( ./script/rails console #{rails_env} )
end
# Turns out there is a '--sandbox' option for the console that will roll back any changes on exit

Keybase proof

I hereby claim:

  • I am terrcin on github.
  • I am terrcin (https://keybase.io/terrcin) on keybase.
  • I have a public key whose fingerprint is 07A6 FAE1 5DE2 905A 507B 7159 F054 3CBD D1E0 4937

To claim this, I am signing this object:

@terrcin
terrcin / gist:6069196
Created July 24, 2013 09:29
Works out how many seconds per handsets sale the Ubuntu Edge project needs from now on to succeed. http://www.indiegogo.com/projects/ubuntu-edge/x/1850818
finish = Time.new 2013, 8, 22, 7 # UTC
goal = 32000000
current = 3762188 # <= update this manually
remaining = goal - current
cost = 830
puts "Seconds per handset sale: #{((finish - Time.now.utc) / (remaining / cost)).round(2)}"
{
"auto_complete": false,
"color_scheme": "Packages/Color Scheme - Default/Slush & Poppies.tmTheme",
"folder_exclude_patterns":
[
".git",
"tmp",
"log"
],
"font_face": "DroidSansMono",
@terrcin
terrcin / vcr_tests.rb
Created July 4, 2012 00:21
Make including VCR in tests real easy
# using the VCR gem:
# https://github.com/myronmarston/vcr/
#
# this wraps each test in a unique VCR cassette and separately the setup method.
#
# require 'vcr_tests' in test_helper.rb
# then in a test file include the VcrTests module after the setup method
module VcrTests
@terrcin
terrcin / gist:2598654
Created May 5, 2012 00:11
Making Temfile.make_tmpname give a better quality unique name
require 'tempfile'
class Tempfile
# overriding so that the Time component of the tmpname including hours, seconds and usecs, was previously just year + month + day
def make_tmpname(basename, n)
case basename
when Array
prefix, suffix = *basename
else