Skip to content

Instantly share code, notes, and snippets.

@betesh
betesh / Gemfile
Last active September 18, 2022 04:15
how to append a has_many association without hitting the database immediately
source 'https://rubygems.org'
gem 'activerecord', '~> 3.2.18'
gem 'sqlite3', '= 1.3.5'
gem 'rspec'
@betesh
betesh / vcr-webmock-2-converter.rb
Created November 3, 2020 01:58
webmock-vcr-cassette-upgrader
#!/usr/bin/env ruby
#
# Convert VCR cassettes that use basic auth to work with Webmock 2. Takes the folder where the VCR
#cassettes are stored as an argument.
require 'yaml'
require 'base64'
require 'uri'
require 'vcr'
@betesh
betesh / .gitignore
Last active October 22, 2020 20:31 — forked from sh4dowb/retrieve_password.py
Chromium Linux Password Retriever (Decryption support)
We couldn’t find that file to show.
@betesh
betesh / .gitignore
Last active January 8, 2020 04:01
Flattening
Gemfile.lock
examples.txt
@betesh
betesh / application.rb
Created April 11, 2018 20:54
Logging Initializers in Rails 3.2
# Put this in config/application.rb right before your Application class
class Rails::Initializable::Initializer
def run_with_logging(*args)
app = args.first
app.config.logger.warn "Running initializer #{name}\t(#{@context.class.parent})"
run_without_logging(*args)
end
alias_method_chain :run, :logging
end
@betesh
betesh / Chrome 61 Backup Saved Passwords
Last active December 14, 2017 15:19 — forked from MoradiDavijani/Chrome 61 Backup Saved Passwords
As Chrome removed the "Backup" button in "Saved Passwords", you can make a backup from your passwords by running this code in the console!
// 1. Open chrome://settings/passwords
// 2. Open chrome developer tools (using F12 or Ctrl+Shift+i)
// 3. Run the following code in the console tab
// 4. Copy output in a text file and save it somewhere safe!
function asyncForEach(array, done, iterator) {
var i = 0;
next();
function next(err) {
if (err) {
@betesh
betesh / export.js
Last active December 14, 2017 14:57
Export all your passwords from Google Chrome
/* Adapted from https://cmatskas.com/export-your-stored-passwords-from-chrome/
* 1. Go to chrome://settings-frame/passwords
* 2. Paste the following into the JS console:
*/
var decryptedRow="";
var pm = PasswordManager.getInstance();
var model = pm.savedPasswordsList_.dataModel;
var pl = pm.savedPasswordsList_;
for(i=0;i<model.length;i++){
# /usr/bin/env ruby
PAIRS = [
["SHA1_ON_NEW_BRANCH", "SHA1_ON_ORIGINAL_BRANCH"],
# etc...
]
PAIRS.each do |pair|
cmd = "bash -c 'diff <(git show #{pair[0]} -U0 --format=\"\" | grep -v \"^index\") <(git show #{pair[1]} -U0 --format=\"\" | grep -v \"^index\") | grep -v \"> @@ \" | grep -v \"< @@ \" | grep -v \"^---$\" '"
result = `#{cmd}`.chomp
# Dequeueing ActiveJob tasks in the context of your Rails application?
# An alternative is to run a standalone ActiveJob process.
# But making it dequeue and send devise emails isn't so simple.
# Devise is designed to be integrated into a Rails application, not a standalone ActiveJob process.
# Before we address configuring the standalone ActiveJob process,
# there's some code that needs to go into your Rails app.
# Put this in each model in your Rails application:
#
@betesh
betesh / failing-test-rails-issue-20882.rb
Last active August 29, 2015 14:25
failing-test-rails-issue-20882
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'