Skip to content

Instantly share code, notes, and snippets.

View erikhansen's full-sized avatar

Erik Hansen erikhansen

View GitHub Profile
@mttjohnson
mttjohnson / mysql_size_info.sql
Last active April 29, 2021 08:30
MySQL data usage queries
/*
# Get size of a specific database into a bash variable for use in estimating mysqldump size for pv status bar
DATABASE_NAME="example_db_name"
DATABASE_SIZE=$(mysql --batch -sN -e "SELECT CONCAT(ROUND(sum( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 0), 'g') as size FROM information_schema.TABLES WHERE table_schema = '${DATABASE_NAME}' GROUP BY table_schema;")
echo "${DATABASE_SIZE}"
*/
/* find the largest tables on the server */
SELECT CONCAT(table_schema, '.', table_name) 'db.table',
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
# clear the entire cache
varnishadm "ban req.url ~ /"
# monitor varnish stats
varnishstat -n prod
# monitor varnish log with multiple patterns
varnishlog | grep 'eqURL\|Age:\|VCL_call\|TTL\|Expires:\|Cache-Control:'
# Use a query with varnishlog to watch requests from a specific IP
@mttjohnson
mttjohnson / magento1_enterprise_index_diagnostics.sql
Last active November 9, 2017 19:53
Magento 1.x Enterprise Partial Indexing Diagnostics Toolset
-- When products are added/removed from a category this table stores all the relation data
select * from catalog_category_product where product_id = '24526';
-- The index that is used for presenting products in a category on the frontend
select * from catalog_category_product_index where product_id = '24526';
-- The change log table used for Magento EE partial index functionality
select * from catalog_category_product_index_cl where product_id = '24526' and version_id > (select version_id from enterprise_mview_metadata where changelog_name = 'catalog_category_product_index_cl');
@twksos
twksos / CiscoVPNConnection.scpt
Last active July 31, 2023 20:50
Cisco VPN connection auto connect AppleScript
-- Please set your vpn connection name and password here
set VPNName to "VPN name"
set VPNpassword to "VPN password"
tell application "System Events"
tell current location of network preferences
set VPNService to service VPNName
end tell
set isConnected to connected of current configuration of VPNService
@nvahalik
nvahalik / custom google apps scripts for tech sales
Last active June 16, 2022 06:17
Some Google Apps Script functions for Spreadsheets which might be useful for those in Technical Sales or software development. They can be used to add up and manipulate hour ranges (e.g. SUMRANGE(["1-2",2,"2-5"]) would yield "5-9"). Those functions are SUMRANGE, SUMRANGEHIGH, SUMRANGELOW, RANGEMULT, and RANGEADD. There are also some functions wh…
/* Grab the values and make them globally available. */
var hoursPerDay = 8;
var hoursPerWeek = hoursPerDay * 5;
/**
* We calculate the number of hours in a given range.
*/
function SUMTIME(allData) {
var numHours = 0;
var numCells = allData.length;
@adgedenkers
adgedenkers / vpn_connection.scpt
Created October 11, 2012 18:16
Toggle Connection to VPN on a Mac via AppleScript
tell application "System Events"
-- get current clipboard contents as a string
set CurrentClipboard to the clipboard as string
-- set the clipboad to your password
set the clipboard to "Y0urVPNPa$$w0rd"
-- start playing with the VPN
tell current location of network preferences