Skip to content

Instantly share code, notes, and snippets.

View jamesmills's full-sized avatar

James Mills jamesmills

View GitHub Profile
<script>
AnyTrack(function() {
// generates the user client id
var at_click_id = AnyTrack('atclid');
var campaign = new Retreaver.Campaign({
campaign_key: '{{ $campaign['retreaverCampaignKey'] }}'
});
var tags = {
@jamesmills
jamesmills / anytrack_leadbyte_example.html
Last active October 13, 2023 06:32
Extracting the AnyTrack Click ID to append to the LeadByte Custom Form integration.
<script>
AnyTrack(function() {
// Extract atclid once AnyTrack script is loaded
var atclid = AnyTrack('atclid');
var c1 = "7 Facebook Ad Tips";
// Append AnyTrack Click ID to LeadByte form url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('atclid', atclid);
@jamesmills
jamesmills / mysql.php
Created July 7, 2023 12:11
Fill Gaps in Statistical Time Series - Date by the hour
$requests = DB::table('advert_requests as ar')
->select(DB::raw("date_format(ar.created_at, '%Y-%m-%d %H' ) AS grouped_hour, count(*) AS requests"))
->join('placements as p', 'p.id', '=', 'ar.placement_id')
->where('ar.created_at', '>=', $from)
->where('p.site_id', $site_id)
->groupBy('grouped_hour')
->get();
// Let's say you have a local package which you want to do some develoment on by including it in another project
/Users/jamesmills/Projects/Packages/larapex-charts
// You can use this one-liner to have composer install it from you local file system
composer config repositories.local '{"type": "path", "url": "/Users/jamesmills/Projects/Packages/larapex-charts"}' --file composer.json
// Which will add this to your composer.json file
"repositories": {
"local": {
"type": "path",
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class GenerateDropForeignKeyMigration extends Command
{
<?php
namespace App\Http\Requests\Api;
use Illuminate\Http\JsonResponse;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\ValidationException;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;

Treeware Option One

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Treeware Option Two

You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

@jamesmills
jamesmills / AdGroupCallExtension.php
Last active June 24, 2020 08:09
Google Adwords API. Creating a Call Extension for an AdGroup.
<?php
public function fire()
{
// See the Placeholder reference page for a list of all the placeholder types and fields.
// https://developers.google.com/adwords/api/docs/appendix/placeholders.html
define('PLACEHOLDER_SITELINKS', 1);
define('PLACEHOLDER_FIELD_SITELINK_LINK_TEXT', 1);
define('PLACEHOLDER_FIELD_SITELINK_URL', 2);
@jamesmills
jamesmills / TreewareCombined.md
Last active April 7, 2020 09:34
Treeware Combined

Treeware Treeware Treeware (Trees)

Licence

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.