Skip to content

Instantly share code, notes, and snippets.

View leepeterson's full-sized avatar
:octocat:

Lee Peterson leepeterson

:octocat:
View GitHub Profile
@shubhamsre
shubhamsre / 1_kubernetes_on_macOS.md
Created October 15, 2020 04:36 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@ravewebdev
ravewebdev / update-block.js
Last active October 11, 2020 07:30
4.2. Perform Request and Update Block
const FrontendTracker = ( props ) => {
// Add the following in place of the `return` statement from Part 1, step 2.1.
const saveUpdates = async () => {
setLoading( true );
setNotice( null );
const response = await apiFetch( {
path: `${initTracker.route}/${ dataAttributes.post_id }`,
method: 'POST',
@ravewebdev
ravewebdev / component-state.js
Last active October 11, 2020 07:30
4.1. Handle Component State
const FrontendTracker = ( props ) => {
// Add the following before the `return()` block from Part 1, step 2.1.
const [ isLoading, setLoading ] = useState( false );
const [ notice, setNotice ] = useState( null );
useEffect( () => {
if ( null === notice ) {
return;
}
@ravewebdev
ravewebdev / localize-route.php
Last active October 11, 2020 07:30
3.2. Localize Route and Create Nonce
<?php
function localize_route() {
wp_localize_script( 'initiative-tracker-frontend-script', 'initTracker', [
'route' => 'rave-initiative/v1/initiative',
] );
}
add_action( 'wp_enqueue_scripts', 'localize_route' );
@ravewebdev
ravewebdev / block-replacement.js
Last active October 11, 2020 07:30
2.2. Static Block Replacement
const trackerClass = '.wp-block-rave-initiative-tracker',
trackers = document.querySelectorAll( trackerClass );
trackers.forEach( ( tracker ) => {
const attributes = {
block_id: tracker.dataset.id,
post_id: parseInt( tracker.dataset.post_id, 10 ),
};
render(
@mtunjic
mtunjic / disable.sh
Last active March 31, 2024 18:12
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@aramoudi
aramoudi / 000-my-supplement.md
Last active September 28, 2019 16:07
[React snippets] from Udacity Nanodegree #React

Udacity HTML, CSS, JS Style Guide

  • A good function should follow the "DOT" rule:

    • Do One Thing
  • Composition is to combine simple functions to build more complicated ones

    • React builds up pieces of a UI using components.
      • كل فنكشن ترجع UI
  • Declarative code vs imperative code

@leepeterson
leepeterson / restapi.txt
Created July 17, 2019 04:17 — forked from chrismccoy/restapi.txt
WordPress REST API Resources
Allow ALL cross origin requests to WordPress REST API
https://github.com/Shelob9/rest-all-cors
WordPress theme using Rest API and Vue.js
https://github.com/rtCamp/VueTheme
WordPress Post from Front End using REST API and Vue.js
http://jimfrenette.com/2017/01/post-from-front-end-wp-api-vuejs/
An offline-first SPA using Vue.js, the WordPress REST API and Progressive Web Apps
<?php
/**
* Filters wp_remote_get() to:
* 1. Return a value from the cache when it's available.
* 2. Write a value to the cache when it's been fetched.
*
* Requires the WP_IMPORT_CACHE constant to be set to a writable directory.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
@Billz95
Billz95 / .php_cs.dist
Last active January 15, 2024 02:58
A Customised fixer for PHP-CS-Fixer to use `prettier`'s php plugin to pre-process the code before getting analysed by other fixers. This would enable `php-cs-fixer` to take advantage of `prettier`'s ability of managing long line.
<?php
require_once __DIR__.'/relative/path/to/PrettierPHPFixer/File';
return PhpCsFixer\Config::create()
->registerCustomFixers([
(new PrettierPHPFixer()),
])
->setRules([
'Prettier/php' => true,