Skip to content

Instantly share code, notes, and snippets.

View gjastrab's full-sized avatar

Greg Jastrab gjastrab

View GitHub Profile
@gjastrab
gjastrab / advent_of_code_2018_day_1.exs
Last active December 5, 2018 05:34
Advent of Code 2018 - Elixir
defmodule Advent2018.Frequencies do
@input_file "frequencies"
def calibrate do
{:ok, data} = File.read(@input_file)
data
|> split_lines()
|> Enum.map(&line_to_number/1)
|> Enum.sum()

Keybase proof

I hereby claim:

  • I am gjastrab on github.
  • I am gjastrab (https://keybase.io/gjastrab) on keybase.
  • I have a public key ASD_HEaNhmNNlYL9ge3CC6macqqzuFJXo9eMlbIi9aWefwo

To claim this, I am signing this object:

@gjastrab
gjastrab / db_pool_logging.rb
Created June 24, 2016 13:48
Log Connection Pool check ins and outs
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
set_callback(:checkout, :after, :log_after_checkout)
set_callback(:checkin, :after, :log_after_checkin)
def connection_info_for_logging
pool = ActiveRecord::Base.connection_pool
pool_size = pool.size
count = pool.connections.count
in_use = pool.connections.count(&:in_use?)
queue = pool.instance_variable_get(:@available)
@gjastrab
gjastrab / fusion_layer_test.html
Created March 11, 2012 19:10
Google Fusion Layer querying test
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Test Fusion Mapping</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function init() {
var numeric_id = 3195033,
@gjastrab
gjastrab / .evergreen
Created January 6, 2011 15:09
Evergreen configuration
# Swap to chrome
Capybara.register_driver :selenium do |app|
Capybara::Driver::Selenium.new(app, :browser => :chrome)
end
Evergreen.configure do |config|
config.driver = :selenium
config.public_dir = 'javascript'
config.spec_dir = 'spec/javascripts'
config.template_dir = 'spec/templates'
@gjastrab
gjastrab / gist:306088
Created February 16, 2010 23:50
Cool git alias for viewing a log
git config --global alias.lol "log --pretty=oneline --abbrev-commit --graph --decorate"