Skip to content

Instantly share code, notes, and snippets.

@benjibee
benjibee / scrape.js
Created February 10, 2018 13:19
A little script to import starred places saved as geoJSON data from Google Maps. Could be better. Works.
// This script is meant to import Google Maps starred places into
// another Google account.
// Given a geoJSON file of Google Maps starred places (places.json)
// exported by Google takeout (account backup) this script should
// open each place URL and manually click save.
// Upon first run, it's best to stop it and manually login to your
// Google account otherwise you'll run into a non-verified device
// issue. Run again and it should continue through with problems.
@benjibee
benjibee / delete_posts.sql
Created March 15, 2023 15:50
WordPress SQL Query: delete posts and post meta for posts older than N days
DELETE p, pm
FROM wp_posts p
INNER
JOIN wp_postmeta pm
ON pm.post_id = p.ID
WHERE p.post_type = 'page'
AND p.post_date < (NOW() - INTERVAL 120 DAY);
@benjibee
benjibee / AppServiceProvider.php
Last active January 10, 2023 15:16
Use ngrok URLs in Laravel for all assets, generated URLs, etc.
<?php
namespace App\Providers;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
{
@benjibee
benjibee / convert_excel_to_date.php
Last active October 12, 2021 15:10
Convert Excel date / time to PHP date
<?php
/**
* Convert date and time from Excel into a PHP DateTime object
*
* Based on similar function from PHPExcel library.
*
* @see https://stackoverflow.com/a/11172688/401980
* @see http://www.cpearson.com/excel/datetime.htm
*/
@benjibee
benjibee / update_meta.php
Created December 16, 2020 17:02
Update WordPress attachment meta
$args = [
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null,
];
$attachments = get_posts($args);
@benjibee
benjibee / functions.php
Last active April 21, 2020 12:25
Wordpress: Move adminbar to bottom, expand on hover
<?php
// move admin bar to bottom of screen when viewing site
function benjibee_modify_adminbar()
{
?>
<style>
div#wpadminbar {
top: auto;
bottom: 0;
@benjibee
benjibee / maintenance.php
Last active November 25, 2019 17:25
Default Maintenance Page for Wordpress
<?php
// place in wp-content directory to
// automatically override default page
http_response_code(503);
wp_load_translations_early();
?><!DOCTYPE html>
<html>
@benjibee
benjibee / flac_to_mp3
Created June 23, 2014 10:40
Convert FLAC to Mp3 (AAC)
brew install ffmpeg
## cd into the folder containing the FLAC files
for f in *.flac; do ffmpeg -i "$f" -aq 1 "${f%flac}mp3"; done
@benjibee
benjibee / index.php
Created February 2, 2015 12:45
BitBucket Webhook
<?php
/*
* ButBucket Webhook `git pull` automation v0.1
* @author Benji Bilheimer
*
* If a directory matching the repository name is found
* in BASE_PATH, CD into that directory and run a git pull.
*
*/
/*
*
* NOT YET IMPLEMENTED FUNCTIONALITY!! EEEEEEP!!!!
*
* Taken from ticket: #16784
* https://core.trac.wordpress.org/attachment/ticket/16784/16784.diff
*
* NOT YET IMPLEMENTED FUNCTIONALITY!! EEEEEEP!!!!
*
*