Skip to content

Instantly share code, notes, and snippets.

View DarkGL's full-sized avatar

Rafał Więcek DarkGL

View GitHub Profile
@DarkGL
DarkGL / php.ini
Created December 12, 2022 17:09 — forked from fuyuanli/php.ini
Disable Dangerous PHP Functions
disable_functions = "apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd, eval, exec, fp, fput, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, mysql_pconnect, openlog, passthru, php_uname, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode"
@DarkGL
DarkGL / missing_indexes.sql
Created April 22, 2023 18:07 — forked from timhwang21/missing_indexes.sql
Spotting missing indexes for MariaDB & MySQL
SELECT
t.TABLE_SCHEMA,
t.TABLE_NAME,
c.COLUMN_NAME,
IFNULL(
kcu.CONSTRAINT_NAME, 'Not indexed'
) AS `Index`
FROM
information_schema.TABLES t
INNER JOIN information_schema.`COLUMNS` c ON c.TABLE_SCHEMA = t.TABLE_SCHEMA
@DarkGL
DarkGL / missing_indexes.sql
Created April 28, 2023 12:19
Spotting missing indexes for MariaDB & MySQL
SELECT
t.TABLE_SCHEMA,
t.TABLE_NAME,
c.COLUMN_NAME,
IFNULL(kcu.CONSTRAINT_NAME, 'Not indexed') AS `Index`,
kcu.ORDINAL_POSITION,
kcu.POSITION_IN_UNIQUE_CONSTRAINT,
kcu.REFERENCED_TABLE_SCHEMA,
kcu.REFERENCED_TABLE_NAME,
kcu.REFERENCED_COLUMN_NAME,
@DarkGL
DarkGL / expressvpn_setup_on_debian_based_linux.md
Created April 17, 2024 05:50 — forked from raven-rock/expressvpn_setup_on_debian_based_linux.md
How to set up ExpressVPN on Debian/Ubuntu/Pop!_OS Linux
@DarkGL
DarkGL / machette.js
Created April 17, 2024 05:50 — forked from Boshen/machette.js
npm machette - find unused dependencies by grepping the dependency name
// pnpm -r -c exec 'node /path/to/machette.js'
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const process = require('process');
const path = require('path');
async function main() {
const cwd = process.cwd();
@DarkGL
DarkGL / opcache-preload.php
Created April 17, 2024 05:51 — forked from fedek6/opcache-preload.php
Working WordPress opcache preloading config
<?php
/**
* WordPress opcache preloading.
* Requires PHP >= 7.4.
*
* @author Konrad Fedorczyk <[email protected]>
* @link https://stitcher.io/blog/preloading-in-php-74
*
* @version 1.0.0
*/
@DarkGL
DarkGL / cloudflare.sh
Created April 17, 2024 05:51 — forked from Manouchehri/cloudflare.sh
Allow CloudFlare only
# Source:
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
# Avoid racking up billing/attacks
# WARNING: If you get attacked and CloudFlare drops you, your site(s) will be unreachable.
iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP
@DarkGL
DarkGL / deps-puppetteer-debian9.sh
Created April 17, 2024 22:25 — forked from HugoJBello/deps-puppetteer-debian9.sh
install dependencies debian 9 puppeteer
# https://medium.com/google-cloud/node-to-google-cloud-compute-engine-in-25-minutes-7188830d884e
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt install nodejs
#install dependencies
#https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-322838700
sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
@DarkGL
DarkGL / branded.ts
Last active May 19, 2024 14:13
Improve Runtime Type Safety with Branded Types in TypeScript
declare const __brand: unique symbol
type Brand<B> = { [__brand]: B }
export type Branded<T, B> = T & Brand<B>
/**
* Branded type for a person's age, should belong to the interval [0, 125] (inclusive)
**/
type Age = Branded<number, "Age">;
/**
@DarkGL
DarkGL / lowercase.ts
Last active July 13, 2024 19:01
Disable toLowerCase on already lower cased string
// Step 1: Define the Branded Type
type LowercaseString = string & { __brand: "LowercaseString" };
// Step 2: Type Guard Function
function toLowercaseString(s: string): LowercaseString {
return s.toLowerCase() as LowercaseString;
}
// Step 3: Override Type Definitions
type RemoveToLowerCase<T> = Omit<T, "toLowerCase">;