Skip to content

Instantly share code, notes, and snippets.

@pvolyntsev
pvolyntsev / ModActiveRecord.php
Last active May 4, 2023 20:27
Yii Active Record instance with "ifModified then ..." logic and dependencies clearing
<?php
/**
* Class ModActiveRecord is the base class for classes representing relational data.
* It provides methods to check if attributes were modified
*
* @author [email protected]
* @link http://copi.st/JtvJ
* @link http://www.yiiframework.com/extension/mod-active-record/
*
@jtsternberg
jtsternberg / wds-include-tlc-transients.php
Last active August 29, 2015 14:07
tlc-transients helper functions
<?php
// Include tlc lib
require_once WPMU_PLUGIN_DIR . '/wp-tlc-transients/tlc-transients.php';
/**
* Use in place of `get_posts`
*
* @param array $args Array of get_posts arguments
* @param integer $time Amount of time before cache expires
@bradp
bradp / setup.sh
Last active August 21, 2025 15:06
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
@gregrickaby
gregrickaby / example-nginx.conf
Last active November 22, 2020 20:24 — forked from pmgarman/gist:8fba357c97193633a66d
Defer the loading of images to the production server. Use either Apache or NGINX depending on your local server setup.
################################################################
# Example configuration file for nginx
#
# To add a new local WordPress domain to your environment, copy
# this file using a filename that matches the domain you wish to
# setup. For example - mylocaldomain.com.conf would be an ideal
# filename for http://mylocaldomain.com
#
# Once copied, you will need to modify two settings in the server
# configuration provided:
@jtsternberg
jtsternberg / extract-plugin-repo.bash
Created February 3, 2015 16:57
Extract a plugin and its commit history from a larger repo (wp-content)
#
# Cutting the rss-post-aggregate plugin and its history out of a (wp-content) repo
#
# clone wp-content repo to a folder named for the plugin
$ git clone [email protected]:/your-organization/your-wp-content-repo.git rss-post-aggregator
# Remove original origin remote (won't be needed)
$ git remote rm origin
@bradp
bradp / gist:8b379e71daa4b6a61d14
Last active March 17, 2025 08:14
Useful SQL Queries
#Get the size of each table, ordered by largest to smallest
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "YOU+TABLE+NAME+HERE"
ORDER BY (data_length + index_length) DESC;
#Get the size of the entire DB
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
@jprante
jprante / binary-put-es.sh
Last active May 9, 2020 15:06
Put binary data to Elasticsearch
# first, set
#
# http.compression: true
#
# in config/elasticsearch.yml
curl -XDELETE 'localhost:9200/test'
rm -f content.json content.json.gz
echo '{"content":"Hello World"}' > content.json
@Integralist
Integralist / 1. siege.sh
Last active September 19, 2019 09:34
Siege load/stress testing utility (https://www.joedog.org/siege-manual/)
# brew install siege
# -c/--concurrent == number of concurrent requests
# -r/--reps == number of times to run the test
siege -c 10 -r 10 -b "http://www.domain.com/"
# Note: doesn't always work with SSL endpoints with self-signed certs
# using Apache Ab in a Docker container seems to do the trick though
# see https://gist.github.com/Integralist/01815f7abc7d18a97341

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods