Skip to content

Instantly share code, notes, and snippets.

@Microtribute
Microtribute / ConstructorMapper.php
Created October 28, 2020 06:11 — forked from boekkooi/ConstructorMapper.php
Symfony Form DataMapper using object constructors
<?php
namespace Acme\Symfony\Form\DataMapper;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
class ConstructorMapper extends PropertyPathMapper
{
@Microtribute
Microtribute / Main.elm
Created October 12, 2020 19:11 — forked from pablohirafuji/Main.elm
Elm simple form example
module Main exposing (..)
import Http
import Task
import Html.App as Html
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Form exposing (Form)
import Form.Validate as Validate exposing (..)
@Microtribute
Microtribute / checkIsBrave.js
Created September 9, 2020 15:03 — forked from drbh/checkIsBrave.js
Reliably detect Brave Browser with native JS
// helper to find Brave in User Agent string
function isBraveAgent(userAgentResponse) {
var isBraveIndex = ~userAgentResponse.indexOf('Brave')
if (isBraveIndex < 0) {
return true
}
return false
}
// Function from Javarome
@Microtribute
Microtribute / Symfony-Event-Dispatcher.md
Last active September 4, 2020 17:10
Symfony Kernel Events Default Method Name

How does Symfony determine the name of the method to call in an event listener on a kernel event?

In regard to this question, the official Symfony documentation states:

Symfony follows this logic to decide which method to execute inside the event listener class:

  1. If the kernel.event_listener tag defines the method attribute, that's the name of the method to be executed;
@Microtribute
Microtribute / Math.php
Created September 4, 2020 15:32 — forked from jgrossi/Math.php
Math class from Taylor Otwell. Thanks to @brad (captain_jim1@yahoo.com) for the class content.
<?php
class Math {
/**
* The base.
*
* @var string
*/
private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
@Microtribute
Microtribute / CountryRepository.php
Created September 1, 2020 17:30 — forked from adamsafr/CountryRepository.php
Doctrine: Union with JOIN example
<?php
namespace AppBundle\Repository;
use AppBundle\Entity\Country;
use AppBundle\Entity\CountryTranslation;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\QueryBuilder;
@Microtribute
Microtribute / Event.php
Created August 19, 2020 12:44 — forked from foaly-nr1/Event.php
NotOverlapping Symfony date period validator
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AppBundle\Validator\Constraints\NotOverlapping;
/**
* @NotOverlapping("period")
*/
@font-face {
font-family: SegoeUI;
src:
local("Segoe UI Light"),
url(//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2) format("woff2"),
url(//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff) format("woff"),
url(//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.ttf) format("truetype");
font-weight: 100;
}
@Microtribute
Microtribute / Click URL Macros.md
Last active August 4, 2020 16:06
Macros to attach to click urls by default

Click URL Macros

Macro

(click-id)={$CLICK_ID$}&(lat)={$LAT$}&(lon)={$LON$}&(idfa)={$IDFA_RAW_UPPER$}&(dpid)={$DPID_UPPER$}&(wpid)={$WPID_RAW_UPPER$}&(gaid)={$GAID_RAW_UPPER$}&(ip)={$IP_ADDRESS$}&(ua-enc)={$USER_AGENT_ENCODED$}&(creative-id)={$CRID$}&(line-id)={$LINE_ID$}&(campaign-id)={$CAMPAIGN_ID$}&(app-id)={$APP_ID$}&(app-name)={$APP_NAME$}&(app-bundle)={$APP_BUNDLE$}&(app-category)={$APP_CATEGORIES$}&(device-os)={$DEVICE_OS$}&(dnt)={$DNT$}

Examples

https://www.basaf.com/store/menu?utm_source=FSM&amp;(click-id)={$CLICK_ID$}&amp;(lat)={$LAT$}&amp;(lon)={$LON$}&amp;(idfa)={$IDFA_RAW_UPPER$}&amp;(dpid)={$DPID_UPPER$}&amp;(wpid)={$WPID_RAW_UPPER$}&amp;(gaid)={$GAID_RAW_UPPER$}&amp;(ip)={$IP_ADDRESS$}&amp;(ua-enc)={$USER_AGENT_ENCODED$}&amp;(creative-id)={$CRID$}&amp;(line-id)={$LINE_ID$}&amp;(campaign-id)={$CAMPAIGN_ID$}&amp;(app-id)={$APP_ID$}&amp;(app-name)={$APP_NAME$}&amp;(app-bundle)={$APP_BUNDLE$}&amp;(app-category)={$APP_CATEGORIES$}&amp;(device-os)={$DEVICE_OS$}&amp;(dnt)={$DNT$}
@Microtribute
Microtribute / postback.js
Created July 29, 2020 14:26
Smadex Postback
(function () {
var u=`https://geo-tracker.dsp.flowershop.media/hyperad/pixel-tracking?order=111466&action=buy&t=${new Date().getTime()}`;
document.createElement('img').src = u;
})();