Skip to content

Instantly share code, notes, and snippets.

Frank Rietta rietta

Block or report user

Report or block rietta

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rietta
rietta / hours.rb
Created Nov 27, 2017
Keep a copy in your ~/bin and chmod to 755. Now, you can compute nicely rounded hours at will from the command line.
View hours.rb
#!/usr/bin/env ruby
##
# Convert hours to invoice time, which is rounded to 6 minute increments.
time_value = ARGV.last.to_s.strip
if time_value =~ /\A[0-9]*:[0-9]*\Z/
time_elements = time_value.split(':')
minutes = time_elements.first.to_i * 60.0 + 1.0 * time_elements.last.to_f
elsif time_value.to_f > 0.0
minutes = time_value.to_f * 60.0
else
@rietta
rietta / url_validator.rb
Created Jul 20, 2017
Create a folder app/validators. Add this to it. Now you can do "validate :some_field, url: true" in your model validations. Works in Rails 3, 4, and 5.
View url_validator.rb
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
valid = begin
URI.parse(value.to_s).kind_of?(URI::HTTP)
rescue URI::InvalidURIError
false
end
unless valid
record.errors[attribute] << (options[:message] || "is an invalid URL")
View url-tweaker-abuser-story-test.rb
describe "User can't change the ID" do
login_as user
get :show, id: other_account.id
expect(response).to have_http_status :unauthorized
expect(response.body).to_not include other_account.id
end
@rietta
rietta / hours.rb
Created Sep 12, 2016
Command line tool to convert hours into decimal notation suitable for invoices. 2:50 = 2.8 hours, etc.
View hours.rb
#!/usr/bin/env ruby
##
# Convert hours to invoice time, which is rounded to 6 minute increments.
time_value = ARGV.last.to_s.strip
if time_value =~ /\A[0-9]*:[0-9]*\Z/
time_elements = time_value.split(':')
minutes = time_elements.first.to_i * 60.0 + 1.0 * time_elements.last.to_f
elsif time_value.to_f > 0.0
minutes = time_value.to_f * 60.0
View feinstein-burr.md

The anticipated Feinstein-Burr Compliance with Court Orders Act, an anti-security bill, would require the provision of data in an intelligible format to a government pursuant to a court order (scribd.com). A draft copy has appeared online though whether it has been submitted officially within the Senate is not yet clear (vice.com).

This bill essentially says you can not have any conversation or data exchange that the government can not access if it wants to. It is the legal culmination of what the FBI has been lobbying Congress for years. If Feinstein-Burr becomes law, it will be illegal to deploy strong encryption without key escrow maintained by each company. Cryptographers and computer scientists near-unanimously assert key backup systems are insecure at scale.

@rietta
rietta / hello_world_encrypt.sql
Last active Jan 12, 2016
Encrypts a hello world greeting to my personal public PGP key that's published at https://keybase.io/rietta.
View hello_world_encrypt.sql
SELECT
ARMOR(PGP_PUB_ENCRYPT(
'Hello, World',
DEARMOR('-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQINBFPRvdYBEACeM7pbpqxheVpIkfNSt1I//MLMmmvV/2XlJFj0z4zTOZPU5KTl
DNpfV0bHSUU5pOs9hSkM5WP+uWTAl/X5a5Ty7Vdr0r//sYNYt05ummAZQEwfaSzj
Ys57Ks1yC/31SOM/bOvWOIf/+D/GVAEuJTdfwic/Vv56ixuk8skLjWTmxBBCFpbF
dEXWyxuADvftrhaGq16xaOx0vLFxagL7mpIEjVN2yYadR5iMm1g48lAG6Tc/JEPY
@rietta
rietta / superpolynomial.txt
Last active Oct 12, 2016
Memorize the RSA encryption algorithm as a song! This is a mirrored copy of the RSA, Superpolynomial song which has become hard to find on the Internet.
View superpolynomial.txt
These original sources are now no longer available:
- http://www.xent.com/FoRK-archive/oct00/0429.html
- http://www.cryptorights.org/events/2000/superpolynomial.html
For a 2000 example of how to use this song in a lecture format, see http://permalink.gmane.org/gmane.comp.encryption.general/4856 by Eric Hughes.
To the tune of Mary Poppins:
Superpolynomial subexponential runtimes.
Even though in practice it would take you several lifetimes,
@rietta
rietta / sql_views.rake
Created Mar 6, 2015
SQL Views rake task implementing `rake db:views`
View sql_views.rake
namespace :db do
desc "Update and create SQL views"
task :views => :environment do
Dir["#{Rails.root}/db/sql_views/*.sql"].each do |file_name|
STDERR.puts "Applying the SQL view at #{file_name}"
source_file = File.new(file_name, 'r')
if source_file and (sql_content = source_file.read)
ActiveRecord::Base.transaction do
# Each statement ends with a semicolon followed by a newline.
View security_talk.md

Regular talks are 45-minute blocks. We recommend 30-35 minutes of presentation, followed by allowing 10-15 minutes for questions and discussion.

Title

Defending from Data Breaches by Fostering a Culture of Security

Tracks: Culture or Crafting Code

Abstract (600 chars)

You've been hearing about big data breaches in the news. As a developer who doesn't specialize in security, knowing how to protect your application from getting hacked may seem like a daunting task. However, fundamentals in the design and development process will greatly increase the security that protects your users from harm.

For Review Committee

@rietta
rietta / keybase.md
Created Jan 8, 2015
Confirming for keybase
View keybase.md

Keybase proof

I hereby claim:

  • I am rietta on github.
  • I am rietta (https://keybase.io/rietta) on keybase.
  • I have a public key whose fingerprint is EF65 AC38 A698 E87D 9CEF B60F 658C D5E9 C004 BAE3

To claim this, I am signing this object:

You can’t perform that action at this time.