Skip to content

Instantly share code, notes, and snippets.

View jstewart's full-sized avatar

Jason Stewart jstewart

View GitHub Profile
defmodule AdventOfCode.Day05 do
@moduledoc """
Intuition:
Part 1: Split each line in half
convert each char of split line into set, find the intersection
calculate the priority of the intersection and sum
Part 2: Chunk input into groups of 3 lines
convert each char of each chunk into set, find the intersection
@jstewart
jstewart / gist:c9ebaff085a977c4dce71c71fca78963
Last active December 2, 2022 14:50
Advent Of Code 2022 Day 2
defmodule AdventOfCode.Day02 do
@scores %{"A" => 1, "B" => 2, "C" => 3, "X" => 1, "Y" => 2, "Z" => 3}
@score_table [
[3, 6, 0],
[0, 3, 6],
[6, 0, 3]
]
def part1(args) do
defmodule AdventOfCode.Day01 do
def part1(args) do
args
|> into_bags()
|> Enum.max()
end
def part2(args) do
args
|> into_bags()

Keybase proof

I hereby claim:

  • I am jstewart on github.
  • I am jstew (https://keybase.io/jstew) on keybase.
  • I have a public key ASD6p_ZIkMjlYJ80Mz5875-47hXe8n3YhB2u8MlDrYxv8Ao

To claim this, I am signing this object:

@jstewart
jstewart / gist:7664823
Created November 26, 2013 19:40
Org-pomodoro notifications for OS X.
;; Needs terminal-notifier (brew install terminal-notifier)
(defun notify-osx (title message)
(call-process "terminal-notifier"
nil 0 nil
"-group" "Emacs"
"-title" title
"-sender" "org.gnu.Emacs"
"-message" message))
;; org-pomodoro mode hooks
@jstewart
jstewart / gist:4127386
Created November 21, 2012 20:17
My Slate Config
# This is the default .slate file.
# If no ~/.slate file exists this is the file that will be used.
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Aliases
alias 1-left push left bar-resize:screenSizeX/2
alias 1-right push right bar-resize:screenSizeX/2
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
before_filter :authorize_admin
rescue_from UserNotAuthorized, :with => :handle_auth_exception
private
def handle_auth_exception
render :text => "401 Not Authorized", :status => :unauthorized
# Generate TAGS files with bundler projects. Bundle must be updated, and tags binary
# must be exuberant ctags.
namespace :tags do
namespace :generate do
desc <<-EOT
Generate a new emacs TAGS file for the current project.
Requires exuberant ctags and bundler.
EOT
task :emacs do
# Gmail-style keyboard shortcuts
macro index,pager y "<enter-command>unset trash\n <delete-message>" "Gmail archive message"
macro index,pager d "<enter-command>set trash=\"imaps://imap.googlemail.com/[GMail]/Bin\"\n <delete-message>" "Gmail delete message"
# In user model
def current
Thread.current[:current_user]
end
def current=(user)
Thread.current[:current_user] = user
end