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 / pdf_compressor.py
Created March 29, 2019 15:02
Compress PDF files with python
#!/usr/bin/env python3
"""
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
Forked date: 2018-01-07 / First version MIT license -- free to use as you want, cheers.
Original Author: Sylvain Carlioz, 6/03/2017
@tvdsluijs
tvdsluijs / find_and_replace_in_files.py
Created February 26, 2019 16:29
Search and replace text within files within a folder.
'''
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 26-02-2019
With this script you can search within a folder and files for some text and replace it with other text.
Extra install:
For the fun of it I used the Halo spinner package to show a nice progress spinner
@tvdsluijs
tvdsluijs / turtle_race.py
Last active February 18, 2019 07:58
turtle race
# code for a course Im doing
# https://www.futurelearn.com/courses/object-oriented-principles/6
from turtle import Turtle
from random import randint
def myturtles(color, start, end):
tur = Turtle()
tur.color(color)
tur.shape('turtle')
@tvdsluijs
tvdsluijs / read_time.html
Created February 14, 2019 06:06
jekyll reading time display
<!--Put this file in your _includes folder and just call it as an include-->
<span class="time-to-read">
{% assign words = content | number_of_words %}
{% if words < 360 %}
1 min
{% else %}
{{ words | divided_by:180 }} mins
{% endif %}
</span>
@tvdsluijs
tvdsluijs / page_view_google_analytics.py
Created January 4, 2019 16:35
Get page views and unique views from google analytics
"""
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 11-12-2018
please put your client_screts.json in the same folder as this file.
You need the oauth2client and google-api-python-client for this to work.
@tvdsluijs
tvdsluijs / send_files_with_gmail.py
Created January 3, 2019 06:43
Send files with gmail
"""
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 02-01-2019
Small script to send mails with attachment from folder with Gmail
Uses nothing but python 3 modules.
@tvdsluijs
tvdsluijs / fractions_calculator.py
Created December 28, 2018 19:51
Small fractions python calculator
"""
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 28-12-2018
Small script for calculating simple Fractions
Klein script om breuken uit te rekenen.
Calculates fractions like
@tvdsluijs
tvdsluijs / python_sqlite_row_keys.py
Created December 26, 2018 14:28
Small script for creating database, filling database en getting row or rows with key names
"""
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 25-12-2018
Small tutorial how to get the column names with your row of values
You need the sqlite3 for this to work.
It's installed together with your python
@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 / getImageColors.py
Created December 20, 2018 06:35
This script gets all colors from an image and displays then in the terminal in rgb and hex values (with coloring!) Just place your image or images in a folder. Set the action for one or multiple (list) files And run the script. Sit back and relax
'''
author: Pure Python
url: https://www.purepython.org
copyright: CC BY-NC 4.0
creation date: 20-12-2018
This script gets all colors from an image
and displays then in the terminal in rgb and hex values (with coloring!)
Just place your image or images in a folder.