Skip to content

Instantly share code, notes, and snippets.

View hakimzulkufli's full-sized avatar
💭
I may be slow to respond.

Hakim Zulkufli hakimzulkufli

💭
I may be slow to respond.
View GitHub Profile
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONIN
<?php
use \Inspector\Laravel\Middleware\WebRequestMonitoring;
class InspectorFilterMonitoringMiddleware extends WebRequestMonitoring
{
/**
* Terminates a request/response cycle.
*
@kmatt
kmatt / void-wsl.txt
Last active June 26, 2024 05:08
Install Void Linux on WSL2
# Based on https://gist.github.com/kmatt/71603170556ef8ffd14984af77ff10c5
# prompt ">" indicates Powershell commands
# prompt "$" are Linux shell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
@marianocordoba
marianocordoba / userdata.sh
Last active February 1, 2023 20:12
Caddy server user data for AWS EC2
#!/bin/bash
sudo su
yum update -y
yum install yum-plugin-copr -y
yum copr enable @caddy/caddy -y
yum install caddy -y
printf ":80\nrespond \"Hello from $HOSTNAME\"" > /etc/caddy/Caddyfile
caddy start --config /etc/caddy/Caddyfile
@conartist6
conartist6 / index.js
Last active June 12, 2022 11:32
sync vs async for loops
function* range(end) {
for (let i = 0; i < end; i++) {
yield i;
}
}
const a = Array.from(range(65536));
module.exports['for await..of values from one chunk'] = {
fn: async function(deferred) {
@johnfedoruk
johnfedoruk / clamd-setup.md
Last active June 26, 2024 16:12
Setting up ClamAV

ClamAV Setup Notes

Context

ClamAV can be used in a few different ways. Most importantly, it provides the ability to scan files in realtime (on-access) or to scan the file system periodically.

I tried configuring ClamAV to both perform on-access virus scanning and to perform nightly full filesystem scanning. Using the on-access option did not prove to be very useful, however a scheduled full system scan seems to be of value.

Here is my story.

// ==UserScript==
// @name No YouTube Volume Normalization
// @namespace https://gist.github.com/abec2304
// @match https://www.youtube.com/*
// @grant none
// @version 2.1
// @author abec2304
// @description Enjoy YouTube videos at their true volume
// @inject-into content
// @run-at document-start
@mfcodeworks
mfcodeworks / encrypted-storage.js
Last active August 3, 2023 05:08
Encrypted storage with localstorage
// Constants
const passphrase = 'password',
key = 'data',
object = { foo: 'bar' };
// Log original item
console.log('Original object', object);
// Store item with encryption
setItem(key, object, passphrase);
@BenSampo
BenSampo / deploy.sh
Last active July 16, 2024 07:53
Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin $FORGE_SITE_BRANCH
@MatthieuScarset
MatthieuScarset / .lando.yml
Last active January 4, 2024 15:03
Correct settings for XDebug + VSCode + Lando (+3.0)
# Lando version is at least +3.0
name: drupal-nine
recipe: drupal9
services:
appserver:
webroot: web
xdebug: debug
config:
php: .vscode/php.ini