Skip to content

Instantly share code, notes, and snippets.

View anhskohbo's full-sized avatar
🎯
Focusing

Van anhskohbo

🎯
Focusing
View GitHub Profile
@anhskohbo
anhskohbo / handleOrientation.html
Created March 23, 2021 03:56
handleOrientation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
<?php
abstract class Node implements JsonSerializable
{
/**
* @var string
*/
public string $id;
/**
<?php
// Paste this code into your theme/functions.php
add_action( 'abrs_countries_dataset', function ( $countries ) {
$top = [ 'VN', 'US' ];
uasort( $countries, function ( $country1, $country2 ) use ( $top ) {
$top = array_reverse( $top );
$priority1 = array_search( $country1['alpha2'], $top );
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/tests/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<!-- How to scan -->
@anhskohbo
anhskohbo / functions.php
Last active August 20, 2018 05:53
Custom rate
add_action( 'abrs_setup_room_rate', function ( $room_rate ) {
/* @var $room_rate \AweBooking\Availability\Room_Rate */
$request = $room_rate->get_request();
$request_adults = $request
->get_guest_counts()
->get_adults()
->get_count();
if ( ( $extra_adults = $request_adults - 1 ) > 0 ) {
@anhskohbo
anhskohbo / Laravel-Container.md
Created April 3, 2018 15:02
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@anhskohbo
anhskohbo / Multidimensional.php
Last active January 4, 2018 15:57
CMB2 With Multidimensional Support
<?php
class Multidimensional {
/**
* Return item in array with multidimensional support.
*
* @param array $array
* @param string $keys
* @param mixed $default
* @return string
@anhskohbo
anhskohbo / content-single-product.php
Created June 25, 2016 18:06 — forked from georgybu/content-single-product.php
WooCommerce - Show next\prev products from current product category (when viewing a single product) 1. If product is last -> Next product is first 2. If product is first -> Prev product is last forked from https://gist.github.com/2176823 (This question was in http://stackoverflow.com/questions/13597687/woocommerce-get-next-previous-product/13612387
<?php
// get next and prev products
// Author: Georgy Bunin (bunin.co.il@gmail.com)
// forked from https://gist.github.com/2176823
function ShowLinkToProduct($post_id, $categories_as_array, $label) {
// get post according post id
$query_args = array( 'post__in' => array($post_id), 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
array(
'taxonomy' => 'product_cat',
@anhskohbo
anhskohbo / jekyll-installer.sh
Last active November 27, 2016 14:02
Homestead + Jekyll For Frontend
#!/bin/bash
# Install Ruby v2.3.0
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz
tar -xvzf ruby-2.3.0.tar.gz
cd ruby-2.3.0/
./configure --prefix=/usr/local