Skip to content

Instantly share code, notes, and snippets.

View oddevan's full-sized avatar

Evan Hildreth oddevan

View GitHub Profile
<?php
function import_cards() {
\WP_CLI::log( 'Querying pokemontcg.io...' );
$cards = Pokemon::Card( [ 'verify' => false ] )->where( [ 'setCode' => 'sm9', 'pageSize' => 1000 ] )->all();
foreach ( $cards as $card_obj ) {
$card = $card_obj->toArray();
$hash_text = $card['name'] . implode( ' ', $card['text'] );
<?php
namespace oddEvan\TrainerDB\Content\Taxonomy;
use WebDevStudios\OopsWP\Structure\Content\Taxonomy;
class CardHash extends Taxonomy {
protected $slug = 'card_hash';
protected $object_types = [ 'card' ];
protected function get_labels() : array {
<?php
namespace oddEvan\TrainerDB\Content\PostType;
use WebDevStudios\OopsWP\Structure\Content\PostType;
class Card extends PostType {
protected $slug = 'card';
protected function get_labels() : array {
return [
<?php
namespace EPH\DAEmbed;
function register_providers() {
$callback = __NAMESPACE__ . '\handle_deviantart';
wp_embed_register_handler( 'deviantart-main', '#https://www.deviantart.com/*+#', $callback, 10 );
// Include other handlers as needed
}
<?php
/*
Plugin Name: Embed DeviantART
Description: Allow embeds from deviantART pages
Author: Evan Hildreth
Version: 1.0
*/
function eph_register_deviantart() {
@oddevan
oddevan / ubuntu-lemp-certbot.sh
Last active November 26, 2018 03:25
An interactive script to set up an Ubuntu 18.04 LTS image with LEMP, store web page files in user's home directory, and install/run certbot
#!/usr/bin/env bash
#
# THIS IS AN INTERACTIVE SCRIPT
#
# Installs a LEMP stack onto an Ubuntu 18.04 LTS image:
#
# - Creates sudo user with given username and password
# - Updates all packages
# - Installs Nginx, MySQL, and PHP
# - Runs mysql_secure_installation
@oddevan
oddevan / page-cordcut-compare.php
Created July 20, 2017 00:21
A fragment of a custom WordPress page to take the information from `eph-ccdb-suite.php` and display it in a comparison page.
<?php
function eph_get_child_tiers( $parent_id ) {
$child_tiers = array();
$child_tier_query = new WP_Query( array(
'post_parent' => $parent_id,
'post_type' => array( 'eph_ccdb_service' ),
'nopaging' => true,
'order' => 'ASC',
'orderby' => 'title',
@oddevan
oddevan / eph-ccdb-suite.php
Last active July 20, 2017 00:19
A WordPress plugin to generate a custom type and taxonomy for storing cable-like services and the channels offered by them.
<?php
/*
Plugin Name: CCDB Suite
Plugin URI: http://eph.me/cordcutdb
Description: Custom post types, taxonomies, and custom fields to enable Cordcut DB.
Author: Evan Hildreth
Version: 1.0
Author URI: http://eph.me/
*/
@oddevan
oddevan / centos-initial-lamp.sh
Last active September 30, 2021 08:00
Shell script to set up CentOS 7 server with LAMP. Must be run as root interactively.
#!/usr/bin/env bash
# This is designed to get a CentOS 7 system up and running
# from absolutely nothing. It will install the LAMP stack
# as well as RVM and Phusion Passenger
# Run this as root
yum update
@oddevan
oddevan / extractmii.rb
Created May 28, 2014 00:23
A simple ruby script to pull blocks of 74 bytes of data from a binary file. It just so happens that a Mii takes up 74 bytes of data in the library.
io = File.open('RFL_DB.dat')
io.read(4) #Burn the first 4 bytes
(1..100).each do |k|
mii = io.read(74)
break unless mii;
IO.binwrite("#{k}.miigx", mii);
end