Skip to content

Instantly share code, notes, and snippets.

View nirjharlo's full-sized avatar
👨‍💻
Working from Home

Nir nirjharlo

👨‍💻
Working from Home
View GitHub Profile
@nirjharlo
nirjharlo / gist:51d9b4259b9b461260c3b83268242927
Created February 23, 2024 13:41 — forked from troelskn/gist:1287893
Luhn's algorithm in php
<?php
function is_valid_luhn($number) {
settype($number, 'string');
$sumTable = array(
array(0,1,2,3,4,5,6,7,8,9),
array(0,2,4,6,8,1,3,5,7,9));
$sum = 0;
$flip = 0;
for ($i = strlen($number) - 1; $i >= 0; $i--) {
$sum += $sumTable[$flip++ & 0x1][$number[$i]];
@nirjharlo
nirjharlo / google-cloud-storage-upload-download.php
Created October 25, 2021 16:43 — forked from stetic/google-cloud-storage-upload-download.php
PHP Example for Google Storage Upload and Download with Google APIs Client Library for PHP
<?php
/*
* PHP Example for Google Storage Up- and Download
* with Google APIs Client Library for PHP:
* https://github.com/google/google-api-php-client
*/
include( "Google/Client.php" );
include( "Google/Service/Storage.php" );
@nirjharlo
nirjharlo / google-example.php
Created November 13, 2019 07:45 — forked from fillup/google-example.php
Example of using Google Admin SDK Directory API to get an individual or list of users.
<?php
// Updated 2018-01-24 to work with google/apiclient:^2.0
/*
* Easiest to use composer to install google-api-php-client and generate autoloader
* If you dont want to use composer you can manually include any needed files
*/
include_once 'vendor/autoload.php';
/*
* Email address for admin user that should be used to perform API actions
@nirjharlo
nirjharlo / wp-query-ref.php
Created November 7, 2019 06:34 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@nirjharlo
nirjharlo / api.php
Last active March 19, 2017 11:32
WordPress API integration, the easy way.
<?php
/**
*
*
* Implimentation of WordPress inbuilt API class
*
* Just include this class and edit it to customize
* and call "$api = new myPluginNameAPI();" to use API connect.
*
* $api->endpoint = 'endpoint_url'
@nirjharlo
nirjharlo / database.php
Last active March 16, 2017 13:04
WordPress database install for custom tables
<?php
/**
*
*
* Implimentation of WordPress inbuilt db class
*
* Just include this class and edit it to customize
* and call "new myPluginNameDbTables();" to install db tables.
*
* Helpful for building WordPress plugin quickly.
@nirjharlo
nirjharlo / widget.php
Created March 16, 2017 08:07
WordPress Widget class for adding custom widgets
<?php
/**
*
*
* Implimentation of WordPress inbuilt Widget class
*
* Just include this class and edit it to customize
* and call "new myPluginNameWidget();" to create a widget.
*
* Helpful for building WordPress plugin quickly.
@nirjharlo
nirjharlo / metabox.php
Created March 16, 2017 07:55
WordPress metabox class to edit on post-type edit screens
<?php
/**
*
*
* Implimentation of WordPress inbuilt Metabox process
*
* Just include this class and edit it to customize
* and call "new myPluginNameMetBox();" to create a metabox.
*
* Helpful for building WordPress plugin quickly.
@nirjharlo
nirjharlo / table.php
Last active March 11, 2017 14:40
WordPress Table class extnding default
<?php
/**
*
*
* Implimentation of WordPress inbuilt functions for creating
* an extension of a default table class.
*
* Just include this class and edit it to customize and call when loading table
*
* $myPluginNameTable = new myPluginNameTable();
@nirjharlo
nirjharlo / ajax.php
Created March 10, 2017 15:33
WordPress AJAX class
<?php
/**
*
*
* Implimentation of WOrdPress inbuilt AJAX process
*
* Just include this class and edit it to customize
* and call "new myPluginNameAjax();" to setup a AJAX call.
*
* Helpful for building WordPress plugin quickly.