Skip to content

Instantly share code, notes, and snippets.

Avatar

Kamaro Lambert kamaroly

View GitHub Profile
@kamaroly
kamaroly / sortTable.js
Last active Jul 27, 2020
A very simple light weight Vanilla Javascript HTML Table sorter
View sortTable.js
/**
* Sort an HTML TABLE IN DOM element
* @usage 1) add #sortable-table-input id to your input and listen to onkeyup event
Example: <input id="sortable-table-input" onkeyup="sortTable()" />
2) Add #sortable-table id to your HTML table
* @return
*/
function sortTable() {
// Declare variables
var input, filter, table, tableRow, index, rowTextValue;
@kamaroly
kamaroly / single-table-permission-mysql.sql
Created Jul 10, 2020
Setting single table permission in mysql
View single-table-permission-mysql.sql
GRANT SELECT ON ceb.loans TO user@'%';
FLUSH PRIVILEGES;
@kamaroly
kamaroly / GoogleSheetMySqlConnection.js
Last active Jun 16, 2020
This Gits help you connect to your MySql Database from google sheet, Make surey ou whitelist google IPs ( see the list here https://developers.google.com/apps-script/guides/jdbc#creating_other_database_connections) then go to Tools > Scripts Editor
View GoogleSheetMySqlConnection.js
var server = "Your DATABASE HOST";
var databaseName = "DATABASE NAME";
var username = "password";
var password = "Username";
var port = 3306;
/**
* Open network to Database
*/
function openConnection() {
@kamaroly
kamaroly / EloquentRoutePaths.php
Last active Jun 23, 2020
This trait adds path to your eloquent model ( $article->edit_path, $article->show_path, $article->update_path,$article->destroy_path).
View EloquentRoutePaths.php
<?php
use Exception;
trait EloquentRoutePaths {
/**
* Actions that are allowed to be performed on this
* Model
* @var array
*/
@kamaroly
kamaroly / EloquentRoutePaths.php
Created Jan 27, 2020
This trait adds path to your eloquent model ( $article->edit_path, $article->show_path, $article->update_path,$article->destroy_path)
View EloquentRoutePaths.php
use Exception;
trait EloquentRoutePaths {
/**
* Actions that are allowed to be performed on this
* Model
* @var array
*/
protected $actions = ['show','edit','update','destroy'];
@kamaroly
kamaroly / elegant-dashboard-with-chartjs.html
Created Aug 22, 2019
This script is configured to make your chartjs line chart looks elegant.
View elegant-dashboard-with-chartjs.html
<div class="card col-md-8">
<div class="cart-header">
<span class="card-title">Today </span>
<span class="dot dot-red"></span> Line red: <span class="text-red-600"> 0 RWF</span>
<span class="dot dot-yellow"></span> Line green: <span class="text-yellow-600"> 0 RWF </span>
</div>
<div class="card-body">
<canvas id="transactionsChart" ></canvas>
@kamaroly
kamaroly / phpunit.xml
Last active May 27, 2019
WordPress plugin phpunit.xml for easy unit testing in WordPress plugin development. Put your tests in `tests` folder in your plugins
View phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../../wp-load.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
@kamaroly
kamaroly / Extract numbers from Text or String
Created Apr 30, 2019
This is an excel formula helps you extract numbers only from text. Replace E2 with cell that has text mixed with number For a text like "We have 17 students" it will return 17
View Extract numbers from Text or String
=SUMPRODUCT(MID(0&E2, LARGE(INDEX(ISNUMBER(--MID(E2, ROW(INDIRECT("1:"&LEN(E2))), 1)) * ROW(INDIRECT("1:"&LEN(E2))), 0), ROW(INDIRECT("1:"&LEN(E2))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(E2)))/10),
@kamaroly
kamaroly / wp.sh
Created Feb 21, 2019 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
View wp.sh
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
@kamaroly
kamaroly / WooCommerce-api-call-method.php
Last active Feb 18, 2019
Call external API using WordPress / WooCommerce
View WooCommerce-api-call-method.php
/**
* Call external API
* @param string $endPoint
* @param array $data
* @param array $headers
* @return OBJECT
*/
function callApi($data,$headers,$endPoint='wp-json/wc/v2/orders',$method='POST'){
return wp_remote_post( home_url($endPoint), array(
You can’t perform that action at this time.