Skip to content

Instantly share code, notes, and snippets.

View jqr's full-sized avatar

Elijah Miller jqr

View GitHub Profile
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@jqr
jqr / reader.rb
Created February 24, 2012 01:53
Locking log rotation for processing
require 'fileutils'
class Reader
def self.read(filename, processing_filename)
return [] unless File.exists?(filename)
FileUtils.move(filename, processing_filename)
lines = []
File.open(processing_filename, 'r') do |f|
f.flock(File::LOCK_EX)
while !f.eof?