Skip to content

Instantly share code, notes, and snippets.

Needed software:
- HFS HTTP fileserver (for serving firmware file) - https://www.rejetto.com/hfs/?f=dl
- Not all HTTP servers will work, it has to support streaming, I think
- Postman (for instructing device to download file from URL) - https://www.postman.com/downloads/
- OTA protocol documentation: https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/master/SONOFF%20DIY%20MODE%20Protocol%20Doc%20v2.0%20Doc.pdf
Steps:
- Prepare your firmware you want to flash (for example from ESPHome)
-- delete any usermeta specific to the other subsites
delete from wp_usermeta where meta_key regexp '^wp_([0-9]+)_';
-- duplicate the wp_usermeta structure in a working data table,
-- but add a unique index for filtering out duplicates
create table _fix_usermeta like wp_usermeta;
alter table _fix_usermeta add unique(user_id, meta_key);
-- copy the site-specific usermeta, keeping only the last of each duplicate
insert into _fix_usermeta
@garubi
garubi / s3-upload-aws4.sh
Created September 15, 2021 13:42 — forked from vszakats/s3-upload-aws4.sh
AWS S3 upload using signature v4
#!/bin/sh -u
# To the extent possible under law, Viktor Szakats (vsz.me)
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# Upload a file to Amazon AWS S3 using Signature Version 4
#
# docs:
@garubi
garubi / wp_config.php
Created April 7, 2021 09:56 — forked from butlerblog/wp_config.php
Configure WordPress wp_mail function to send through SMTP server https://b.utler.co/Y3
<?php
/*
* Set the following constants in wp-config.php.
* These should be added somewhere BEFORE the constant ABSPATH is defined.
*
* Author: Chad Butler
* Author URI: https://butlerblog.com
*
* For more information and instructions, see: https://b.utler.co/Y3
@garubi
garubi / gist:8ecf136eb522e6425e02ac273f8558c4
Created December 7, 2020 08:36 — forked from clifgriffin/gist:8827396
Change comment notification recipient for Shopp products
<?php
add_filter('comment_notification_recipients', 'override_comment_notice_repicient', 10, 2);
function override_comment_notice_repicient($emails, $comment_id) {
$comment = get_comment( $comment_id );
if ( empty( $comment ) )
return $emails;
$post = get_post( $comment->comment_post_ID );
@garubi
garubi / .editorconfig
Last active September 1, 2020 11:12 — forked from salcode/.editorconfig
WordPress .editorconfig - modified version of the WordPress coding standards
# EditorConfig helps keep your project formatting consistent.
# See https://EditorConfig.org
#
# This is a modified version of the WordPress coding standards.
#
# Author: Sal Ferrarello (@salcode)
# https://salferrarello.com/wordpress-editorconfig/
#
# You can download this file directly
# to your project from the command-line with
@garubi
garubi / gist:7ddaa4c282b167ed3eca5aa5f1dd881e
Created March 30, 2017 12:47 — forked from kyleondata/gist:3440492
Backbone.js and Handlebars.js example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<script src="jquery-1.7.2.min.js" ></script>
<script src="handlebars-1.0.0.beta.6.js" ></script>
<script src="underscore-min.js" ></script>
<script src="backbone-min.js" ></script>
@garubi
garubi / gist:d08a7dbfdbcfbebac7b4
Created November 20, 2015 14:10 — forked from johnkolbert/gist:769160
Unregisters a post type and removes the menu item
<?php
/*
* Usage for a custom post type named 'movies':
* unregister_post_type( 'movies' );
*
* Usage for the built in 'post' post type:
* unregister_post_type( 'post', 'edit.php' );
*/
function unregister_post_type( $post_type, $slug = '' ){
@garubi
garubi / pullJSON.js
Created November 6, 2015 16:33 — forked from varun-raj/pullJSON.js
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //