Skip to content

Instantly share code, notes, and snippets.

View nawawi's full-sized avatar

Nawawi Jamili nawawi

View GitHub Profile
<?php
function has_with( string $haystack, $needles ) {
foreach ( (array) $needles as $needle ) {
if ( false !== strpos( $haystack, (string) $needle ) ) {
return true;
}
}
return false;
}
@nawawi
nawawi / gist:8a328a51ba115d6405a01e52a4f98df3
Created March 21, 2020 03:10 — forked from danielestevez/gist:2044589
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
#!/bin/sh
# 1) edit /etc/pam.d/sshd
# 2) append to bottom /etc/pam.d/sshd
# session optional pam_exec.so seteuid /usr/sbin/notifysshlogin
if [ "$PAM_TYPE" != "close_session" ]; then
# echo "user: {$PAM_USER} IP: {$PAM_RHOST}";
# your mail command
fi
exit
@nawawi
nawawi / redis_key_sizes.sh
Created February 12, 2020 12:03 — forked from epicserve/redis_key_sizes.sh
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
kernel.msgmnb = 65536
kernel.msgmax = 65536
# use default
#kernel.shmmax = 68719476736
#kernel.shmall = 16777216
fs.file-max = 2097152
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
net.ipv4.tcp_synack_retries = 2
#!/bin/bash
#
# hugepages_settings.sh
# https://kerneltalks.com/services/what-is-huge-pages-in-linux/
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
@nawawi
nawawi / baseurl
Last active November 12, 2019 02:16
<?php
function _basehost() {
if ( !empty($_SERVER["HTTP_HOST"]) ) {
$schema = ( !empty($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") ? "https://": "http://";
$host = $_SERVER["HTTP_HOST"];
return $schema.$host;
}
return null;
}
#!/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
@{*
Name: quotation total quantity
Date: 07082019
*}
@{* TEMPLATE SETTING *}
@{$TITLE="Quotation"}
@{$SUBJECT=""}
@{$SHOW_STATUS=true}
@{$SHOW_DISCOUNT_PERCENT=false}
#!/bin/bash
# nawawi: purge cloudflare cache
_EMAIL="";
_GLOBAL_API_KEY="";
_ZONE_ID="";
echo "";
_BUFF="$(curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${_ZONE_ID}/purge_cache" \
-H "X-Auth-Email: ${_EMAIL}" \