Skip to content

Instantly share code, notes, and snippets.

@jdembowski
jdembowski / wp-rest-api-example.py
Last active January 17, 2024 21:07
Use cookie authentication to obtain a nonce for WP REST API calls that need authentication.
#!/usr/bin/python3
# This Python script will
#
# - Log into a WordPress installation using supplied credentials.
# - Get a single published post using the REST call /wp/v2/posts
# - Get a valid nonce from '/wp-admin/post.php?post=xxx&action=edit'
# - Use cookie+nonce to retrieve on post in draft status via REST.
#
# Getting that valid nonce must be performed prior to each WP REST call
@jdembowski
jdembowski / destination-list-api.py
Created November 27, 2023 18:47
destination-list-api.py
#!/usr/bin/python3
import requests, json, sys, re
api_org = '2323049'
# Read the Management API base64 of the management key and secret.
#
# Key: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
# Secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@jdembowski
jdembowski / Configuration_adv.h
Created January 18, 2019 01:07
Wanhao Duplicator i3 V2 Configuration_adv.h for Marlin 1.1.9
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@jdembowski
jdembowski / Configuration.h
Created June 19, 2019 00:18
Anycubic Delta Linear with inductive probe
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
#!/usr/bin/python
# This will need the investigate module installed via 'pip install investigate'
import investigate, json, fileinput, codecs, sys, os, requests, time, re
def slice(l, n):
n = max(1, n)
return [l[i:i + n] for i in range(0, len(l), n)]
# Read key, single line
with open('api-key.txt', 'r') as k:
@jdembowski
jdembowski / not-gravatar.php
Last active July 13, 2021 23:04
Use Gravatar images in WordPress but don't reveal the Gravatar img src URL. Display the Gravatar inline instead.
<?php
/*
Plugin Name: Tin Foil Hat Gravatars
Description: Use Gravatars but don't use Gravatars. What? Shut up.
Author: Jan Dembowski
Author URI: https://blog.dembowski.net/
Version: 0.7
License: GPL2
*/
<?php
/*
Plugin Name: Make new sites in the network with https URLs
Description: Force new sites in a multisite network to use HTTPS as the scheme.
Plugin Author: Jan Dembowski
This probably should not be necessary and the scheme should be picked up
by WordPress. But I could not get my new sites to use https so here I am.
// ==UserScript==
// @name WordPress topic redirect
// @namespace WordPress_topic_redirect
// @description Forces https, adds view=all to topic urls and redirects if needed.
// @version 1
// @grant none
// @run-at document-start
// @include *://*wordpress.org/support/topic/*
// @include https://wordpress.org/support/plugin/*
// @include https://wordpress.org/support/theme/*
@jdembowski
jdembowski / Configuration.h
Created January 18, 2019 01:06
Wanhao Duplicator i3 v2 Marlin 1.1.9 Configuration.h file
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
<?php
/*
Plugin name: Import IFTTT created Instagram posts
Description: This plugin will identify IFTTT created Instagram posts when published and will download the image into the media library. It will also modify the post to use the media library copy.
Version: 0.4
Author: Jan Dembowski
Author URI: https://blog.dembowski.net/
*/