Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
@mikeschinkel
mikeschinkel / chat.md
Created December 23, 2022 09:53
My Discussion with ChatGPT asking it to find ways to hold Fox News accountable for their spreading of misinformation.

How to Combat Misinformation in the US, especially Fox News?

Me

Explain how to require Fox News to limit itself to factual reporting without violating the 1st amendment to the US Constitution that guarantees free speech.

ChatGPT

It is not possible for the government or any other entity to require Fox News or any other news organization to limit itself to factual reporting without violating the First Amendment to the United States Constitution, which guarantees freedom of speech. The First Amendment protects the freedom of the press to report on issues and events as they see fit, even if their reporting is not always factual or unbiased.

However, there are ways to encourage news organizations to strive for accuracy and factual reporting. One way is through the use of media literacy education, which helps individuals develop the critical thinking skills needed to evaluate the accuracy and reliability of different sources of information. This can help people to identify and avoid sources of misinforma

@mikeschinkel
mikeschinkel / log.txt
Created May 6, 2019 19:53
Raw grep file for WordPress plugins having 'wp_edit_nav_menu_walker' hook as of 2019-05-05
add-to-menus-lite/index.php: add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
advanced-custom-fields/includes/forms/form-nav-menu.php: add_filter('wp_edit_nav_menu_walker', array($this, 'wp_edit_nav_menu_walker'), 10, 2);
advanced-custom-fields/includes/forms/form-nav-menu.php: * wp_edit_nav_menu_walker
advanced-custom-fields/includes/forms/form-nav-menu.php: function wp_edit_nav_menu_walker( $class, $menu_id = 0 ) {
affilicious/vendor/htmlburger/carbon-fields/core/Container/Nav_Menu_Container.php: add_filter( 'wp_edit_nav_menu_walker', array( $self, 'edit_walker' ), 10, 2 );
agp-font-awesome-collection/classes/MenuIcons.php: add_filter( 'wp_edit_nav_menu_walker', array( $this, 'editWalker'), 10, 2 );
amnav-menu-control/inc/class.aMNav_Menu_Control.php: add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
apollo13-framework-extensions/features/mega-menu.php:add_filter( 'wp_edit_nav_menu_walker', 'a13fe_admin_change_walker_class', 10, 2
<?php
/*
* Example code showing how to hook WordPress to add fields to the taxonomny term edit screen.
*
* This example is meant to show how, not to be a drop in example.
*
* This example was written in response to this question:
*
* http://lists.automattic.com/pipermail/wp-hackers/2010-August/033671.html
*
@mikeschinkel
mikeschinkel / StringLiteralsAreAPITA.md
Last active June 22, 2022 01:09
Managing String Literals is a PITA, not just in GoLang but in (All?) Other Languages

Managing String Literals is a PITA,
Not Just in GoLang but in (All?) Other Languages

When working in Go, or Bash, or PHP, or any other language for that matter I find one of the most tedious tasks that are also very error prone is management of literal strings.

AFAIK no programming language has addressed this head on, ever. If I am right about that, it would be great if Go was the first.

Literal String Management

Management of literal strings occurs especially with URLs and local paths, but also with many other values that end up as literals used in source code. And there is not one good way to handle them, only several different ways all with major cons, and so developers are all over the map in how they handle string literals.

One approach is for a developer to assign a string literals to a named constant, and then use that name constant wherever the value is needed, e.g.:

SELECT name
FROM sqlite_master
where type = 'table'
# crime_scene_report
# drivers_license
# person
# facebook_event_checkin
# interview
# get_fit_now_member
@mikeschinkel
mikeschinkel / list-custom-post-type-posts-with-ajax.PHP
Created November 13, 2010 10:04
Shows how to create a widget with a dropdown list of posts for a given post type and then retrieve HTML specific to the selected post via AJAX to insert into the page.
<?php
/*
List_Custom_Post_Type_Posts_with_AJAX class.
Shows how to create a widget with a dropdown list of posts for a given post type and
then retrieve HTML specific to the selected post via AJAX to insert into the page.
Yes, the name of the class is insanely long in hopes that you'll be forced to think
about what would be a better name.
@mikeschinkel
mikeschinkel / functions.php
Created June 5, 2016 20:36
Example of how to use WordPress' wp_localize_script() script to provide number of page children to a jQuery script
<?php
// Your other your-theme/functions.php code goes here
add_action( 'wp_enqueue_scripts', 'yoursite_enqueue_scripts' );
function yoursite_enqueue_scripts() {
global $post;
if ( ! empty( $post ) && is_page( $post ) ) {
wp_enqueue_script( 'yoursite-js', get_stylesheet_directory_uri() . '/js/yoursite.js');
<?php
/*
Plugin Name: WP Active Plugins Data
Plugin URI: http://mikeschinkel.com/wordpress-plugins/wp-active-plugins-data/
Description: Loads Plugin Data on Plugin Activation and Persists to wp_options for quick retrieval.
Version: 0.1
Author: Mike Schinkel
Author URI: http://mikeschinkel.com
Note: Written for http://wordpress.stackexchange.com/questions/361/is-there-a-way-for-a-plug-in-to-get-its-own-version-number
*/
@mikeschinkel
mikeschinkel / _README.md
Last active April 9, 2022 04:15
Potential update to GoLang `encoding/csv`. Provides a ReadFunc() method that allows tweaking the logic for processing a CSV file.

Making encoding/csv.Reader extensible

The simple idea behind these potential modifications is to add a function csv.ReadFunc() that can be passed a csv.LogicFunc when called where the signature of the passed closure and related type and consts would be.

In this case there is really only one evalation needed, but there could easily be multiple in other use-cases.

@mikeschinkel
mikeschinkel / _readme.md
Last active April 6, 2022 17:33
Potential approach for streamlined error handling in Go

Proposal for Streamlined Error Handling in Go

This is a proposal for a way to simplify the error handling in Go.

The idea is to use attempt{} and recover{} blocks to separate the happy path from the error handling. NOTE: this is NOT exception handling as you would see in Java or PHP. More on why below.

In this proposal Go would allow the developer to omit capturing the last returned variable from a function call if and only if that call was within a attempt{} block. The Go compiler would handle providing access to the error instance via the geterror() function within the recover{} block if any function returns a non nil error as its last omitted parameter, i.e.:

attempt{
 data:= GetData()