Skip to content

Instantly share code, notes, and snippets.

View kosarlukascz's full-sized avatar
😶‍🌫️

Lukáš Kosař kosarlukascz

😶‍🌫️
View GitHub Profile
@NeilMasters
NeilMasters / delete-all-facebook-photos.js
Created December 6, 2022 11:45
Javascript to delete all of your facebook photos without having to do it manually.
/**
* Run this in your browser console and it will delete all of your facebook photos
* one after another.
*
* You will most likely need to fiddle with the css selectors but its basically:
* 1. Click edit of first photo
* 2. Click delete in dropdown menu
* 3. Click confirm in dialog
*/
setInterval(() => {
const EARTH_RADIUS = 6371000;
/**
* Calculates the great-circle distance between two points, with
* the Haversine formula.
*
* @param float $latitudeFrom Latitude of start point in [deg decimal]
* @param float $longitudeFrom Longitude of start point in [deg decimal]
* @param float $latitudeTo Latitude of target point in [deg decimal]
@mrkaluzny
mrkaluzny / woocommerce-popularity-last-30-days.php
Created May 13, 2022 15:56
WooCommerce -> Popularity custom sorting based on last 30days of sales
<?php
if (!wp_next_scheduled('set_last_month_product_sales_hook')) {
wp_schedule_event(time(), 'daily', 'set_last_month_product_sales_hook');
}
add_action('set_last_month_product_sales_hook', 'cc_set_last_month_sales');
function cc_set_last_month_sales()
{
@soderlind
soderlind / dropzonejs-wp-rest-api.js
Last active July 27, 2024 11:21
DropzoneJS & WordPress REST API
/*
Uploading images is a two step process (from https://github.com/WP-API/WP-API/issues/1768#issuecomment-160540932):
POST the data to /wp/v2/media - this can either be as the request body, or in multipart format. This will upload the file, and give you a 201 Created response with a Location header. This header points to the post object for the attachment that has just been created.
PUT the post data to the endpoint returned in the Location header (which will look something like /wp/v2/media/{id}).
I do step 2 (PUT), if POST is a success, in myDropzone.on("success", function(file, response){}
*/
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute