Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am mainej on github.
  • I am jmaine (https://keybase.io/jmaine) on keybase.
  • I have a public key ASDRyJwjgJPN9jP7MI5MwXJ2u9MMaEROnAzXGP0FVXbhMQo

To claim this, I am signing this object:

@mainej
mainej / extract_license_data.rb
Last active Oct 7, 2020
How to extract detailed data from license_finder. Beware of caveats.
View extract_license_data.rb
#!/usr/bin/env ruby
require 'license_finder'
# See lib/license_finder/core.rb for more configuration options.
# A quiet logger is required when running reports...
lf = LicenseFinder::Core.new(logger: { quiet: true })
# Groups of packages
lf.acknowledged # All (non-ignored) packages license_finder is tracking
@mainej
mainej / license_report.rb
Last active Oct 7, 2020
Custom ERB `license_finder` report
View license_report.rb
#!/usr/bin/env ruby
require 'license_finder'
# See lib/license_finder/core.rb for more configuration options.
# A quiet logger is required when running reports...
lf = LicenseFinder::Core.new(logger: { quiet: true })
# Example ERB template: lib/license_finder/reports/templates/html_report.erb
template = Pathname.new("path/to/your/template.erb")
@mainej
mainej / update_reports.sh
Created Dec 30, 2014
Re-generate license_finder reports in rake task or pre-commit hook
View update_reports.sh
#!/bin/bash
HTML_REPORT=doc/dependencies.html
STATUS_REPORT=doc/dependencies.csv
checksum_before=$(md5 -q < $STATUS_REPORT)
checksum_after=$(license_finder report --format csv --columns approved name version licenses | tee $STATUS_REPORT | md5 -q)
# # Alternatively
# CHECKSUM_FILE=doc/dependencies_status.md5
@mainej
mainej / post_repository.rb
Created Apr 23, 2012
anemic controllers, thin models, fat domain
View post_repository.rb
class PostRepository
def self.update(id, post_updates, editor)
post = find(id)
raise SecurityTransgression unless can_edit?(post, editor)
post.update_attributes!(post_updates)
post
end
def self.find(id)
Post.find(id)
View sign_up_page.rb
class SignUpPage
def initialize
current_path.should == sign_up_path
end
def with_email(email)
fill_in "Login", :with => email
end
def with_password(password, confirmation = password)
View gist:23175
# by bryan helmkamp with slight modification by chris wanstrath
# from http://www.brynary.com/2008/8/3/our-git-deployment-workflow
# I DO NOT RECOMMEND USING THIS WORKFLOW - IT DESTROYS HISTORY! - jesse andrews
module GitCommands
extend self
def diff_staging
`git fetch`