Skip to content

Instantly share code, notes, and snippets.

@lukecarbis
lukecarbis / gpt-clock-poem.html
Last active March 22, 2023 15:26
An HTML widget that asks the GPT-3.5 model for a short poem about the current time.
<script>
const url = "https://api.openai.com/v1/chat/completions";
const apiKey = "YOUR OpenAI API KEY GOES HERE";
fetchPoem();
setInterval(runCodeOnMinute, 1000);
function fetchPoem() {
const xhr = new XMLHttpRequest();
xhr.open("POST", url);
# ack is a tool like grep, designed for programmers with large trees of heterogeneous source code
# To install ack, see http://betterthangrep.com/
# To use ack, launch terminal (mac osx) and type 'ack <some_keywords>'
# ack will search all files in the current directory & sub-directories
# Always color, even if piping to a another program
--color
# Ignore some directories
@lukecarbis
lukecarbis / monster-block.json
Created November 7, 2019 00:07
A huge block with all controls in a variety of configurations, for testing Block Lab.
{
"block-lab\\/monster-block": {
"name": "monster-block",
"title": "Monster Block",
"excluded": [],
"icon": "whatshot",
"category": {
"slug": "monster",
"title": "Monster",
"icon": null
Verifying my Blockstack ID is secured with the address 1Mh2ZHBa4mwbMJv2TcbreXnpAKVsDHXuSw https://explorer.blockstack.org/address/1Mh2ZHBa4mwbMJv2TcbreXnpAKVsDHXuSw
<?php
/**
* Custom block to create a gallery based on image folder in uploads.
*
* @package Block Lab
*/
?>
<div class="singlepost__media__image has-pswp">
<?php
@lukecarbis
lukecarbis / class-my-block-plugin.php
Last active April 8, 2019 21:32
Using Block Lab in a Plugin
class My_Block_Plugin {
/**
* Register any hooks that this component needs.
*/
public function __construct() {
add_filter( 'block_lab_template_path', array( $this, 'template_path' ) );
}
/**
* Include the plugin's blocks folder in the template path.
@lukecarbis
lukecarbis / block-colour-picker.php
Last active January 4, 2019 06:37
Colour Picker template for Block Lab
<?php
$field = 'colour-picker';
$color = block_value( $field );
if ( '#' === substr( $color, 0, 1 ) ) {
$rgb = str_split( str_replace( '#', '', $color ), 2 );
$r = hexdec( $rgb[0] );
$g = hexdec( $rgb[1] );
$b = hexdec( $rgb[2] );
} elseif ( 'rgb' === substr( $color, 0, 3 ) ) {
@lukecarbis
lukecarbis / VRPC.md
Last active January 23, 2018 00:28
ITX VR PC, with i5 vs i7 and 1080 vs 1080ti options

Purchased:

  • Motherboard (eBay)
  • CPU (eBay)
  • GPU (eBay)
  • PSU (Umart)
  • RAM (Umart)
  • SSD (Umart)
  • CPU Cooling (eBay)
  • Case (PC Case Gear)
  • VR System (eBay)
<?php
$weightings_file = 'https://raw.githubusercontent.com/xwp/wp-tide/develop/services/audit-server/audit-weightings/phpcs/tide/weightings.json';
$markdown_file = 'weightings.md';
if ( isset( $argv[1] ) ) {
$weightings_file = $argv[1];
}
if ( isset( $argv[2] ) ) {
$markdown_file = $argv[2];
@lukecarbis
lukecarbis / wp-setup.sh
Last active October 17, 2017 20:42
Setup script for a new WordPress site
#!/bin/bash
wp plugin install jetpack theme-check user-switching gutenberg
wp plugin install akismet debug-bar stream --activate
wp core update
wp plugin update --all
wp theme update --all
wp comment delete 1
wp post delete 1
wp post delete 2
wp rewrite structure '/%postname%/'