Skip to content

Instantly share code, notes, and snippets.

View arjanfrans's full-sized avatar

Arjan Frans arjanfrans

View GitHub Profile
@arjanfrans
arjanfrans / gist:362df0cb1cf4dec8aae01724b346bf47
Created May 10, 2024 13:20
delete-next-27-lines-from-line-5.csv
title,type,number,orderDate,customerAvisoContact.id,customerAvisoContact.lastName,customerAvisoContact.firstName,customerAvisoContact.fullName,customerAvisoContact.email,customerAvisoContact.phone,customerAvisoContact.formOfAddress,customerAvisoContact.title,sendPurchaseOrder,shippingCosts,netShippingCosts,surcharge,netSurcharge,currency,isTaxFree,deliveryAddress.id,deliveryAddress.street,deliveryAddress.state,deliveryAddress.number,deliveryAddress.zip,deliveryAddress.country,deliveryAddress.city,deliveryAddress.originalAddressId,invoiceAddress.id,invoiceAddress.street,invoiceAddress.state,invoiceAddress.number,invoiceAddress.zip,invoiceAddress.country,invoiceAddress.city,invoiceAddress.originalAddressId,totalPrice,totalNetPrice,customerAccount.id,customerAccount.name,customerAccount.mainContact.id,customerAccount.mainContact.lastName,customerAccount.mainContact.firstName,customerAccount.mainContact.fullName,customerAccount.mainContact.email,customerAccount.mainContact.phone,customerAccount.mainContact.formOf
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20130206112827 extends AbstractMigration
@arjanfrans
arjanfrans / gist:7bbd1f800b0c4a07c4c048f4bf4fd73f
Last active April 2, 2022 14:42
Get curl download commands for all links on a page
function printDownloadLinks(){
var output = '';
var pdfs = document.querySelectorAll("body > center > table > tbody > tr > td > a")
for(var i=0; i<pdfs.length; i++) {
var link = pdfs[i].href;
var name = link.split('/').reverse()[0];
output += `curl -O ${link} -A "Mozilla/4.0\n\n"`
}
/**
* Find all url's and turn them into hyperlinks if they are not already.
*/
public function urlsToHyperlinks(string $text): string
{
return preg_replace(
'~(?<!href=[\'"])https?://[\w/._\-&;=?]*(?!</a>)(?=[^\w/._\-&])~s',
'<a href="$0" target="_blank" rel="noopener noreferrer">$0</a>',
$text
);
@arjanfrans
arjanfrans / cleanup-local-git-branches.md
Last active May 7, 2019 07:32
Cleanup local git branches

Cleanup local git branches that are not on the remote.

git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@arjanfrans
arjanfrans / cronjobs-in-docker.md
Last active October 27, 2022 11:22
Cronjob debugging in Docker
  1. Does the file end with an empty line? The crontab files must end with an empty line.
  2. Are the file permissions correct? The cron process might not be able to read the files. (Have atleast chmod 644)
  • Example problem:
    • I copied a file into the docker container inside the Dockerfile.
    • I did an sed -i replace inside my entypoint (which causes the file to be newly created).
    • The cronjob was not executed.
    • I fixed it by setting chmod 600 after the sed -i replace.
  1. Inside crontab and /etc/cron.d/ (system crontabs) the cron jobs must have a user specified, for example: * * * * * www-data <job>.
  2. Is cron running in the foreground (cron -f) when running inside a docker container?
  3. When running in docker; use something like Supervisor to start it in the foreground. Otherwise it won't work.
@arjanfrans
arjanfrans / FindTmxParser.cmake
Created September 6, 2015 21:30
FindTmxParser.cmake
# Copyright (c) 2014 Andrew Kelley
# This file is MIT licensed.
# See http://opensource.org/licenses/MIT
# TMXPARSER_INCLUDE_DIR
# TMXPARSER_LIBRARY
# TMXPARSER_FOUND
find_path(TMXPARSER_INCLUDE_DIR NAMES tmxparser/Tmx.h
PATHS