Skip to content

Instantly share code, notes, and snippets.

Avatar

Kabue Charles McKabue

View GitHub Profile
@McKabue
McKabue / Promise.cs
Created Aug 21, 2020 — forked from dbones/Promise.cs
C# Promises (again because i can), note this is not A+ standard, but functions similar to it
View Promise.cs
namespace Promise.CommandLine
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
@McKabue
McKabue / apache-permission.sh
Last active Jul 13, 2020 — forked from v1shwa/apache-permission.sh
Ubuntu: Fix for Permissions denied on /var/www/html
View apache-permission.sh
# 1. Change owner of /var/www/html directory to apache user, here: www-data.
sudo chown -R www-data:www-data /var/www/html
# 2. Allow Group to edit.
sudo chmod -R 775 /var/www/html
# 3. Add yourself to apache group(www-data).
sudo usermod -a -G www-data ${USER}
# 4. Reboot to effect the permissions.
View turn-off-webpack-code-splitting.md

How to turn off Webpack code-splitting

Using Webpack import()

The following code will produce code-splitting in Webpack, which means that the source code will be split into several files that will be loaded async at runtime.. More info here;

import('./some-module').then((SomeModule) => {});
@McKabue
McKabue / cloudflare-delete-all-records.sh
Created May 22, 2020 — forked from slayer/cloudflare-delete-all-records.sh
Delete all DNS records for specified zone
View cloudflare-delete-all-records.sh
#!/bin/bash
EMAIL=me@gmail.com
KEY=11111111111111111111111111
ZONE_ID=2222222222222222222222222
curl -X GET https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records?per_page=500 \
-H "X-Auth-Email: ${EMAIL}" \
-H "X-Auth-Key: ${KEY}" \
-H "Content-Type: application/json" | jq .result[].id | tr -d '"' | (
@McKabue
McKabue / debug-android-from-terminal.sh
Last active Feb 8, 2020
This script allows to debug android with adb commands in terminal easily, with one or many devices/emulators: See blog at https://dev.to/mckabue/connect-debug-android-with-adb-android-debug-bridge-commands-in-terminal-easily-with-one-or-many-devices-emulators-1g1o
View debug-android-from-terminal.sh
#!/bin/bash
devices=(`adb devices | grep -v devices | grep device | cut -f 1`)
devicesCount=${#devices[@]}
devicesToUse=()
if [ $devicesCount -eq 0 ]
then
echo "No attached devices.";
elif [ $devicesCount -eq 1 ]
@McKabue
McKabue / adb+
Created Jan 30, 2020 — forked from christopherperry/adb+
A bash script that let's you issue adb commands to multiple devices at once
View adb+
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
@McKabue
McKabue / flush-dns.sh
Created Mar 27, 2019 — forked from craigvantonder/flush-dns.sh
Flushing the DNS in Ubuntu 16.04
View flush-dns.sh
#!/bin/bash
# NB: First install nscd with sudo apt-get install nscd
# run this command to flush dns cache:
sudo /etc/init.d/dns-clean restart
# or use:
sudo /etc/init.d/networking force-reload
# Flush nscd dns cache:
sudo /etc/init.d/nscd restart
@McKabue
McKabue / clearRAM.sh
Created Jan 14, 2019 — forked from pklaus/clearRAM.sh
A Script to Clear Cached RAM on Linux
View clearRAM.sh
#!/bin/bash
## Bash Script to clear cached memory on (Ubuntu/Debian) Linux
## By Philipp Klaus
## see <http://blog.philippklaus.de/2011/02/clear-cached-memory-on-ubuntu/>
if [ "$(whoami)" != "root" ]
then
echo "You have to run this script as Superuser!"
exit 1
fi
@McKabue
McKabue / RequestResponseLoggingMiddleware.cs
Last active Jul 16, 2019
An ASP.NET CORE Request - Response Logger Middleware
View RequestResponseLoggingMiddleware.cs
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.IO;
// https://exceptionnotfound.net/using-middleware-to-log-requests-and-responses-in-asp-net-core/
// https://gist.github.com/elanderson/c50b2107de8ee2ed856353dfed9168a2
@McKabue
McKabue / C# Email Validator.cs
Created Oct 14, 2018
This handy extention validates email address with and without a display name. e.g: `Kabue Charles <me@mckabue.com>` and `me@mckabue.com`
View C# Email Validator.cs
/// <summary>
/// https://stackoverflow.com/a/1374644
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
public static bool IsValidEmail(this string email)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
You can’t perform that action at this time.