Skip to content

Instantly share code, notes, and snippets.

View derak-kilgo's full-sized avatar

Derak Kilgo derak-kilgo

View GitHub Profile
@derak-kilgo
derak-kilgo / wordpress-config-extract.php
Last active October 29, 2021 14:16
Extract database and other constants from a wp-config.php file without "including" it.
<?php
/**
* Extract key and value from all "define" constants in a wp-config.php file using built-in php tokenizer functions.
* Does not "include" the file so it won't pollute the current scope or cause side effects.
*
* NOTE: Works with constants defined as string, bool or number
* Method can extract values from statements like:
* define( 'DB_NAME', 'wordpress' );
* define('WP_DEBUG', true);
* define('SOMEINT', 1234567);
@samhernandez
samhernandez / MampHelper.php
Last active July 21, 2022 06:00
Craft CMS v3, MAMP, and mysqldump for database backups
<?php
namespace modules;
use Craft;
/**
* MAMP Helper class.
* File: /modules/MampHelper.php
*
* MySQL database backups triggered from the Craft 3 Control Panel fail because,
#!/usr/bin/env bash
# exit 0
set -ex
echo '##########################################################################'
echo '##### About to run install-gnome-gui.sh script ##################'
echo '##########################################################################'
# https://codingbee.net/tutorials/vagrant/vagrant-enabling-a-centos-vms-gui-mode
yum groupinstall -y 'gnome desktop'
@ohpe
ohpe / MiTM-SSL.md
Created February 12, 2018 20:03
Simple SSL MiMT using stunnel

Simple SSL MiTM

A quick and dirty SSL MiTM using stunnel

  • Generate a SSL certificate .. or use Let's Encrypt (for the green lock)
openssl req -batch -new -x509 -days 365 -nodes -out mitm.pem -keyout mitm.pem
  • Run stunnel
@gtgt
gtgt / build-php-static.sh
Last active March 6, 2024 04:51
Script to build static php
#!/bin/bash
U=${SUDO_USER:=${USER}}
if [[ -x `which realpath` ]]; then
T=$(realpath ${BASH_SOURCE[0]:=${0}})
else
T=${BASH_SOURCE[0]:=${0}}
fi
D=$(dirname ${T})
#apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libtidy-dev libmemcached-dev imagemagick-dev msgpack-dev
@derak-kilgo
derak-kilgo / cli-export.php
Created February 5, 2016 18:52
Magento Loop through a collection (stand alone)
<?php
if(php_sapi_name()!=="cli"){
echo "Must be run from the command line.";
};
/**
* Setup a magento instance so we can run this export from the command line.
*/
@Topener
Topener / slack_invite.php
Last active June 26, 2022 03:05
Simple PHP script to invite slack users
<?php
/**
* This is a simple script to invite users to your slack
* Replace the subdomain and token in the variables below.
* Upload a logo called "logo.png" to the same directory for your group
* Upload a logo called "slack.png" to the same directory for slack
*/
define('SUBDOMAIN','{YOUR SUBDOMAIN HERE}');
define('TOKEN','{YOUR API TOKEN HERE}');
?>
@brianlmoon
brianlmoon / apache_cors_example
Last active November 19, 2023 03:14
CORS example for Apache with multiple domains
# Sets CORS headers for request from example1.com and example2.com pages
# for both SSL and non-SSL
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
Header set Access-Control-Allow-Credentials "true" env=ORIGIN
# Always set Vary: Origin when it's possible you may send CORS headers
Header merge Vary Origin
@tonymtz
tonymtz / gist:714e73ccb79e21c4fc9c
Created November 15, 2014 00:02
Uninstall XQuartz.app from OSX Yosemite
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
# Log out and log in
@m1
m1 / ferengi-apache.txt
Last active September 24, 2024 14:45
How to throttle the FCC to dial up modem speeds on your website using Apache.
# How to throttle the FCC to dial up modem speeds on your website using Apache.
# Ported from https://gist.github.com/kyledrake/e6046644115f185f7af0
## The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
##
## Current known FCC address ranges:
## https://news.ycombinator.com/item?id=7716915
##
## Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft