Skip to content

Instantly share code, notes, and snippets.

View kidpollo's full-sized avatar
💁‍♂️
Potato farming

Paco Viramontes kidpollo

💁‍♂️
Potato farming
  • San Francisco, CA
View GitHub Profile
@kidpollo
kidpollo / index.js
Last active June 13, 2024 07:55 — forked from auchenberg/index.js
Script to delete all Google Photos from console (2024)
const maxCount = 5000;
const counterSelector = '.rtExYb';
const checkboxSelector = '.ckGgle[aria-checked=false]';
const photoDivSelector = ".yDSiEe.uGCjIb.zcLWac.eejsDc.TWmIyd";
const deleteButtonSelector = 'button[aria-label="Delete"]';
const confirmationButtonSelector = '#yDmH0d > div.VfPpkd-Sx9Kwc.cC1eCc.UDxLd.PzCPDd.V639qd.bvQPzd.oEOLpc.A9Uzve.VfPpkd-Sx9Kwc-OWXEXe-FNFY6c > div.VfPpkd-wzTsW.O4g5Md.iWO5td > div > div.VfPpkd-cnG4Wd.m5OsGf > div > div.VfPpkd-T0kwCb.IdSMxc > button.VfPpkd-LgbsSe.VfPpkd-LgbsSe-OWXEXe-k8QpJ.nCP5yc.AjY5Oe.LQeN7.kDryjd';
async function deleteGooglePhotos() {
// Retrieves the current count of selected photos
const getCount = () => {
@kidpollo
kidpollo / Instrument Anything in Rails 3.md
Created September 14, 2012 21:39 — forked from mnutt/Instrument Anything in Rails 3.md
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@kidpollo
kidpollo / application.rb
Created August 23, 2012 21:48 — forked from AMEE/application.rb
Make Rails 3.1 use symbols in sessions so it can share Rails 2 sessions.
#...
module MyApp
class Application < Rails::Application
#...
config.after_initialize do
require 'session_patch'
end
@kidpollo
kidpollo / uri.js
Created April 21, 2012 04:04 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.host; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
@kidpollo
kidpollo / retry_upto.rb
Created October 7, 2011 07:42 — forked from raul/retry_upto.rb
retry_upto.rb
# Ruby's `retry` with steroids:
#
# - retry up to 5 times without waiting between them and retrying after any exception
#
# retry_upto(5) do ... end
#
# - retry up to 5 times, waiting 2 seconds between retries and retrying after any exception
#
# retry_upto(5, :wait => 2) do ... end
#
@kidpollo
kidpollo / retry_upto.rb
Created October 7, 2011 07:42 — forked from raul/retry_upto.rb
retry_upto.rb
# Ruby's `retry` with steroids:
#
# - retry up to 5 times without waiting between them and retrying after any exception
#
# retry_upto(5) do ... end
#
# - retry up to 5 times, waiting 2 seconds between retries and retrying after any exception
#
# retry_upto(5, :wait => 2) do ... end
#
#!/usr/bin/env ruby
## Taken from: http://snippets.dzone.com/posts/show/4935
#
# Usage:
# a = AmazonS3Asset.new
# a.copy_over_bucket("myapp_production", "myapp_production")
require 'aws/s3'
require 'mechanize'
require 'logger'
# usage:
# field_labeled('Select your address').should have_option("Home Address")
Spec::Matchers.define :have_option do |expected|
def options_for(select_field)
select_field.options.map(&:inner_text)
end
match do |select_field|
raise "Field is not a SelectField" unless select_field.kind_of?(Webrat::SelectField)
options_for(select_field).include?(expected)