Skip to content

Instantly share code, notes, and snippets.

View itsderek23's full-sized avatar

Derek Haynes itsderek23

View GitHub Profile
@itsderek23
itsderek23 / scout_apm_httpoison.ex
Created April 18, 2018 00:08 — forked from mitchellhenke/scout_apm_httpoison.ex
Scout HTTPoison Instrumentation
# Instruments HTTPoison calls.
#
# Example usage:
#
# defmodule DemoWeb.PageController do
# use DemoWeb, :controller
# alias Demo.HTTPClient
#
# def index(conn, _params) do
# case HTTPClient.get("https://cnn.com") do
@itsderek23
itsderek23 / Elixirdesignpatterns.md
Created December 8, 2016 16:29 — forked from jsturg/Elixirdesignpatterns.md
Elixir foundations for Ruby Devs: transforming data

Elixir foundations for Ruby Devs: transforming data

Have you ever reached for a drink of water, then realized, half-way through your first sip, it was Sprite? I like Sprite, but that first sip of a similar-looking, but very different liquid is a shock.

That's how Elixir can feel if you're coming from Ruby. The syntax looks similar, but Elixir is different from the first sip. For a smooth transition, you need to (a) learn some functional programming patterns and (b) unlearn some Object-Orientated habits.

A core design pattern of Elixir is the focus on data transformations: you'll see it in libraries like Ecto.Changeset, Ecto.Multi, Plug.Conn and built-ins like Enum. Let's dive in.

Data Transformations

@itsderek23
itsderek23 / Elixirdesignpatterns.md
Last active December 7, 2016 17:43
Elixir foundations for Ruby Devs: transforming data

Elixir foundations for Ruby Devs: transforming data

Have you ever reached for a drink of water, then realized, half-way through your first sip, it was Spite? I like Sprite - but that first sip of a similar-looking, but very different liquid is a shock.

That's how Elixir can feel if you are coming from Ruby. The syntax looks similar, but Elixir is different from the first sip. For a smooth transition, you need to (a) learn some functional programming patterns and (b) unlearn some Object-Orientated habits.

A core design pattern of Elixir is the focus on data transformations: you'll see it in libaries like Ecto.Changeset, Ecto.Multi, Plug.Conn and built-ins like Enum. Let's dive in.

Data Transformations

#! /usr/bin/env bash
# This example bash script file is located here: /home/your-username/scripts/scout_cron.sh for our example, but could be anywhere on your server.
# Make sure you remember to make this file an executable script by: chmod +x /home/your-username/scripts/scout_cron.sh.
# Loading the RVM Environment files. To find your unique rvm path use: rvm env --path -- ruby-version[@gemset-name].
# For example: rvm env --path -- 1.9.3-p194@projectX
source /home/deploy/.rvm/environments/ruby-1.9.3-p374
# Changing directories to our rails project. The example below is a Capistrano path.
#! /usr/bin/env bash
# This example bash script file is located here: /home/your-username/scripts/scout_cron.sh for our example, but could be anywhere on your server.
# Make sure you remember to make this file an executable script by: chmod +x /home/your-username/scripts/scout_cron.sh.
# Loading the RVM Environment files. To find your unique rvm path use: rvm env --path -- ruby-version[@gemset-name].
# For example: rvm env --path -- 1.9.3-p194@projectX
source /home/deploy/.rvm/environments/ruby-1.9.3-p374
# Changing directories to our rails project. The example below is a Capistrano path.
@itsderek23
itsderek23 / mysql-health-check.rb
Created September 9, 2011 13:33
MySQL Health Scout plugin
# MySQL Health plugin
#
# Plugin is intended to monitor basic MySQL parametrs
# plugin was inspired by mysqltuner
#
# Currently plugin monitors
# * InnoDB data size / buffer pool
# * Highest usage of available connections
# * Active processes