Skip to content

Instantly share code, notes, and snippets.

View moon0326's full-sized avatar

Moon moon0326

  • Automattic
  • Los Angeles
View GitHub Profile
<?php
/**
* Plugin Name: WooCommerce Calypso Bridge Helper
* Plugin URI: https://woocommerce.com
* Description: Utility to assist testing wc-calypso-bridge locally
* Author: WooCommerce
* Version: 0.1
*/
class Atomic_Plan_Manager {
@moon0326
moon0326 / rest-route-finder.php
Last active May 23, 2022 02:22
Find WP Rest Route Callback by an URL
<?php
/**
* Plugin Name: REST Routes CLI
* Version: 0.0.1
*/
defined( 'ABSPATH' ) || exit;
function routes_match( $args ) {
$routes = rest_get_server()->get_routes();
class aController {
private $service;
public function __construct(aService $service) {
$this->service = $service;
}
public function get_items() {
return $this->service->get_items();
}
@moon0326
moon0326 / dataview-polyfill.js
Created March 4, 2016 02:58
DataView (and ArrayBuffer) polyfill that works in any engine (including old IE).
void function(global){
if ('DataView' in global && 'ArrayBuffer' in global) {
return;
}
var hide = (function(){
// check if we're in ES5
if (typeof Object.getOwnPropertyNames === 'function' && !('prototype' in Object.getOwnPropertyNames)) {
var hidden = { enumerable: false };
@moon0326
moon0326 / gist:8420e1a4c0a6363c0f45
Last active August 29, 2015 14:18
List of HTML Editors
http://madebymany.github.io/sir-trevor-js/
https://github.com/mduvall/grande.js
https://github.com/daviferreira/medium-editor
@moon0326
moon0326 / gist:6421728c45a87a622ed4
Last active August 29, 2015 14:14
Simple IoC Container
<?php
class Container
{
protected $index = array();
public function make($abstract)
{
if ($this->has($abstract)) {
return $this->resolve($this->index[$abstract]);
@moon0326
moon0326 / gist:35becfa058e4358272c0
Last active August 29, 2015 14:14
Simple PHP DI
<?php
class Container
{
protected $index = array();
const TYPE_SINGLETON = 'singleton';
const TYPE_INSTANCE = 'instance';
const TYPE_BIND = 'bind';
@moon0326
moon0326 / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console