Skip to content

Instantly share code, notes, and snippets.

@mturilin
mturilin / paste_to_devtools_console.js
Created March 29, 2020 22:04
Delete all Google Photos
for(i = 1; i<=9999; i++) {
console.log("Iteration # --> " + i);
document.querySelectorAll('div[role=checkbox]').forEach(div=>div.click());
document.querySelectorAll('div[aria-label*="Select all photos"]').forEach(div=>div.click());
await new Promise(r => setTimeout(r, 3000));
try{console.log("Selected documents count for iteration [" + i + "]: " + document.evaluate('/html/body/div[1]/div/c-wiz/c-wiz[2]/span/div[1]/div/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText);}catch(ex){/*do nothing*/}
document.querySelector('button[title=Delete]').click();
await new Promise(r => setTimeout(r, 5000));
document.evaluate('//span[text()="Move to trash"]', document, null, XPathResult.ANY_TYPE, null ).iterateNext().click();
@carlosramireziii
carlosramireziii / allow_content_type.rb
Last active September 22, 2023 21:39
A validator and RSpec matcher for restricting an attachment’s content type using Active Storage
require "rspec/expectations"
RSpec::Matchers.define :allow_content_type do |*content_types|
match do |record|
matcher.matches?(record, content_types)
end
chain :for do |attr_name|
matcher.for(attr_name)
end
@beaufortfrancois
beaufortfrancois / finally.js
Created October 10, 2017 08:34
Promise.prototype.finally vs try/catch/finally with Async/Await
// Promise.prototype.finally
fetch('http://foo.bar')
.then(response => console.log(response))
.catch(error => console.log(error))
.finally(_ => console.log('finally'))
// try/catch/finally with Async/Await
@m-e-h
m-e-h / Responsive-embed.css
Last active April 22, 2018 14:14
Responsive video embeds for WP
/**
* Flexible media embeds
*
* For use with media embeds – such as videos, slideshows, or even images –
* that need to retain a specific aspect ratio but adapt to the width of their
* containing element.
*
* Based on: http://alistapart.com/article/creating-intrinsic-ratios-for-video
*/
@contemplate
contemplate / functions.php
Last active November 14, 2023 12:59
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
/*--------------------------------------
Woocommerce - Allow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@refractalize
refractalize / install_node-oracledb_on_elcapitan.md
Last active January 13, 2017 11:30 — forked from kubo/install_node-oracledb_on_elcapitan.md
Install node-oracledb on OS X 10.11 El Capitan

Installing Oracle Clients on Mac OS X El Capitan

(This page is a simplification of another guide to installing oracle on Mac OS X, from which this was forked.)

Get InstantClient version numbers

Run these brew commands:

brew install InstantClientTap/instantclient/instantclient-basiclite
@mikejolley
mikejolley / functions.php
Created March 10, 2016 09:39
WooCommerce Disable guest checkout for certain products
<?php
// Code goes in theme functions.php or a custom plugin
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' );
function conditional_guest_checkout_based_on_product( $value ) {
$restrict_ids = array( 1, 2, 3 ); // Replace with product ids which cannot use guest checkout
if ( WC()->cart ) {
$cart = WC()->cart->get_cart();
@prasadsilva
prasadsilva / fresh-chrome-with-custom-tz.sh
Last active June 4, 2023 12:54 — forked from stuartsierra/fresh-chrome.sh
Launch new instances of Google Chrome on OS X with isolated cache, cookies, user config and custom Timezone
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@addyosmani
addyosmani / package.json
Last active January 18, 2024 21:31
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",