Skip to content

Instantly share code, notes, and snippets.

View jaysonmulwa's full-sized avatar
👤
Building

Jayson Mulwa jaysonmulwa

👤
Building
View GitHub Profile
@jaysonmulwa
jaysonmulwa / thin_space.php
Created September 17, 2023 15:41 — forked from hopeseekr/thin_space.php
ASCII Space vs UTF-8 Thin Space in PHP
<?php
/** See it live: https://onlinephp.io/c/551a0 **/
$helloWorld = [
'ascii' => 'Hello, World!',
'utf-8' => 'Hello, World!',
];
$spacePos = strpos($helloWorld['ascii'], ' ');
@jaysonmulwa
jaysonmulwa / chmod-400.cmd
Created June 17, 2023 14:36 — forked from jaskiratr/chmod-400.cmd
Set permission of file equivalent to chmod 400 on Windows.
# Source: https://stackoverflow.com/a/43317244
$path = ".\aws-ec2-key.pem"
# Reset to remove explict permissions
icacls.exe $path /reset
# Give current user explicit read-permission
icacls.exe $path /GRANT:R "$($env:USERNAME):(R)"
# Disable inheritance and remove inherited permissions
icacls.exe $path /inheritance:r
@jaysonmulwa
jaysonmulwa / entropy.js
Created October 28, 2022 20:06 — forked from radekk/entropy.js
Calculating Shannon's entropy with JavaScript
/**
* Calculate Shannon's entropy for a string
*/
module.exports = (str) => {
const set = {};
str.split('').forEach(
c => (set[c] ? set[c]++ : (set[c] = 1))
);