Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
mgibbs189 / simple-history-log-http-requests-time.php
Created May 6, 2016 19:19 — forked from bonny/simple-history-log-http-requests-time.php
Snippet for WordPress plugin Simple History Log that logs https request made and how long each request took
<?php
/**
* To use this you first need to install the free plugin Simple History
* https://wordpress.org/plugins/simple-history/
*/
// pre_http_request is fired close before the actual request
add_filter( 'pre_http_request', function( $retval, $r, $url ) {
@em-piguet
em-piguet / article2collections.sql
Created March 30, 2016 09:59
How to convert an MODX articles container to a MODX collections container...
# switch ArticlesContainer -> CollectionContainer
# the res. ID I want to migrate is 11
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'ArticlesContainer', 'CollectionContainer') WHERE id=11;
# switch class_key to go back to default document view for children
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'Article', 'modDocument') WHERE parent=11;
# Change template 49 -> 57
@ben-w-smith
ben-w-smith / gulpfile.js
Created February 26, 2016 18:34
Gulp with BrowserSync with ngrok
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var ngrok = require('ngrok');
gulp.task('default', function() {
browserSync.init({
server: {
baseDir: "./public"
}
import pandas as pd
df = pd.DataFrame({'Name': ['Soton Central', 'Soton Airport', 'London Paddington', 'Malvern Link', 'Great Malvern', 'Oxford'],
'TLC': ['SOU', 'SOA', 'PAD', 'MVL', 'GMV', 'OXF']})
selected_stations = ['London Paddington', 'Malvern Link']
df[df.Name.isin(selected_stations)]
$ = jQuery;
/*
* jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
@jgeewax
jgeewax / configure-mailgun
Created December 7, 2015 17:59
Script to configure Postfix for Mailgun
#!/bin/bash
# Configuration for the script
POSTFIX_CONFIG=/etc/postfix/main.cf
POSTFIX_SASL=/etc/postfix/sasl_passwd
function confirm () {
read -r -p "${1:-Are you sure? [Y/n]} " response
if [[ $response == "" || $response == "y" || $response == "Y" ]]; then
echo 0;
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 26, 2025 05:11
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@jprjr
jprjr / Server-level CORS in NGINX.md
Last active July 2, 2024 14:33
Server-level CORS in NGINX

NGINX does weird things with If statements: http://wiki.nginx.org/IfIsEvil

It turns out, "if" inside a location directive w/ proxy_pass disables that implied URL-rewriting function. So, for example:

location /some/url/ {
  proxy_pass http://backend/api/;
  # example client url: http://server/some/url/data
  # URL sent to proxy: http://backend/api/data
}
@rsalmond
rsalmond / php_oboe functions
Last active April 26, 2016 16:48
AppNeta php_oboe function signatures
<?php
/**
* Oboe API for PHP
*
* This can be used for autocompletion in many major PHP editors
* provides documentation for the code
* and can be used on systems where the oboe extension is not loaded
* to provide no-op versions of functionality
*/
@lavoiesl
lavoiesl / AbstractFixtureMigration.php
Last active October 18, 2023 19:23
Load Doctrine Fixtures when using Migrations in Symfony: AbstractFixtureMigration
<?php
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader as Loader;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;