Skip to content

Instantly share code, notes, and snippets.

@merltron-pa
merltron-pa / php_jms_article_addconstructor1.php
Last active November 16, 2020 16:09
PHP/JMS Article: Add add first part of constructor
<?php
...
class TestAddressController extends AbstractController
{
/**
* @var SerializerInterface
*/
private $serializer;
@merltron-pa
merltron-pa / php_jms_article_entity_getters.php
Last active November 16, 2020 16:17
PHP/JMS Article: Add getters to entity
<?php
...
private $country;
public function getName(): ?string
{
return $this->name;
}
public function getLineOne(): ?string
@merltron-pa
merltron-pa / php_jms_article_basicEntity.php
Last active November 16, 2020 15:53
PHP/JMS Article: Create basic entity
<?php
namespace App\Entity;
class TestAddress
{
/** @var string */
private $name;
/** @var string */
private $lineOne;
@merltron-pa
merltron-pa / php_jms_article_emptyjson.php
Last active November 17, 2020 12:03
PHP/JMS Article: Test post request, get back empty JSON
<?php
...
class TestAddressController extends AbstractController
{
/**
* @Route("/test/address", methods={"POST"})
*/
@merltron-pa
merltron-pa / php_jms_article_newcontroller.php
Created November 16, 2020 11:54
PHP/JMS Article: Use Maker Bundle to Create Controller
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class TestAddressController extends AbstractController
{
@merltron-pa
merltron-pa / php_jms_article_xml_serialize.php
Last active November 17, 2020 13:41
PHP/JMS Article: Serialize test data into XML
<?php
...
class TestAddressController extends AbstractController
{
/**
* @Route("/test/address", methods={"POST"})
*/
@merltron-pa
merltron-pa / multitouch_article_js2.js
Created September 29, 2020 14:17
multitouch_article_js2
function () {
var name = '_gid'
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : '(not set)';
}
@merltron-pa
merltron-pa / multitouch_article_js1.js
Created September 29, 2020 14:15
multitouch_article_js1
function () {
var name = '_ga'
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : '(not set)';
}
@merltron-pa
merltron-pa / multitouch_article_pt4.py
Created September 29, 2020 14:13
multitouch_article_pt4
#authorization
gc = pygsheets.authorize(service_file='google_credentials.json')
#open the google spreadsheet (where 'PY to Gsheet Test' is the name of my sheet)
sh = gc.open("Multi-touchpoint attribution model - Talent Acquisition")
#select the first sheet
wks = sh[1]
#update the first sheet
@merltron-pa
merltron-pa / multitouch_article_pt3.py
Last active September 29, 2020 14:14
multitouch_article_pt3
#Setting up the empty dataframe that will be filled with the attributed conversions
columns = ['date', 'utm_medium', 'conversions']
attributed_conversion_df = pd.DataFrame(columns=columns)
#looping over all the rows of the raw GA dataframe
for index, row in ga_raw_data.iterrows():
#looking for rows that have at least 1 conversion
if row['submitted_applications'] > 0:
#create a dataframe with the conversion raw and all former sessions of this user
single_conversion_df = ga_raw_data[(ga_raw_data['date'] <= pd.to_datetime(row["date"])) & (ga_raw_data['user_id'] == row["user_id"])]
#sorting by date and number of conversion ascending