Skip to content

Instantly share code, notes, and snippets.

View RobertRM's full-sized avatar

RobertRM RobertRM

View GitHub Profile
"""
File: oauthRequest.py
Author: Robert Royce-Malmgren
Email: robert@robertrm.com
Github: https://github.com/RobertRM
Description:
"""
import urllib.parse
import requests
public class HelloWorld {
public static void main (String[] args) {
String textVar = "Text Here"
textVar = textVar.replaceAll("[^a-zA-Z1-9 ]", "");
String[] textVarSplit = textVar.split("\\s+");
for (int i = 0; i < textVarSplit.length; i++) {
String output = textVarSplit[i].substring(0, 1).toUpperCase() + textVarSplit[i].substring(1);
System.out.println(output);
}
}

Keybase proof

I hereby claim:

  • I am robertrm on github.
  • I am rnr (https://keybase.io/rnr) on keybase.
  • I have a public key ASAw0OwmJEBmju5S5l9i7Fxc7RFyL0H8vscH3JHttzZZygo

To claim this, I am signing this object:

@RobertRM
RobertRM / get_taxonomy_by_post_type.php
Last active January 3, 2016 05:59
Function to grab taxonomy terms associated with a specific post type in Wordpress.
<?php
/**
* Returns $wpdb results array of taxonomy term ids associated with a post_type
*
* @since 4.4.0
*
* @global object $wpdb Wordpress Database Object.
* @param string $taxonomy_slug The slug for the taxonomy you're looking for results from.
* @param strint $post_type_slug The post type slug for the type of post you're looking at.
*
@RobertRM
RobertRM / gist:5058468
Last active December 14, 2015 08:29
Some error stuff in case someone comes to the page without an original email address, gives them a more meaningful response than getting just a 500 error.
if (!isset($_GET['original_email'])) {
$no_email_error = "<h1>Sorry there was a problem, we need a valid email to continue, you may have been given this URL in error, please return to the homepage</h1>";
die($no_email_error);
}
// THis way uses the fact that Strings wrapped in double quotes will automatically concoctenated variables in side it.
// i.e. $var = "foo"; $string = "This is $var"; results in $string being "This is foo";
$info = new SimpleXmlElement (get_web_page("https://rest.api.pbsmartconnections.com/v1/Subscribers/$_GET[original_email]/Properties"));
// using the conococtenating operator
$info = new SimpleXmlElement (get_web_page("https://rest.api.pbsmartconnections.com/v1/Subscribers/" . $_GET['original_email']. "/Properties"));
<?php
//Function to pull data needed from PB's server
function get_web_page($url) {
// Set up the options that cURL will use.
$options = array(
CURLOPT_HTTPHEADER => array('ApiKey:5393c0a3-2ff2-48f3-a450-288cb0205a61'), // Add API Key to the header for the request
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
);
<?php
// Create the SQL statement with the correct table and a place holder for the group_id, ':group_id:'.
$industry_sql = "SELECT group_name from " . TABLE_GROUP_PRICING . " WHERE group_id = :group_id:";
// Use Zen-cart to modify the SQL statment to incorporate the value from the $industry_id.
$industry_sql = $db->bindVars($industry_sql, ':group_id:', $industry_array, 'integer');
// query the database.
$industry_result = $db->Execute($industry_sql);
// Make sure there were results
if($industry_result->RecordCount() > 0) {
<?php
//Function to pull data needed from PB's server
function get_web_page($url) {
// Set up the options that cURL will use.
$options = array(
CURLOPT_HTTPHEADER => array('ApiKey:5393c0a3-2ff2-48f3-a450-288cb0205a61'), // Add API Key to the header for the request
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
);
@RobertRM
RobertRM / Example1
Last active December 12, 2015 00:29
<?php
$user_list_array = array();
foreach($info->Lists->List as $List) {
$List_id = intval($List->ListID);
$user_list_array[] = $List_id;
}
// Starts iterating over the full set of Lists
foreach($doc->List as $List) {