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 / rename-files-auto-increment.py
Last active June 19, 2022 08:42
This script takes a folder and renames all the files to the same name with auto increment numbers. It keeps the extensions of each file unchanged. Great for renaming images!
'''
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 22-12-2018
This script takes a folder and renames all the files
to the same name with auto increment numbers.
It keeps the extensions of each file unchanged
@tvdsluijs
tvdsluijs / gist:3019b478325b3ed0e0d2
Created January 9, 2015 19:04
Mongodb php aggregation $match $or $and combined usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
//create the aggregation
//create the Match on clothing-category = shoes or brand = nike AND size 37
$ops = array(
array(
'$match' => array('$or' => array(array("category" => 'shoes'),
array("brand" => 'nike')),
@tvdsluijs
tvdsluijs / slimmemeterportal.nl.py
Last active April 19, 2021 07:43
Small script to get your energy data from the slimmemeterportal.nl
import requests
import calendar
import time
import datetime
from bs4 import BeautifulSoup
username = "" # fill in your slimmemeterportal username
password = "" # fill in your password
start_year = "" # fill in the year your started measurements
@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 / gist:7e1589b042b55d39ea94
Created January 9, 2015 19:51
Mongodb php aggregation $match between dates $gte $tle
$today = strtotime(date('Y-m-d 00:00:00'));
$yesterday = strtotime(date('Y-m-d 00:00:00', (time() - 24 * SECONDS_PER_HOUR)));
$m = new MongoClient(); // connect to local mongodb
$db = $m->orders; //select 'mongo database' named orders
$items_col = $db->items; //create a collection from the 'table' ordered items
@tvdsluijs
tvdsluijs / sudoku_solve.py
Created September 25, 2020 14:54
Sudoku solver
# SuDoKu Solver in Python
# With special thanks to Computerphile (Danke Thorsten!)
# https://www.youtube.com/watch?v=G_UYXzGuqvM FUN TO WATH
# Make a list of each row of Sudoku numbers, empty = 0
# Put each list (row) in a list and run!
import sys
@tvdsluijs
tvdsluijs / bulk-export.yml
Created July 2, 2020 12:25
Screaming Frog -bulk-export list of names and filenames (when using command line)
bulk_exports:
-
file: all_inlinks.csv
name: All Inlinks
-
file: all_outlinks.csv
name: All Outlinks
-
file: queued_urls.csv
name: Queued URLs
@tvdsluijs
tvdsluijs / img_ocr.py
Created July 2, 2020 12:10
Get text from Images with python and pytesseract
import sys
import pytesseract
from pathlib import Path
from glob import glob
from os.path import join
class ImageOcr:
def __init__(self, my_path: Path = None):
@tvdsluijs
tvdsluijs / jekyll2medium.py
Last active January 31, 2020 07:39
Import all you Markdown Jekyll files to Medium
import requests
import json
import os
import re
import yaml
class ImportMDs:
def __init__(self, m_token=None, git_username=None):
try:
@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']