Skip to content

Instantly share code, notes, and snippets.

Yorick Terweijden terwey

Block or report user

Report or block terwey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@terwey
terwey / readme.md
Created Jun 9, 2019
Squarespace hack for adding taxes in Javascript.
View readme.md

Squarespace hack for adding taxes in Javascript.

This allows for showing your local taxrate (as is mandatory in most EU countries) on the store without needing to set the entire site to include taxes (which would also calculate taxes for outside-EU).

Trick is to take your price including VAT (e.g. €50): 50 / 1.19 = 42.01 and use this amount in the Inventory. Configure the tax-rules to set 19% where applicable (shipping from Germany to e.g. Netherlands requires 19% VAT anyway to a private person) and set to 0% to countries non-EU.

The cart will then reflect the correct pricing, and with this snippet (Settings -> Advanced -> Code Injection) inside the Footer will fix the storefront too.

NB: Be sure to disable AJAX Loading, this can be found in Design -> Site Styles because else it'll only work on Refresh and not initial load. This is a known bug in Squarespace.

@terwey
terwey / readme.md
Last active Jul 24, 2017
PHP mail with SMTP for Apache/nginx/etc
View readme.md

Setup

apt-get install msmtp

vim /etc/msmtprc

defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt 
View xorg.conf
# Xorg.conf config for dummy video driver
# For usage with for example TeamViewer on a machine without a monitor attached
# and you wanted more then just 1024x768 ;)
#
# Use at own risk, loosly based on info scattered around but these links really helped
# http://arachnoid.com/modelines/ for the modelines (lot of trial and error to figure out which worked over Teamviewer and Xorg)
# https://www.xpra.org/xorg.conf sample config from xpra who seems to use the dummy driver a lot (thanks guys!)
Section "Device"
Identifier "dummy_videocard"
View fixshards.php
<?php
$helpopts = array(
'host:' => 'Host/IP of the Elasticsearch node that runs the REST API',
'port::' => '(optional) Port for the Elasticsearch node',
'node:' => 'Node name for the Elasticsearch Indice',
'pretend' => 'Show sample of the to be dispatched POST Data',
'help' => 'Shows the available options'
);
@terwey
terwey / gist:0594905cd03e472679ff
Created Feb 19, 2015
PHP Imagick (ImageMagick) TIFF to JPG
View gist:0594905cd03e472679ff
// So ImageMagic is pretty cool, -but- it can sometimes consider a TIFF
// to be "metadata" that should be part of your thumbnailed JPG.
$Thumb = new \Imagick();
$Thumb->setResolution(72,72); // set the DPI of $Thumb to 72dpi, it's the WEB!
$data = file_get_contents('/data/some_image.jpg'); // secretly a TIFF pretending to be a JPG
// else make $data be something that came from curl_exec
$Thumb->readImageBlob($data);
$Thumb->setCompressionQuality(80); // you know, why have a 100compression quality thumbnail?
$Thumb->resampleImage(72,72,imagick::FILTER_UNDEFINED,1); // VERY IMPORTANT, without this it'll just "set" the DPI
View gist:cdfd063d09d5c5ab8981
/*
This method sets the Description of a Location
@todo add fail callbock method and throw exception as notification
*/
$(document).ready(function() {
$("a[data-role=updateLocationDescription]").click(function() {
var reference = $(this);
var form = $('form#update-location-description-form');
var anchorData = jQuery.parseJSON($(this).attr('data-json'));
@terwey
terwey / PHP5.4 - Ubuntu-Lucid.md
Created Sep 2, 2013
Ubuntu 10.04 Lucid upgrade PHP 5.3.2 to PHP 5.4.19-1 (+ Ioncube)
View PHP5.4 - Ubuntu-Lucid.md

PHP 5.4 woes on Ubuntu 10.04 Lucid

So I was having an issue on a VPS I rent that it was on Ubuntu 10.04 LTS. They seem to have a different idea of what LTS means then what seems reasonable. Having your packages available for 5 years isn't something I'm waiting for, I can also still get Debian Buzz with no issues so that's not an argument. What I want is -support- for -updates- on an -existing- platform. Luckily, I don't have to travel far to the Ubuntu team to slap some sense in them because luckily people run their own PPA's that do compile software for existing OS installs.

However, I kept running into an issue that most posts and gists kept referring to PPA's that no longer supported Ubuntu 10.04 Lucid by now... Found a few PPA's but they named their packages like php54 and libapache2-mod-php54 which causes Ubuntu 10.04 Lucid with Plesk installed to throw you a giant headache cause it wants to remove Plesk specific packages (cause it's only compatible with libapache2-mod-php5 and php5)

Getting to i

@terwey
terwey / part1.md
Last active Feb 1, 2017
Newscoop 4.2 - A Simple Plugin
View part1.md

Newscoop 4.2 - a Simple Plugin

Just like you I am extremely excited about the release of [Newscoop 4.2] and the new [Symfony Bundles] plugin system. In the following few steps I will demonstrate to you how to get started creating a super simple Plugin for [Newscoop 4.2].

Prerequisites

  • Motivation (we won't get anywhere if you don't have this!)
  • Your favourite code editor
  • Git client
  • (S)FTP Client for connecting to your server
  • Some knowledge of how to use the Terminal
@terwey
terwey / spicy_pretzel_pieces.txt
Last active Dec 15, 2015
Recipe for Spicy Pretzel Pieces PS: I live in Germany so getting 'Brezeln' is not so hard. These are basically the sourdough pretzels frozen ;)
View spicy_pretzel_pieces.txt
Spicy Pretzel Pieces
Pretzels:
1 pack of fresh 'Brezeln', any brand will do.
Marinade:
240ml oil (I used sunflower)
1-2 teaspoons of Cayenne Pepper
2-3 dining spoons 'Kühne Schäfer Feuerig-Scharfe Chilisauce mit Habanero Chili'
1 envelope 'Knorr Salat Krönung Cremig "American"'
@terwey
terwey / update_releases.patch
Created Feb 7, 2013
NewzNab's update_releases patch to increase the speed for Stage 7 Apply with: patch -p0 < update_releases.patch
View update_releases.patch
Index: www/lib/releases.php
===================================================================
1492c1492
< if (preg_match("/\*$/i", $regexrow["groupname"]))
---
> if ('*' == substr($regexrow["groupname"], -1)) // twisted // if (preg_match("/\*$/i", $regexrow["groupname"]))
1603a1604
>
1905a1907
> /*
You can’t perform that action at this time.