Skip to content

Instantly share code, notes, and snippets.

View tvdsluijs's full-sized avatar

Theo van der Sluijs tvdsluijs

View GitHub Profile
@tvdsluijs
tvdsluijs / image_resizer.py
Created December 13, 2018 14:50
Python script for resizing images easy
'''
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 01-12-2018
Script to resize images to one or multiple sizes
You need 3 folders for this script
/done_images/
@tvdsluijs
tvdsluijs / fake_jekyll_posts.py
Created December 12, 2018 18:32
Fake posts generator for Jekyll. With sections, headers and images.
'''
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 11-12-2018
This script uses the "md_data" folder to save the files in to
Make sure this folder exists where your run this script
Fake images by : https://imgplaceholder.com/
@tvdsluijs
tvdsluijs / scrapy.py
Created October 4, 2018 04:46
Scraping contact data from a site
import requests
from bs4 import BeautifulSoup
import re
from lxml import html
from urllib.parse import urlsplit
import csv
class getAddress:
def __init__(self, url=None, filename="contacts.cvs"):
if url is not None:
@tvdsluijs
tvdsluijs / json_to_csv_woocommerce.py
Last active December 4, 2019 00:57
Class to create csv from json for Woocommerce
import json
import requests
import csv
import datetime
class WooCommerceCVS:
def __init__(self):
self.woo_sfields = ['title', 'sku', 'price', 'description']
@tvdsluijs
tvdsluijs / medium2Markdown.py
Last active March 5, 2021 16:20
Python script to turn your Medium export into Markdown Files. More info https://www.itheo.nl/2018-07-python-convert-medium-export-to-markdown-files/
# sudo -H pip install xlrd
# pip install beautifulsoup4
# maybe you should install the above python items
import time
import logging
import os
import urllib
import sys
@tvdsluijs
tvdsluijs / functions.php
Last active July 14, 2018 09:48
Show invoice column in Woocommerce orders in Wordpress
<?php #if copy past to function, remove this line
/**
* Adds 'Profit' column header to 'Orders' page immediately after 'Total' column.
*
* @param string[] $columns
* @return string[] $new_columns
*/
function tvdsluijs_add_order_invoice_column_header( $columns ) {
@tvdsluijs
tvdsluijs / pagination.html
Created July 11, 2018 12:48
Better pagination for Jekyll on Github pages, also see :
{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page %}
<a class="ml-1 mr-2" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">&laquo; {{site.str_previous_page}}</a>
{% else %}
<span>&laquo; {{site.str_previous_page}}</span>
{% endif %}
{% assign page_start = paginator.page | minus: site.pagination_nr %}
{% assign page_end = paginator.page | plus: site.pagination_nr %}
@tvdsluijs
tvdsluijs / DutchDate.html
Created July 7, 2018 09:28
Short code to show the Dutch date in Jekyll Liquid on Github
<!--
Add this to your _config.yml
months:
- Januari
- Februari
- Maart
- April
- Mei
- Juni
- July
@tvdsluijs
tvdsluijs / wordpresslinks.php
Last active March 27, 2016 06:35
So you want a list of links on your site from posts from another wordpress blog? Use this little script!
@tvdsluijs
tvdsluijs / mongodb_backup_tar_s3.sh
Created August 11, 2015 10:00
Better MongoDB backup script and move to S3 Bucket
#!/bin/bash
#add right params at [PARAM]
export LC_ALL=C
BAK="/opt/backup"
TIMESTAMP=`date +%F-%H%M`
S3_BUCKET_NAME=[BUCKET_NAME]
S3_BUCKET_PATH=[BUCKET_PATH]