Skip to content

Instantly share code, notes, and snippets.

@sameg14
sameg14 / CollectUserStatsWorker.php
Created April 29, 2016 20:01
An example of a worker written in PHP that collects user statistics
<?php
namespace Tib\CoreBundle\Job\Worker;
use Tib\CoreBundle\Exception\APIException;
use Tib\CoreBundle\Exception\InvalidDataException;
use Tib\CoreBundle\Util\JsonResponseTrait;
/**
* Class CollectUserStatsWorker collects user information and records it to a table
@sameg14
sameg14 / service_container.yml
Created April 29, 2016 20:00
Service container in symfony (inversion of control)
services:
app.request_listener:
class: Tib\CoreBundle\EventListener\RequestListener
arguments: [@db2, @session, @service.job_scheduler]
tags:
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
client.guzzle:
class: GuzzleHttp\Client
@sameg14
sameg14 / ansible_deploy.yml
Created April 29, 2016 19:58
Ansible playbook to deploy
---
- name: Update code
sudo: yes
sudo_user: ubuntu
git: repo=ssh://git@github.com/sameg14/tib.git
dest=/var/www/tib
version=master
accept_hostkey=True
force=True
[
{
"offer_type":"punch",
"title":"Buy 5 ice cream, get 1 50% off.",
"sub_title":"Ice Cream",
"rewards_sync_timestamp":null,
"require_offer_claim":false,
"rank":null,
"punches_per_card":​5,
"offer_tcs":"Buy 5 ice cream, get 1 50% off.",
[{"ID":{"value":"001L000000gNLRWIA4"},"LastName":{"value":"testing"},"FirstName":{"value":"qa"},"PersonHasOptedOutOfEmail":{"value":"1"},"CustomerMainStore__c":{"value":""},"CustomerStatus__c":{"value":"Active"},"Gender__c":{"value":"Not Saying"},"GlutenFree__c":{"value":"0"},"MainStore__c":{"value":""},"OptOutCommunication__c":{"value":"0"},"PersonAccountEmail__c":{"value":"xxx.xxx@xxx.com107391"},"PointsBalance__c":{"value":"50.0"},"Vegan__c":{"value":"0"},"HouseholdSize__c":{"value":"3"},"MemberID__c":{"value":"48001321142"},"TotalLifetimeSpend__c":{"value":""},"Affinity_Rewards_Program__c":{"value":"1"},"Wholebody_Program__c":{"value":"1"},"Wholebody_Tier__c":{"value":""},"ServiceCloud__c":{"value":"0"},"TotalPointsEarned__c":{"value":""},"WBRegion__c":{"value":""},"TotalPointsUsed__c":{"value":""},"TotalTransactions__c":{"value":""},"JanrainUUID__c":{"value":"b066363b-4f3e-41bc-8e17-f6cc045976fa"},"DigitalCouponMember__c":{"value":"1"},"ImyFamilyDoNotEatDairy__c":{"value":"0"},"ImyFamilyDoNotEatSeafood__
@sameg14
sameg14 / final_upm_esp_attributes.json
Last active February 19, 2016 22:18
Final UPM ESP attributes
{
"core":{
"id":"string",
"active":"bool",
"first_name":"string",
"last_name":"string",
"email":"string",
"phone_number":"string",
"date_created":"timestamp",
"affinity_number":"int",
{
"core":{
"id":"string",
"active":"bool",
"first_name":"string",
"last_name":"string",
"email":"string",
"phone_number":"string",
"date_created":"timestamp",
"affinity_number":"int",
{
"365.generic":[
{
"365_affinity":"bool"
},
{
"365_insight":"bool"
}
],
"esp.generic":[
@sameg14
sameg14 / sample user coupons response.json
Created February 3, 2016 18:47
sample user coupons response
[
{
"redeemed":false,
"id":"a02F000000ONRThIAP",
"title":"House-Made Guacamole",
"sub_title":"$2 Off",
"offer_description":"any ONE (1) tub House-Made Guacamole",
"mobile_web_info":"",
"terms_and_conditions":"Save $2 when you buy any one (1) tub House-Made Guacamole. Coupon good one time only. Valid 2/3/2016\u20132/9/2016 in participating U.S. Whole Foods Market\u00ae stores only. Valid customer barcode must be presented at checkout. Coupon valid for all sizes and varieties. Product selection and availability varies by location. Offer will be applied at checkout during the qualifying shop. No rain checks. Cannot be combined with any other offer or applied to previous orders. Void where prohibited.",
"start_date":"2016-02-03T00:00:00.000Z",

PHPIntro Intermediate Midterm - Part 1

Instructions

Copy this text file to a file named YourName_Midterm_Part1.txt. For example, JoeMcCullough_Midterm_Part1.txt. You will provide your answers to the problems in the "Answer:" sections indicated.