Skip to content

Instantly share code, notes, and snippets.

View davidwilliam's full-sized avatar

David William Silva davidwilliam

View GitHub Profile
@davidwilliam
davidwilliam / brute_force_attack_password.rb
Last active February 8, 2022 00:37
A toy Ruby class for brute forcing hashes in order to find their corresponding passwords.
#!/usr/bin/ruby
require 'digest'
module Password
class BruteForce
attr_accessor :validation, :hash_value, :type_id, :hash_algorithm_id, :length, :collections
def initialize(argv)
@hash_value, @type_id, @hash_algorithm_id, @length = argv
@davidwilliam
davidwilliam / keybase.md
Last active January 13, 2021 20:57
keybase.md

Keybase proof

I hereby claim:

  • I am davidwilliam on github.
  • I am davidwsilva (https://keybase.io/davidwsilva) on keybase.
  • I have a public key ASAFUtY3LLfKIzzzEHhvPgHWLuTtOZzIaLfpA_fiEnrNiQo

To claim this, I am signing this object:

require 'omniauth-oauth2'
module Omniauth
module Strategies
class Oi < OmniAuth::Strategies::OAuth2
# Give your strategy a name.
option :name, "oi"
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
class SessionsController < Devise::SessionsController
# DELETE /resource/sign_out
def destroy
user = current_user
credential = user.credentials.oi.first
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
# encoding: utf-8
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:oi]
has_many :credentials
def self.find_for_oi_authentication(request)
@davidwilliam
davidwilliam / draft_gazeta_crawler.rb
Last active August 29, 2015 14:16
Draft - Crawler Gazeta
require 'mechanize'
class Gazeta
def source
browser.get(base_url + root_path)
end
def root_path
"/jogorapido/jogorapido-1.html"