Skip to content

Instantly share code, notes, and snippets.

@ryancurtin
ryancurtin / scout_apm_absinthe_plug.ex
Last active December 18, 2021 14:52 — forked from percygrunwald/scout_apm_absinthe_plug.ex
Scout Absinthe (GraphQL) Instrumentation
defmodule ReaperWeb.Plugs.ScoutApmAbsinthe do
@moduledoc """
This plug allows us to add context to our GraphQL requests in Scout.
We are intuiting the operation name from the query itself and attaching it
to a Scout layer
"""
alias ScoutApm.Internal.Layer
alias Reaper.MetaLogger, as: Logger
class CustomersController < ApplicationController
include CustomersHelper
def lookup_phone
customer_data = Customer.customer_data_by_type('phone', params[:PhoneNumber])
reset_device(customer_data)
Customer.customer_data_to_json(customer_data)
end
def lookup_account_id
@ryancurtin
ryancurtin / calculator.html
Created September 3, 2014 22:35
Calculator
<html>
<body>
<head>
<style>
.row {
margin: 10px 0;
}
input {
width: 200px;
@ryancurtin
ryancurtin / gitknowledge
Created June 26, 2014 21:45
Random git commands over the years
# Force Pull (on a release, get updated production / preproduction)
-------------------------------------------------------
git fetch --all
git reset --hard origin/master
@ryancurtin
ryancurtin / dialog.js
Created November 17, 2012 00:31
blahblahblah
$(document).ready(function() {
var url = 'http://google.com';
var dialog_form = $('<div id="dialog-form">Loading form...</div>').dialog({
autoOpen: false,
width: 520,
modal: true,
open: function() {
return $(this).load(url + ' #content');
},
close: function() {
@ryancurtin
ryancurtin / treenode.rb
Created July 23, 2012 00:25
Treenode problem
class TreeNode
attr :children
attr_reader :parent
def name=(value)
@name=value
end
def name
@name
@ryancurtin
ryancurtin / arrayrandom.rb
Created May 7, 2012 16:46
Randomly Display Elements from Array
x = %w(a b c d e)
x.cycle(x.length) do
y = x.sample
p y
x.delete(y)
end
@ryancurtin
ryancurtin / morsels.rb
Created March 13, 2012 22:11
Morsels are Delicious
m = %w(.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..)
z = Hash[*m.zip(("A".."Z").to_a).flatten]
arr = []
morse.split(" ").each do |x|
x.split(" ").each do |y|
arr << z[y]
end
arr << " "
end
@ryancurtin
ryancurtin / jqueryrowhide.html.erb
Created March 4, 2012 21:25
jQuery Hiding Rows
<h3>Select the Number of Guests Before Proceeding: <label for="guests"></label></h3>
<select name="guests" id="guests" class="span1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
@ryancurtin
ryancurtin / rake_countries.rake
Created February 10, 2012 18:58
Rake task to build list of countries to call api
# Here is the rake task I've created. The API has a little quirk though -- I'm calling 'subcontinent,' but it isn't #working because the subcontinent is stored in the name property (i.e. <subcontinent name="England">). For reference, #the API file I'm referring to is here: http://www.instantworldbooking.com/xml/files/locations.xml
# Aside from the first loop, the rest of the should work. I may have to find a way around populating an array with the #locations (such as copying the results and reformatting them - I just need a list of countries from that file). Once I #have the list of locations, I can continue (I'm not sure how to run the rake task yet)
"desc"
task
# make an array of all countries that the api supports -- STILL NEED TO FIGURE OUT HOW TO GET THIS FROM API
response = HTTParty.get("http://www.instantworldbooking.com/xml/files/locations.xml")
country = response['locations']['continent']['subcontinent']