Skip to content

Instantly share code, notes, and snippets.

View papayasoft's full-sized avatar

David Weinraub papayasoft

View GitHub Profile
@pbojinov
pbojinov / README.md
Last active December 8, 2023 21:09
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@tadas-s
tadas-s / mysql-rename-db.sh
Created April 18, 2013 08:58
MySQL database rename script
#!/bin/bash
# Disclaimer - make backups, use at your own risk.
#
# Based on this comment: http://stackoverflow.com/a/13944924/843067
# Views and stored procedures have to be done separately.
OLDDB="old_db_name"
NEWDB="new_db_name"
MYSQL="mysql -u root -pyour_password "
@mgebundy
mgebundy / wp-xml-rpc.php
Last active May 4, 2016 04:08
Building custom XML-RPC methods in WordPress
<?php
// Include the XML-RPC files
include_once(ABSPATH . WPINC . '/class-IXR.php');
include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');
class my_xmlrpc extends wp_xmlrpc_server {
function __construct() {
// This filter will add the new methods we're building
add_filter('xmlrpc_methods', array($this, 'my_xmlrpc_methods'));
parent::__construct();
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@jhartikainen
jhartikainen / gist:1050932
Created June 28, 2011 11:21
PHP error to exception converter with special invalid argument handling
<?php
//This converts errors into exceptions, but if the error is caused
//by an argument being invalid (for example failing a typehint), it gets converted into an InvalidArgumentException
function handle($code, $message, $file, $line) {
//This test might be naive but it worked in my very very simple test code :)
if(strpos($message, 'Argument ') === 0) {
throw new InvalidArgumentException($message);
}
else {
throw new ErrorException($message, 0, $code, $file, $line);