Skip to content

Instantly share code, notes, and snippets.

class Analytics::RefreshIdentifiesService
# This service is explicitly written to send identify calls for users
# that have incorrect attributes in Braze. The flow for this service is as
# follows:
#
# 1. Find all users that have been updated in the last hour
# 2. For each user, pull the corresponding user attributes for that user
# from Braze using the Braze REST API (via the Braze-Ruby gem)
# 3. If the traits in the user's identify_data is different than what comes
# from Braze (that is, there are either new attributes or changed attributes),
@stephenreid
stephenreid / pre-commit.rb
Last active June 28, 2017 18:26
prevent_asset_commit.rb
#!/usr/bin/env ruby
# Place in your .git/hooks directory
# Prevents rails assets commotted to master and other merge conflicts, etc
def on_master?
`git rev-parse --abbrev-ref HEAD`.include?("master")
end
# Don't allow master to have a manifest
if on_master? && File.directory?("public/assets")
@stephenreid
stephenreid / before_migrate.rb
Created April 13, 2016 03:01
Amazon Opsworks Assets Deploy
Chef::Log.info("Precompiling assets for RAILS_ENV=#{rails_env}...")
# Precompile assets. Assets are compiled into shared/assets and shared between deploys.
shared_path = "#{new_resource.deploy_to}/shared"
# create shared directory for assets, if it doesn't exist
directory "#{shared_path}/assets" do
mode 0770
action :create
recursive true
@stephenreid
stephenreid / apiProcessor.php
Last active December 13, 2015 17:49
Takes GET url w/ Post Parameters and sends the request on to a very basic rest server.
<?php
class apiProcessor{
private $gets;
private $posts;
public function __construct($gets,$posts){
$this->gets = $gets;
$this->posts = $posts;
}
public function process(){
$url = $this->gets['url'];
@stephenreid
stephenreid / gist:4319322
Created December 17, 2012 15:49
Pardot Create New Prospect from Info
<?php
//$info = $order->info();
$info = array(
'email' => 'test@text.com',
'first' => 'Bob'.
'last' => 'Roberts'
);
$pardotConnector = new PardotConnector();
//Keep credentials secure
@stephenreid
stephenreid / gist:3086745
Created July 10, 2012 22:50
Prospect Query With Criteria
<?php
$pardotConnector = new PardotConnector();
//Keep credentials secure
$pardotConnector->authenticate($username,$password,$userKey);
//Return array of simpleXMLObject prospects
$recentlyUpdatedProspects = $pardotConnector->prospectQuery(
$queryCriteria = array(
'updated_after'=>'yesterday',
'updated_before'=>'last_year',
'last_activity_after'=>'last_seven_days',
@stephenreid
stephenreid / AssignToUserViaCustomField.php
Created May 29, 2012 16:56
Assign to a User with Custom Field Value
<?
//This is the pseudo code to assign prospects based on a custom field's value
$connection = new PardotConnector();
$connection->authenticate();
$prospects = $connection->getRecentlyUpdatedProspects();
foreach($prospects as $prospect){
if($prospect->owner_email!=false){
$prospect->setAssignedUser($prospect->owner_email);
}
<?
/**
Written by James Laughlin
http://developer.pardot.com/discussions/questions/55-php-login-example
There seems to be little on this forum that is language specific, so If you are using Drupal or Wordpress, you'll need to build interfaces to Pardot in PHP at some point. Here's a function you can use to retrieve your Pardot credentials in one array object so that you can make your API calls.
**/
// the pardot API key is only good for an hour
// so it's best to get it before every API call
function get_pardot_credentials(){