Skip to content

Instantly share code, notes, and snippets.

View ilyasfoo's full-sized avatar

Ilyas Foo ilyasfoo

View GitHub Profile
@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();
<?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
*/
function woocommerce_ecommplan_helper_handler() {
@octaedro
octaedro / woocommerce-notes-testing.php
Last active April 9, 2021 03:44
Adds 4 new notes with layout: banner, thumbnail, and plain, OR sets all the notes to not deleted. One of those notes is a StoreAlert. Now also adds an email note after pressing `Add Email Notes`.
<?php
/**
* Plugin Name: WooCommerce Prepare Notes Testing
* Plugin URI: https://woocommerce.com
* Description: Adds 4 new notes with layout: banner, thumbnail, and plain, OR sets all the notes to not deleted. One of those notes is a StoreAlert. Now also adds an email note after pressing `Add Email Notes`.
* Author: WooCommerce
* Domain Path: /test_notes
* Version: 0.4
*/
@nasrulhazim
nasrulhazim / syaiton.php
Created June 1, 2018 00:32
Syaiton Detector
<?php error_reporting(E_ALL ^ E_NOTICE); ?>
<?php $keyboard_warriors = $_REQUEST['keyboard_warriors']; ?>
<?php
$keyboard_warriors = [
[
'name' => 'J-bon',
'post' => 'Hutang 600 juta',
],
[
'name' => 'Mira 01',
@angch
angch / malaysia.districts.geojson
Created March 31, 2017 11:22
geojson of malaysia's districts (mukim) converted from gadm.org for convenience
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gylaz
gylaz / rate_limit_post.md
Last active July 19, 2023 09:45
Handling API Rate Limits with Delayed::Job

Has your app ever encountered a 429 (Too Many Requests) status code when making requests to a third-party API? Getting rate limited can be a nussance and if not handled properly can cause a bad experience for you and your users. While one solution is to catch the exception and ignore it, a better solution is to retry the request.

Let's take a look at how we can alleviate rate-limiting woes by utilizing a background job system. In this example we'll use delayed_job, since it provides the ability to retry failed jobs.

Let's pretend that we are going to be accessing the API of a popular website. Let's setup a background job that makes a request to that API.

class MyCustomJob < Struct.new(:param1, :param2)
  def perform
 PopularSiteApi.get('/posts')