Skip to content

Instantly share code, notes, and snippets.

View aaronmoodie's full-sized avatar
Coffee

Aaron Moodie aaronmoodie

Coffee
View GitHub Profile
# Generate stats for journal files
require 'date'
stats = {
total_files: 0,
word_count: 0,
late_entry: 0,
}
@aaronmoodie
aaronmoodie / email_list_diff.rb
Created January 29, 2020 04:24
Diff two email lists and find new and missing email
# Diff two email lists and find new and missing emails
# To use, call file and pass in an original list and updated list
# eg. ruby email_list_diff.rb ~/original_list.txt ~/updated_list.txt
original_list = File.readlines(ARGV[0])
updated_list = File.readlines(ARGV[1])
def find_unique_emails(list_01, list_02)
# given two email lists, find all emails
# in list_01 that are not in list_02
@aaronmoodie
aaronmoodie / rem_replace.rb
Last active April 10, 2018 01:18
find rem value and replace with modified version
# Find and modify all rem values
# To use, call file and pass in CSS dir
# eg. ruby rem_replace.rb ~/my_css_files
dir = ARGV[0]
Dir.glob(dir + '/*.css') do |css_file|
# do work on files ending in .css in the desired directory
puts "working on: #{css_file}..."

Keybase proof

I hereby claim:

  • I am aaronmoodie on github.
  • I am aaronmoodie (https://keybase.io/aaronmoodie) on keybase.
  • I have a public key whose fingerprint is 483E 8F5F FF31 3295 C283 5C41 5D7A 299A 0864 1366

To claim this, I am signing this object:

@aaronmoodie
aaronmoodie / gist:1308100
Created October 24, 2011 00:01
Sinatra: render template partial without layout when requested va Ajax
if request.xhr?
# renders :template_partial without layout.html
erb :template_partial, :layout => false
else
# renders as normal inside layout.html
erb :template_partial
end
➜ ~ ping duckduckgo.com
PING duckduckgo.com (46.51.216.186): 56 data bytes
64 bytes from 46.51.216.186: icmp_seq=0 ttl=47 time=493.049 ms
64 bytes from 46.51.216.186: icmp_seq=1 ttl=47 time=358.478 ms
64 bytes from 46.51.216.186: icmp_seq=2 ttl=47 time=357.297 ms
64 bytes from 46.51.216.186: icmp_seq=3 ttl=47 time=358.935 ms
64 bytes from 46.51.216.186: icmp_seq=4 ttl=47 time=469.308 ms
64 bytes from 46.51.216.186: icmp_seq=5 ttl=47 time=358.160 ms
64 bytes from 46.51.216.186: icmp_seq=6 ttl=47 time=358.421 ms
64 bytes from 46.51.216.186: icmp_seq=7 ttl=47 time=357.605 ms
@aaronmoodie
aaronmoodie / gist:5401127
Last active December 16, 2015 07:48 — forked from dnch/gist:5392985
class Show < ActiveRecord::Base
attr_accessible :artist_tokens, :cost, :booking_url, :door_charge, :venue_id, :date, :time, :starts_at
attr_reader :artist_tokens, :date, :time
validate :is_time
validate :is_date
before_save :save_date_and_time
has_many :performances
has_many :artists, :through => :performances
[5] pry(main)> file = TagLib::MPEG::File.new('taro.mp3')
=> #<TagLib::MPEG::File:0x007f852353ec88 @__swigtype__="_p_TagLib__MPEG__File">
[6] pry(main)> tag = file.tag
=> #<TagLib::Tag:0x007f852350a870 @__swigtype__="_p_TagLib__Tag">
[7] pry(main)> puts "#{file}: #{tag.title} by #{tag.artist}; track #{tag.track} on #{tag.album}"
#<TagLib::MPEG::File:0x007f852353ec88>: Taro by alt-J; track 13 on An Awesome Wave
=> nil
[8] pry(main)>
1.9.2p290 :002 > require 'taglib'
=> true
1.9.2p290 :003 > TagLib::MPEG::File.new('taro.mp3') do |file|
1.9.2p290 :004 > tag = file.tag
1.9.2p290 :005?> puts "#{file}: #{tag.title} by #{tag.artist}; track #{tag.track} on #{tag.album}"
1.9.2p290 :006?> end
=> #<TagLib::MPEG::File:0x007f9cea923770>
# html
# place under div.email (92)
<div class="gifts-newsletter">
<input type="checkbox" name="etsy_gift" id="etsy_gift"> <label for="etsy_gift">I'd also like great gift ideas from Etsy.</label>
</div>
# css
# place under form div.email (314)
.reminder p {