Skip to content

Instantly share code, notes, and snippets.

View afcapel's full-sized avatar

Alberto Fernández-Capel afcapel

View GitHub Profile
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|
next unless model.table_exists?
model.columns.each do |col|
next unless col.name =~ /_?id\Z/
if col.type == :integer && col.sql_type != "bigint"
puts "#{model.table_name} #{col.name} is of type #{col.sql_type} but should be bigint"
import { Controller } from 'stimulus'
export default class extends Controller {
connect() {
if ( typeof window.ga != 'undefined' ) {
const currentExperiments = this.experiments()
Object.keys(currentExperiments).forEach((experimentId) => {
ga('set', 'expId', experimentId)
VCR.configure do |config|
config.cassette_library_dir = "test/support/vcr_cassettes"
config.hook_into :webmock
config.ignore_localhost = true
end
module RecordedVCR
extend ActiveSupport::Concern
included do
#!/usr/bin/env ruby --disable-gems
require "date"
require "fileutils"
JOURNAL_DIR = File.expand_path("~/textos/diario")
now = DateTime.now
date = now.strftime("%F")
require "open-uri"
module Imports
class PageCrawler
attr_reader :current_page, :pages, :crawled
attr_accessor :follow_patterns, :ignore_patterns
def initialize(start_url, max_depth: 3, max_pages: 1000)
@max_depth, @max_pages = max_depth, max_pages
@afcapel
afcapel / journal.rb
Last active February 2, 2021 06:55
Script at ~/bin/journal I use to keep a journaling practice
#!/usr/bin/env ruby --disable-gems
require "date"
require "fileutils"
JOURNAL_DIR = File.expand_path("~/Google Drive/writing/journal")
now = DateTime.now
date = now.strftime("%F")
module main
go 1.17
require github.com/gorilla/websocket v1.4.2 // indirect
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
<script>
const STATES = [
"CONNECTING",
"OPEN",
"CLOSING",
@afcapel
afcapel / index.html
Created December 16, 2022 16:55
Slow document.body.cloneNode(true) in Chrome
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Slow document.body.cloneNode(true) in Chrome</title>
<body>
<div id="container"></div>
<script type="text/javascript">
@afcapel
afcapel / stimulus.html
Last active February 8, 2023 10:15
Stimulus targets making document clone slow
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Stimulus Test</title>
</head>
<body>
<div id="container">
<button id="cloneBodyBtn">Clone body</button>