Skip to content

Instantly share code, notes, and snippets.

View kamaroly's full-sized avatar

Kamaro Lambert kamaroly

View GitHub Profile
@kamaroly
kamaroly / wp.sh
Created February 21, 2019 22:34 — 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!
#!/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 February 18, 2019 19:42
Call external API using WordPress / WooCommerce
/**
* 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(
@kamaroly
kamaroly / WooCommerce Auto update cart after quantity change.php
Last active October 12, 2023 16:57
Auto update cart after quantity change. You trigger the click, but the button doesn't have enough time to become enabled, so that is why, by the time you click the second time the button becomes enabled. Remove the "disabled" propriety before triggering the click. This should be added in **footer.php** of your child theme
<?php if (is_cart()) { ?>
<script type="text/javascript">
// Each time quantity in the cart changes, trigger update
// cart option
jQuery('div.woocommerce').on('change', '.qty', function(){
// Make sure the button is enabled before triggering the event
// otherwise this won't work.
jQuery("[name='update_cart']").prop("disabled", false);
jQuery("[name='update_cart']").trigger("click");
});
@kamaroly
kamaroly / footer.php
Created December 17, 2018 08:13
Auto update cart after quantity change. You trigger the click, but the button doesn't have enough time to become enabled, so that is why, by the time you click the second time the button becomes enabled. Remove the "disabled" propriety before triggering the click:
@kamaroly
kamaroly / wp-config.php
Created November 23, 2017 16:12
Multiple WordPress installation behind LoadBalancer
<?php
/**
* SET URL BASED ON THE CURRENT URL
*/
define('WP_SITEURL', $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST']); 
define('WP_HOME', $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST']);
/** OTHER WORDPRESS CONFIGURATIONS **/
@kamaroly
kamaroly / ClipboardNotification.cs
Created January 26, 2017 04:24 — forked from glombard/ClipboardNotification.cs
Monitor Clipboard changes in C# using AddClipboardFormatListener / WM_CLIPBOARDUPDATE. See Clipboard class: http://msdn.microsoft.com/en-us/library/system.windows.clipboard(v=vs.110).aspx
// from: http://stackoverflow.com/questions/2226920/how-to-monitor-clipboard-content-changes-in-c
/// <summary>
/// Provides notifications when the contents of the clipboard is updated.
/// </summary>
public sealed class ClipboardNotification
{
/// <summary>
/// Occurs when the contents of the clipboard is updated.
/// </summary>
@kamaroly
kamaroly / csvToArray.php
Last active December 28, 2016 09:21
Php method / function to convert CSV into an ARRAY
<?php
/**
* Convert CSV TO ARRAY
* @param string $filename
* @param string $delimiter
* @return
*/
function csvToArray($filename='', $delimiter=','){
if(!file_exists($filename) || !is_readable($filename))
return FALSE;
@kamaroly
kamaroly / pyrocms sortable list styles
Created December 28, 2016 06:43 — forked from james2doyle/pyrocms sortable list styles
PyroCMS sortable list styles. Because I keep forgetting the best way to get the sortable list to look/work nice.
.ui-sortable-container {
overflow: auto;
-ms-overflow-x: hidden;
overflow-x: hidden;
}
.ui-sortable {
margin: 0;
list-style: none;
}
@kamaroly
kamaroly / ajax_form_validation.js
Created December 14, 2016 09:06
When you have a laravel project with a form and you would like to make jquery ajax form submit and validation, you can use below codes,
$(function(){
$('.form-horizontal').on('click', function(e){
e.preventDefault();
var $form = $('.form-horizontal');
var url = $form.attr('action');
var method = $form.attr('method');
$.ajax({
url: url,
type: method,
data: $form.serialize(),
@kamaroly
kamaroly / Round Robin Generator
Created December 13, 2016 09:35
If you've ever been involved in chess tournaments, you would know they come in various formats, one of which is the round robin format. In a round robin, each player plays every other player, and the difference in colours is kept to a minimum, with half the field having white for one more game than the other half. I couldnt come up with a good e…
<?php
/************************************************
* Round Robin Pairing Generator
* Author: Eugene Wee
* Date: 23 May 2005
* Last updated: 23 May 2005
* Copyright (c) 2005 Eugene Wee
* Licensed under the Academic Free License 2.1
* Based on algorithm by Tibor Simko
************************************************/