Skip to content

Instantly share code, notes, and snippets.

View terwey's full-sized avatar
👋
Available for Hire

Yorick Terweijden terwey

👋
Available for Hire
  • Y Terweijden IT Advice
  • Berlin
View GitHub Profile
@terwey
terwey / protoc-error.md
Created October 31, 2022 15:25
--grpc-gateway_out: 11:1: expected 'IDENT', found 'import'

If you ended up here because of the following error:

--grpc-gateway_out: 11:1: expected 'IDENT', found 'import'

And you noticed the generated Go code was missing the package name, it could be due to the way the go_package is declared.

This works for the go-grpc, if you want to generate it directly into a directory

option go_package = "pinger/";
@terwey
terwey / resolve.md
Last active January 9, 2022 23:50
Greece Passenger Locator Form PDF Print

Greece Passenger Locator Form PDF Print

When attempting to print the provided PDF my printer gave this output

ERROR: undefined
OFFENDING COMMAND: New

STACK:
/AAAAAB+*Times
@terwey
terwey / mds.md
Created January 12, 2021 14:42
macOS mds exclusion list

For some reason macOS reindexes a file if it was read or opened by another program, so cache dirs are heavy offenders. Can be checked with sudo fs_usage mdworker mds

A list to start with, you can add these paths by going to System Preferences then Spotlight and finally Privacy, clicking the + and then doing cmd+shift+g or programatically (see below).

My current list contains the following sudo defaults read /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist Exclusions

NB: Change the /Users/yt to reflect your OWN user.

(
@terwey
terwey / disable.sh
Last active July 21, 2020 10:39
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# sudo mount -uw /
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
# Agents to disable
@terwey
terwey / readme.md
Created June 9, 2019 12:19
Squarespace hack for adding taxes in Javascript.

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 July 24, 2017 15:29
PHP mail with SMTP for Apache/nginx/etc

Setup

apt-get install msmtp

vim /etc/msmtprc

defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt 
# 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"
<?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 February 19, 2015 11:14
PHP Imagick (ImageMagick) TIFF to JPG
// 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
/*
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'));