Skip to content

Instantly share code, notes, and snippets.

@raamdev
raamdev / nginx-mamp-macports.txt
Last active February 24, 2023 08:02
These are the steps to get Nginx running alongside MAMP on a Mac.
# These steps will get nginx installed on your Mac for local development and
# testing purposes, to be used alongside MAMP (which already includes Apache).
# The following steps assume that you're running MAMP and that you already
# have php-cgi in /Applications/MAMP/bin/php/php5.4.10/bin/php-cgi.
# The start-nginx and stop-nginx scripts created at the end do not
# start or stop MySQL because it is assumed that you normally run MAMP
# with Apache + MySQL turned on and that you occasionally want to switch
# your web server to Nginx for testing purposes and that you leave MySQL running.
# This process was tested successfully on OS X 10.9.
@raamdev
raamdev / bitly.php
Last active February 28, 2020 17:31
<?php
/**
* Plugin Name: Bit.ly
* Version: 1.2
* Author: Micah Ernst, Bradford Campeau-Laurion (Alley Interactive)
* Description: Uses bit.ly API to get shortened url for a post on publish and saves url as meta data. Based on TIME.com's Bit.ly plugin.
*/
if ( defined( 'WP_CLI' ) && WP_CLI )
require dirname( __FILE__ ) . '/class-wp-cli.php';
<!DOCTYPE html>
<html>
<head>
<title>Welcome To Google Cloud | Kinsta</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
<style type='text/css'>
/* CSS RESET */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';
@raamdev
raamdev / flickr-random-photo.php
Created October 6, 2012 05:49
Load a Flickr photo set and then display a random photo from that set
<?php
/**
* Raam Dev - http://raamdev.com/
*
* This code loads a Flickr Photo Set and then picks a random photo from that set
* After configuring your settings and loading the PHP, you can display the random photo as follows:
* <a href="<?php echo $flickr_img_url_large; ?>" title="<?php echo $flickr_photo_description; ?>">
* <img title="<?php echo $flickr_photo_description; ?>" border="0" src="<?php echo $flickr_img_url; ?>" />
* </a>
*
@raamdev
raamdev / custom-link-library-stylesheet.css
Created July 13, 2016 17:34
Link Library stylesheet used on raamdev.com
$to = preg_replace_callback('/%%\$(\_[a-zA-Z]+)(.+?)%%/i', 'wp_redirects\plugin::_url_e_gprcs_value', $to);
if(strlen($element_w_brackets = $m[2]) && preg_match('/^(?:(?:\[(["\'])[a-z0-9\._\-]+?\1\])|(?:\[[0-9]+\]))+$/i', $element_w_brackets))
<?php
$curl_localhost_test_success = FALSE;
$curl_localhost_test_url = 'http://'.$_SERVER['HTTP_HOST'];
$curl_localhost_test_url_return_string_frag = 'html';
if(is_resource($_curl_test_resource = curl_init()))
{
curl_setopt_array(
$_curl_test_resource, array(
CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5,
<?php
if(!defined('WPINC')) // MUST have WordPress.
exit('Do NOT access this file directly: '.basename(__FILE__));
add_action('init', 'github_events::init');
class github_events // Event handler.
{
# Configuration ###############################################
@raamdev
raamdev / testing-wp-access-control-mu-plugin.md
Last active March 9, 2016 18:40
Testing WordPress Access Control using an MU Plugin

Testing WordPress Access Control using an MU Plugin

WARNING - MU plugin file for testing purposes only.

If you don't want to use the plugin and instead want to use a coded solution, the following below could be done for testing purposes. We highly recommend on using a plugin like User Switching over this method. The plugin method is likely to offer better security and it will be easier for most people.

Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folder and which are automatically enabled on all sites in the installation. Must-use plugins do not show in the default list of plugins on the Plugins page of wp-admin – although they do appear in a special Must-Use section – and cannot be disabled except by removing the plugin file from the must-use directory, which is found in wp-content/mu-plugins by default.

See: http://codex.wordpress.org/Must_Use_Plugins

@raamdev
raamdev / fpass.sh
Created February 5, 2016 17:29
Script to quickly search password store
#!/bin/bash
PATH_TO_PASS=/usr/local/bin/pass
PATH_TO_PASS_DIR=/Users/raam/.password-store
PATH_TO_FIND=/usr/bin/find
# Trims ".password-store/Personal/example.com.gpg" to
# "Personal/example.com" for use with the pass command
OFFSET=${#PATH_TO_PASS_DIR}