Skip to content

Instantly share code, notes, and snippets.

View amirulasyraf88's full-sized avatar
🎯
Focusing For Brain Damage

Amirul Asyraf Mohamed Azam amirulasyraf88

🎯
Focusing For Brain Damage
View GitHub Profile
#include<cmath>
#include<iostream>
#include<climits>
using namespace std;
int Maximum_Sum_Subarray(int arr[],int n) //Overall Time Complexity O(n)
{
int ans = A[0],sum = 0;
for(int i = 1;i < n; ++i) //Check if all are negative
ans = max(ans,arr[i]);
@amirulasyraf88
amirulasyraf88 / chart.vue
Created July 18, 2019 09:58 — forked from rvanzon/nuxt.config.js
A way to use vue-chartjs as a plugin of Nuxt.js
// just an example. A cleaner way is to wrap the showLine-stuff in a dedicated component
<template>
<div>
<my-line v-if="showLine" :data="lineData" :options="options">
</div>
</template>
<script>
export default {
data () {
#!/bin/bash
# please refer to https://github.com/nawawi/nginx-cache-data/blob/master/nginx-proxy-cache-data.sh
cat /tmp/nginx-proxy-cache-data/data-file-cache.txt |grep -v ^# |tr -s '|' ' ' |while read _host _size _url; do
_purge="$(echo $_url|sed -e "s/$_host/${_host}\/purge/g")";
_output="$(curl -s -H "Host: ${_host}" ${_purge}*)";
echo $_output;
done
@amirulasyraf88
amirulasyraf88 / wc-filter-product-shipping-weight
Created March 26, 2020 08:58 — forked from vanbo/wc-filter-product-shipping-weight
WooCommerce: Filter a product shipping weight
// Filters both variations and simple products with the same function
add_filter( 'woocommerce_product_variation_get_weight', 'filter_product_weight', 10, 2 );
add_filter( 'woocommerce_product_get_weight', 'filter_product_weight', 10, 2 );
/**
* @param float $weight
* @param WC_Product $product
*
* @return int
*/
function filter_product_weight( $weight, $product ) {
@amirulasyraf88
amirulasyraf88 / endo-handling-fee.php
Created July 23, 2020 07:51 — forked from greenhornet79/endo-handling-fee.php
Add percentage based fee to WooCommerce cart
<?php
add_action( 'woocommerce_cart_calculate_fees','endo_handling_fee' );
function endo_handling_fee() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$subtotal = $woocommerce->cart->subtotal;
$fee_percentage = 0.1; // 10 percent