Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
# If you want to test against edge Rails replace the previous line with this:
# gem "rails", github: "rails/rails", branch: "main"
require 'digest/sha1'
require 'net/http'
def pwned?(password)
digest = Digest::SHA1.hexdigest(password).upcase
prefix = digest[0,5]
suffix = digest[5,256]
uri = URI.parse("https://api.pwnedpasswords.com/range/" + prefix)

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

# Idea from: https://twitter.com/nateberkopec/status/1255573064747712515
require 'fileutils'
require 'net/http'
require 'json'
require 'uri'
require 'csv'
POINT_THRESHOLD = 400
HN_ALGOLIA_URL = 'https://hn.algolia.com/api/v1/search?query=github.com&restrictSearchableAttributes=url&page=%<page>d'

Keybase proof

I hereby claim:

  • I am hundredwatt on github.
  • I am gaggleampjason (https://keybase.io/gaggleampjason) on keybase.
  • I have a public key whose fingerprint is 37B5 EBD2 0DA0 D058 233F A8A7 5B63 CAA2 4575 FA9B

To claim this, I am signing this object:

'use strict';
/**
* This code sample demonstrates an implementation of the Lex Code Hook Interface
* in order to serve a bot which manages dentist appointments.
* Bot, Intent, and Slot models which are compatible with this sample can be found in the Lex Console
* as part of the 'MakeAppointment' template.
*
* For instructions on how to set up and test this bot, as well as additional samples,
* visit the Lex Getting Started documentation.
@hundredwatt
hundredwatt / initializer.rb
Created February 8, 2015 20:42
Apply rails/rails#18846 for Delayed Job workers
Delayed::Worker.lifecycle.before :execute do
require 'active_record/relation/warn_on_result_set_size'
ActiveRecord::Base.warn_on_result_set_size = 1001
ActiveRecord::Base.logger = Rails.logger
ActiveRecord::Base.logger.level = Logger::WARN
end
<div style="width:100%; text-align:left;" ><iframe src="http://eventbrite.com/tickets-external?eid=13780017403&ref=etckt" frameborder="0" height="260" width="100%" vspace="0" hspace="0" marginheight="5" marginwidth="5" scrolling="auto" allowtransparency="true"></iframe><div style="font-family:Helvetica, Arial; font-size:10px; padding:5px 0 5px; margin:2px; width:100%; text-align:left;" ><a style="color:#ddd; text-decoration:none;" target="_blank" href="http://www.eventbrite.com/r/etckt">Online event registration</a><span style="color:#ddd;"> for </span><a style="color:#ddd; text-decoration:none;" target="_blank" href="https://www.eventbrite.com/e/amplify-2015-the-stakeholder-social-engagement-conference-tickets-13780017403?ref=etckt">AMPlify 2015 - The Stakeholder Social Engagement Conference</a> <span style="color:#ddd;">powered by</span> <a style="color:#ddd; text-decoration:none;" target="_blank" href="http://www.eventbrite.com?ref=etckt">Eventbrite</a></div></div>
require 'csv'
# Please someone include this in the csv module proper. Thanks.
# Public domain. Author: Felix Rabe (heavily based on 1.9.3 stdlib csv docs)
class CSV
def CSV.unparse array, opts = {}
CSV.generate(opts) do |csv|
array.each { |i| csv << i }
end
@hundredwatt
hundredwatt / store_bug_test.rb
Last active January 4, 2016 19:30
ActiveRecord::Store - no implicit conversion of ActiveSupport::HashWithIndifferentAccess into String
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.2'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.