Skip to content

Instantly share code, notes, and snippets.

@velzie
velzie / manifest-v2-chrome.md
Last active September 24, 2024 09:49
How to keep using adblockers on chrome and chromium

How to keep using adblockers on chrome and chromium

  1. google's manifest v3 has no analouge to the webRequestBlocking API, which is neccesary for (effective) adblockers to work
  2. starting in chrome version 127, the transition to mv3 will start cutting off the use of mv2 extensions alltogether
  3. this will inevitably piss of enterprises when their extensions don't work, so the ExtensionManifestV2Availability key was added and will presumably stay forever after enterprises complain enough

You can use this as a regular user, which will let you keep your mv2 extensions even after they're supposed to stop working

Linux

In a terminal, run:

@ReganRyanNZ
ReganRyanNZ / factory_bot.rb
Created March 8, 2021 03:50
find_or_create for FactoryBot
# initializers/factory_bot.rb
# This needs to be extended in any factory you want its methods in, e.g.:
# factory :my_factory do
# extend FactoryBotEnhancements
# change_factory_to_find_or_create
# end
# FactoryBot.create(:my_factory) # creates with default attributes
# FactoryBot.create(:my_factory) # finds with the same default attributes
@AlexWayfer
AlexWayfer / benchmark.rb
Last active August 20, 2020 17:34
Benchmark example
# frozen_string_literal: true
require 'bundler/setup'
Bundler.setup :system
require 'pry-byebug'
require 'benchmark'
require 'benchmark/ips'
require 'benchmark/memory'
@benstigsen
benstigsen / TwitchBot.rb
Last active September 6, 2019 10:06
Twitch chat bot written in Ruby
# bot.rb
require 'socket'
require 'logger'
# Create logger
log = Logger.new("log.txt")
# Required Info
PASS = "oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # "oauth:YourOauthToken" https://twitchapps.com/tmi/ <--- REQUIRED <--- REQUIRED
NICK = "botname" # Name of bot <--- REQUIRED <--- REQUIRED
@heliohead
heliohead / feature_helper.rb
Created April 4, 2017 00:06
Compile assets before run rspec features test
# spec/support/feature_helper.rb
RSpec.configure do |config|
config.before :all do
ENV['PRECOMPILE_ASSETS'] ||= begin
case self.class.metadata[:type]
when :feature, :view
STDOUT.write "Precompiling assets..."
system "bundle exec rake assets:precompile > /dev/null 2>&1"
@colby-swandale
colby-swandale / Rails DockerFile
Created October 25, 2015 08:56
Dockerfile with rbenv and ruby-install
FROM ubuntu:latest
MAINTAINER Colby Swandale <colby@taplaboratories.com.au>
# update apt cache and install dependencies
RUN apt-get update && apt-get install git curl build-essential libssl-dev libreadline-dev zlib1g-dev sqlite3 libsqlite3-dev -y
# add app user
RUN adduser --gecos '' --disabled-password app
# set user to app
USER app
# set rbenv, ruby-build bin paths
ENV HOME /home/app
@avdi
avdi / macro_modules.rb
Last active August 29, 2018 07:43
Modules for macros. In reference to: http://thepugautomatic.com/2013/07/dsom/
class SomeORM
def self.attributes(*names)
if const_defined?(:DynamicAttributes, false)
mod = const_get(:DynamicAttributes)
else
mod = const_set(:DynamicAttributes, Module.new)
include mod
end
mod.module_eval do
names.each do |name|
@samstokes
samstokes / regex-groups-global.rb
Created November 18, 2009 03:28
How to extract groups from a regex match in Ruby without globals or temporary variables. Code snippets supporting http://blog.samstokes.co.uk/post/251167556/regex-style-in-ruby
if "foo@example.com" =~ /@(.*)/
$1
else
raise "bad email"
end
# => "example.com"
@raggi
raggi / alias_task.rake
Created November 12, 2009 15:11
A helper to alias a task in rake
def alias_task(name, old_name)
t = Rake::Task[old_name]
desc t.full_comment if t.full_comment
task name, *t.arg_names do |_, args|
# values_at is broken on Rake::TaskArguments
args = t.arg_names.map { |a| args[a] }
t.invoke(args)
end
end