Skip to content

Instantly share code, notes, and snippets.

View kaesetoast's full-sized avatar
🤔
Coding

Philipp Nowinski kaesetoast

🤔
Coding
View GitHub Profile
@kaesetoast
kaesetoast / intl.js
Created February 10, 2021 16:58
Example of using the Intl API to format a date
// output: 10.02.2021, 17:53
new Intl.DateTimeFormat('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
}).format(new Date(comment.created_at));
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
trait UuidTrait
-----------------------------------------------------------------------------
| Tarif | Anbieter | Leistungsbeschreibung | Vergleichbar |
-----------------------------------------------------------------------------
| Standard | TouringCars | Unbegrenzte Freikilometer | ✔️ |
| Standard | TouringCars | Transfer inklusive | ✔️ |
| Standard | TouringCars | Vom Chef signierter Wackeldackel | ✖️ |
| Standard | IndieCampers | Unbegrenzte Freikilometer | ✔️ |
-----------------------------------------------------------------------------
// check if referrer is outside of the website scope
if (document.referrer.indexOf(`${window.location.protocol}//${window.location.host}`) === -1) {
window.localStorage.setItem('__fnp_referrer', document.referrer);
}
const referrerField = document.querySelector('[name="signupform[referrer]"]');
const referrerValue = window.localStorage.getItem('__fnp_referrer');
// write stored referrer value back to hidden field in signup-form
if (referrerField && referrerValue) {
@kaesetoast
kaesetoast / datalayer.php
Last active January 5, 2020 09:11
DataLayer
// The dataLayer JavaScript is generated inside of a smarty template. All variables in curly-braces have to be replaced
// with whatever your system provides you with.
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: "orderCompleted",
transactionId: '{$sOrderNumber}', // Transaction ID. Required for purchases and refunds.
transactionTotal: {if $sAmountWithTax && $sUserData.additional.charge_vat}{$sAmountWithTax}{else}{$sAmount}{/if}, // Total transaction value (incl. tax and shipping)
transactionTax: {$sAmountTax},

CSS Custom Properties are Variables. Just cooler.

If you are using some kind of Preprocessors like Sass, Less, or Stylus, you probably are familiar with the concept of variables in CSS. So now we have the same thing in the Browser – right? Well. Kinda. But better.

Let's explore what makes custom properties different from variables and why they are so much more powerful. Together, we will dive into some real-world examples to see how custom properties can help with some of the challenges of responsive design, theming and a component-driven CSS-architecture.

Custom Properties are well supported among modern browsers and you can use them today! Internet Explorer is still relevant to your customers? – Worry not! We will also take a look at possible fallback strategies for serving legacy browsers.

$('.js-popup-link').each(function(){
var url = $(this).attr('href');
url += (url.split('?')[1] ? '&':'?') + 'type=103';
$(this).attr('data-mfp-src', url);
});
$('.js-popup-link').magnificPopup({
type: 'ajax',
callbacks: {
parseAjax: function(response) {
@kaesetoast
kaesetoast / dynamic-gulp-dest
Last active March 10, 2017 20:58
write gulp output to dynamic destinations
return gulp.src('app/**/scss/++/*.scss')
.pipe(sass())
.pipe(gulp.dest(function(files) {
return path.join(file.base, '../css');
}));
@kaesetoast
kaesetoast / fix-duplicate icon
Created November 18, 2014 10:33
Fix duplicate Chrome icon in Plank
sudo sed -i -r 's/(\[.+\])$/\1\nStartupWMClass=Google-chrome-stable/g' /usr/share/applications/google-chrome.desktop
<?php // HTTP Headers for ZIP File Downloads
// http://perishablepress.com/press/2010/11/17/http-headers-file-downloads/
// set example variables
$filename = "Inferno.zip";
$filepath = "/var/www/domain/httpdocs/download/path/";
// http headers for zip downloads
header("Pragma: public");
header("Expires: 0");