Skip to content

Instantly share code, notes, and snippets.

View kasparsd's full-sized avatar

Kaspars Dambis kasparsd

View GitHub Profile
! function(s) {
function e(e) {
for (var t, n, r = e[0], i = e[1], a = 0, o = []; a < r.length; a++) n = r[a], Object.prototype.hasOwnProperty.call(d, n) && d[n] && o.push(d[n][0]), d[n] = 0;
for (t in i) Object.prototype.hasOwnProperty.call(i, t) && (s[t] = i[t]);
for (u && u(e); o.length;) o.shift()()
}
var n = {},
d = {
0: 0
};
<?php
add_action(
'widgets_init',
function() {
global $wp_widget_factory;
$widget_classes = array_map(
function ( $widget ) {
return get_class( $widget );
cask 'virtualbox' do
version '6.0.14,133895'
sha256 'ea3ebf2457908495128178f9b6676a77b120fa7878fd626d2baf0a8c45921370'
url "https://download.virtualbox.org/virtualbox/#{version.before_comma}/VirtualBox-#{version.before_comma}-#{version.after_comma}-OSX.dmg"
appcast 'https://download.virtualbox.org/virtualbox/LATEST.TXT'
name 'Oracle VirtualBox'
homepage 'https://www.virtualbox.org/'
conflicts_with cask: 'virtualbox-beta'

Updating to mysql-server-5.7 (5.7.28-0ubuntu0.18.04.4) on Ubuntu produces the following error:

mysql_upgrade: [ERROR] 1833: Cannot change column 'table_name': used in a foreign key constraint 'innodb_index_stats_ibfk_1' of table 'mysql.innodb_index_stats'

The update appears to be changing the varchar length of the table_name column:

Important Change; Partitioning: After creating partitioned InnoDB tables with very long names, the table_name columns in the corresponding entries in the mysql.innodb_index_stats and mysql.innodb_table_stats system tables were truncated. To fix this issue, the length of the table_name column in each of these tables has been increased from 64 to 199 characters. In both cases, this is now the same as the lengths of these columns in MySQL 8.0.

So I ended deleting that constraint:

@kasparsd
kasparsd / esp32-cam-pseudocode.js
Created October 12, 2019 08:40
Main logic behind a battery powered esp32 timelapse camera
onInteruptInterval( MINUTEINSECONDS, function() {
takePicture()
goToSleep()
} )
onInteruptInterval( DAYINSECONDS, function() {
connectWifi()
.then( () => uploadImages( getNewPhotos() ) )
.finally( () => disconnectWifi() )
@kasparsd
kasparsd / db-dump.sh
Last active February 15, 2019 15:35
Must-use plugin for WordPress plugin and theme demo sites
#!/usr/bin/env bash
# Dump specific DB tables to a file.
mysqldump -u sqluser dbname wp_posts wp_postmeta > dump.sql

My WordPress Development Wishlist

  • Standardize saving post meta attributes. The state of save_post is a mess. Is autosave, has nonce, has permissions, is cron, ir WP-API? See https://github.com/xwp/wp-safe-input

  • Introduce templating for building configuration screens in the admin. Probably as an abstraction over the Settings API that is actually friendlier and easier to use. Decouple data store from where and how the settings are presented to a user.

$token-symbols: (
adx: '<svg xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle cx="16" cy="16" r="16" fill="#1B75BC"/><path fill="#FFF" d="M11.587 8.602L16 13.208l4.305-4.606L23 11.36 18.604 16 23 20.603l-2.695 2.793L16 18.792l-4.413 4.604L9 20.68l4.36-4.706L9 11.36l2.587-2.757zm.355-.376L15.982 4l4.04 4.226-2.126 2.265-1.914-2.114-1.914 2.114-2.126-2.265zm0 15.548l2.126-2.265 1.914 2.114 1.914-2.114 2.126 2.265L15.982 28l-4.04-4.226z"/></g></svg>',
ae: '<svg xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle cx="16" cy="16" r="16" fill="#DE3F6B"/><path fill="#FFF" fill-rule="nonzero" d="M9.752 11h.904c1.413.134 2.72.821 3.687 1.81 2.009 2.039 3.113 4.916 5.67 6.433 1.848 1.097 4.433.2 5.341-1.654.462-.008.927-.008 1.389-.006-.636 1.883-2.489 3.236-4.515 3.417h-.746c-1.247-.1-2.46-.564-3.403-1.366-1.37-1.123-2.25-2.664-3.315-4.036-.916-1.213-1.85-2.577-3.366-3.128-1.873-.679-4.16.383-4.843 2.187-.6 1.486-.112 3.328 1.23 4.28 1.006.752 2.407 1.033 3.615.

RFM69_initialise

  • Set MY_RFM69_POWER_PIN mode to OUTPUT, if defined.

  • Power up the radio RFM69_powerUp().

  • Reset radio module, if MY_RFM69_RST_PIN is defined.

  • Configure radio:

@kasparsd
kasparsd / filter.php
Created November 25, 2018 08:49
Contact Form 7 Lead info with country support for Storage for Contact Form 7
<?php
add_filter( 'wpcf7_special_mail_tags', function( $output, $name ) {
if ( 'tracking-info' === $name && function_exists( 'wpshore_wpcf7_before_send_mail' ) ) {
$replaced = wpshore_wpcf7_before_send_mail( array( 'body' => '[tracking-info]' ), null, null );
return $replaced['body'];
}
return $output;
}, 10, 2 );