Skip to content

Instantly share code, notes, and snippets.

@Rarst
Rarst / append.php
Last active April 27, 2016 12:31
My xhprof/uprofiler setup, tweaked for WordPress and more easily profiling segments.
<?php
use Rarst\Profiler\Handler;
global $wp;
if ( Handler::$profiling && empty( $wp ) ) {
Handler::close();
}
<?php
namespace HM\Hotfix;
add_action( 'deleted_option', __NAMESPACE__ . '\\workaround_28701' );
/**
* Workaround cache deletion issue
*
* Ensures that the singular
#!/usr/bin/env python
# Quick and dirty demonstration of CVE-2014-0160 by
# Jared Stafford (jspenguin@jspenguin.org)
# Modified so that it finds cookies
import sys
import struct
import socket
import time
import select
@fh
fh / nginx.conf
Last active December 28, 2015 04:48
My Crypto Configs
listen 443 ssl;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers kECDH:HIGH:!aNULL:!MEDIUM:!LOW:!NULL:!SSLv2:!ADH@STRENGTH;
ssl_prefer_server_ciphers on;
ssl_certificate /path/to/file.crt;
ssl_certificate_key /path/to/file.key;
#to enable forward secrecy. Generate the file using
#openssl dhparam -outform PEM -out dh.pem 1024
ssl_dhparam /path/to/dh.pem;
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@jgeurts
jgeurts / statsd-graphite-install.sh
Last active January 28, 2017 20:23
Install statsd and graphite as a services on Ubuntu 13.10
sudo apt-get install --assume-yes python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install --assume-yes nodejs
sudo apt-get install --assume-yes git
# Install Graphite
sudo apt-get install python-dev ruby-dev bundler build-essential libpcre3-dev graphite-carbon graphite-web
cat >> /tmp/graphite-carbon << EOF
# Change to true, to enable carbon-cache on boot
@UtahDave
UtahDave / mult-line cmd.run
Last active December 20, 2015 11:39
Multi-line cmd.run wget->tar->rm->cd->make
'''
Redhost functionality
'''
# Import salt libs
import salt.utils
def install_redis():
'''
@westonruter
westonruter / readme.md
Last active December 19, 2015 17:38
vassh: Vagrant Host-Guest SSH Command Wrapper/Proxy/Forwarder

THIS REPO HAS MOVED! It has graduated to a dedicated GitHub project: https://github.com/x-team/vassh

The big pain of doing vagrant ssh is that it doesn’t drop you into the corresponding working directory in the Vagrant guest’s synced_folder, so you have to cd to the dir and then run whatever you needed to do (e.g. wp core update). This is the problem that vassh solves: it will make sure you start out in the corresponding directory. So if you’re in your WordPress project on your host machine, all you need to do is:

$ vassh wp core update

There’s also a wrapper called vasshin which will shell you into Vagrant at the current directory, with a prompt for entering commands. This gets you colors and interactive TTY. You can also pass commands as arguments to vasshin to have them executed right away in the colorized TTY (with some additional Vagrant .bash_login echoes and SSH connection close):

@outmost
outmost / node_beacon.js
Last active December 17, 2015 01:58
Node JS beacon to capture performance metrics from Boomerang.
// Assumptions
// Boomerang makes beacon call to port :8080
// StatsD is running on same server (localhost)
// The following NodeJS modules are installed:
// https://github.com/tobie/ua-parser
// https://github.com/bluesmoon/node-geoip
// Boomerang is configured to send custom parameters for "domain", "page_type", "user_status", "ip" and "user_agent".
// http://lognormal.github.io/boomerang/doc/howtos/howto-5.html