Skip to content

Instantly share code, notes, and snippets.

Avatar

Jens Martsch jmartsch

View GitHub Profile
@duncanmcclean
duncanmcclean / console.php
Last active Apr 16, 2021
Identify & fix Duplicate IDs in Statamic 3.
View console.php
<?php // copy everything after this line
Artisan::command('identify-duplicates', function () {
$duplicates = [];
$shouldFixDuplicates = $this->confirm('Should Duplicate IDs be replaced with fresh IDs?');
$items = collect(\Illuminate\Support\Facades\File::allFiles(__DIR__.'/../content'))
->filter(function ($file) {
return $file->isFile();
})
View scrollObserver
/**
* ScrollMonitor
*/
const scrollMonitorScript = {
cfg: {
selectors: {
waypoint: '[waypoint]',
waypointTarget: '[waypoint-target]',
},
@nico-martin
nico-martin / gtag-gdpr-ready.html
Last active Feb 24, 2020
This little snippet provides a simple way to a) implement Google Tag Manager with anonymized IP and b) provide a Opt-Out / Opt-In mechanism: gtagOptOutIn();
View gtag-gdpr-ready.html
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.gtagTrackingID = 'UA-XXXXXXXX-X';
window.gtagDisableStr = 'gtag-disable-' + gtagTrackingID;
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
@lokomotivan
lokomotivan / fieldgroup.php
Last active Oct 10, 2019
Processwire Using API to create and manipulate pages, templates, field, users etc..
View fieldgroup.php
<?php
$fg = $this->fieldgroups->get('FIELDGROUP_NAME');
// if not, create it
if(empty($fg)) {
$fg = new Fieldgroup();
$fg->name = 'NAME';
$fg->add($this->fields->get('title'));
$fg->add($this->fields->get('FIELD2'));
$fg->add($this->fields->get('FIELD3'));
@Nilpo
Nilpo / Using Git to Manage a Live Web Site.md
Last active Jun 10, 2021
Using Git to Manage a Live Web Site
View Using Git to Manage a Live Web Site.md

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents

View Project Questionnaire
Here are a few questions that will tee us up for a good conversation:
- Can you tell me about your project in a few sentences?
- What’s the timeframe? Does a certain event depend on this project launching?
- What are you looking for from us? Do you want us to design, build, and launch the whole site? Or do you have developers or other partners lined up and only need us for design?
- Have you already started on any part of the project? Do you have existing work? A new logo? Some rough designs or ideas for the site?
- How large is your team? What are the roles you envision on your end?
- How did you hear about our work? What specifically interests you about it? Any projects that you’re keen on?
- How much money have you set aside for this project?
- Are you talking to others about this project? Might we ask how many? What do you like about their work?
@somatonic
somatonic / form-process.php
Last active Nov 18, 2020
ProcessWire example front-end form with file upload and fields
View form-process.php
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";