Skip to content

Instantly share code, notes, and snippets.

View padi's full-sized avatar

Marc Ignacio padi

View GitHub Profile
@padi
padi / bench.sh
Created March 26, 2020 07:00 — forked from james2doyle/bench.sh
A website benchmarking script using Apache ab. This script hits a target with requests and then generates a small report for each case.
#!/usr/bin/env bash
# idea from https://www.devside.net/wamp-server/load-testing-apache-with-ab-apache-bench
# if you are testing a base url, you need a trailing slash
SITE="http://example.com/"
OUTFILE="output.txt"
DIVIDER="\n====================================================================\n"
# if the file doesnt exist, make it
@padi
padi / remove_manychat.css
Last active October 25, 2019 10:32
Updated CSS code to remove Manychat Logo in a variety of Manychat Growth Tools (Video: https://www.loom.com/share/90e01e8822a148e993f1679435b792f7)
<style>
.mcwidget-overlay a[href^="https://manychat.com"], .mcwidget-embed a[href^="https://manychat.com"] {
display: none;
}
</style>

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

@padi
padi / post_checkout_migrations.sh
Created March 27, 2018 07:26 — forked from brysgo/post_checkout_migrations.sh
Post checkout hook for managing rails migrations and bundle install
CHECKING_OUT_BRANCH=$3
OLD_BRANCH=$1
NEW_BRANCH=$2
if [ $CHECKING_OUT_BRANCH -eq 1 ]
then
FILES_CHANGED=`git diff $OLD_BRANCH $NEW_BRANCH --name-status`
MIGRATIONS_REMOVED=`echo "$FILES_CHANGED" | egrep 'D\tdb/migrate/([0-9]+)' | sort -r`
MIGRATIONS_ADDED=`echo "$FILES_CHANGED" | egrep 'A\tdb/migrate/([0-9]+)'`
@padi
padi / post_checkout_migrations.sh
Created March 27, 2018 07:26 — forked from brysgo/post_checkout_migrations.sh
Post checkout hook for managing rails migrations and bundle install
CHECKING_OUT_BRANCH=$3
OLD_BRANCH=$1
NEW_BRANCH=$2
if [ $CHECKING_OUT_BRANCH -eq 1 ]
then
FILES_CHANGED=`git diff $OLD_BRANCH $NEW_BRANCH --name-status`
MIGRATIONS_REMOVED=`echo "$FILES_CHANGED" | egrep 'D\tdb/migrate/([0-9]+)' | sort -r`
MIGRATIONS_ADDED=`echo "$FILES_CHANGED" | egrep 'A\tdb/migrate/([0-9]+)'`
@padi
padi / gist:82f84fe73eca1b68f6c9cf4770a49040
Created December 6, 2017 23:56 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@padi
padi / development.log
Last active December 6, 2017 06:45
chaos-app: GET /products on first load (development environment)
Started GET "/products" for 127.0.0.1 at 2017-12-06 14:29:33 +0800
Processing by ProductsController#index as HTML
User Load (1.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]]
Spree::Preference Load (4.0ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT $2 [["key", "spree/app_configuration/currency"], ["LIMIT", 1]]
Spree::Store Load (5.3ms) SELECT "spree_stores".* FROM "spree_stores" WHERE (url like '%tsi.lvh.me%') ORDER BY "spree_stores"."id" ASC LIMIT $1 [["LIMIT", 1]]
Spree::Store Load (6.3ms) SELECT "spree_stores".* FROM "spree_stores" WHERE "spree_stores"."default" = $1 ORDER BY "spree_stores"."id" ASC LIMIT $2 [["default", "t"], ["LIMIT", 1]]
Spree::Order Load (2.8ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3
@padi
padi / evaluate_multiline_script.rb
Created September 11, 2017 01:06 — forked from beccasaurus/evaluate_multiline_script.rb
Capybara helper for calling evaluate_script with multiple lines of JavaScript, supporting short-circuit return statements, etc etc. Just wraps your JS in a function and then calls it.
# Given a multiline script, this will wrap the script in a function and then
# call it so Capybara's evaluate_script knows how to get the return value properly.
# By default, Capybara just prepends a 'return ' to your script.
#
# Usage:
#
# value = page.evaluate_multiline_script %{
# var foo = [];
# $('li').each(function(i, li) {
# foo[foo.length] = $(li).text();
@padi
padi / no_animations.rb
Created September 8, 2017 05:12 — forked from keithtom/no_animations.rb
Rack Middleware to disable Disable CSS3/jQuery Animations for Capybara
module Rack
# disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues.
# Usage for Rails:
# in config/environments/test.rb
# config.middleware.use Rack::NoAnimations
class NoAnimations
def initialize(app, options = {})
@app = app
end
@padi
padi / run_rubocop_in_branch.sh
Created February 14, 2017 23:27
Check rubocop against file changes in your feature-branch (compared to origin/master)
git diff origin/master --name-only --diff-filter=ACMR | grep '.rb' | grep -v 'schema' | xargs rubocop -c .rubocop.yml --force-exclusion --display-cop-names