Skip to content

Instantly share code, notes, and snippets.

View tombola's full-sized avatar

Tom Readings tombola

  • Freelance
  • Devon
View GitHub Profile
@tombola
tombola / wc_rest_api_decorator.py
Last active February 8, 2023 13:24
Decorator to make multiple requests to WooCommerce REST API to get paged results
from woocommerce import API
WC_MAX_API_RESULT_COUNT = 100
wcapi = API(
url=url,
consumer_key=key,
consumer_secret=secret,
version="wc/v3",
timeout=300,
@tombola
tombola / install-vscode-extensions.sh
Created March 2, 2022 12:37
Install useful VScode extensions
# Install some useful VScode extensions, focussed on python/django development
code --install-extension adpyke.vscode-sql-formatter --force &
code --install-extension AlDuncanson.react-hooks-snippets --force &
code --install-extension alefragnani.Bookmarks --force &
code --install-extension AndreyVolosovich.monokai-st3 --force &
code --install-extension anseki.vscode-color --force &
code --install-extension batisteo.vscode-django --force &
code --install-extension bibhasdn.django-html --force &
code --install-extension bigonesystems.django --force &
code --install-extension bmewburn.vscode-intelephense-client --force &
@tombola
tombola / controlshift-auth.postman_environment.json
Created November 4, 2021 12:17
Control Shift API - auth environment variables
{
"name": "Control Shift Auth",
"values": [
{
"key": "CS_REST_CLIENT_SECRET",
"value": "",
"enabled": true
},
{
"key": "CS_REST_CLIENT_ID",
@tombola
tombola / controlshift.postman_collection.json
Last active November 4, 2021 12:15
Control Shift API - postman collection
{
"info": {
"name": "Control Shift",
"description": "For this collection of requests to authenticate, you will need to add a couple of additional variables to an 'environment' and activate that.\n\n- `CS_REST_CLIENT_ID`\n- `CS_REST_CLIENT_SECRET`",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "CS: Unauth JSON",
"item": [
"""
Example usage:
dj shell < wagtail_list_allowed_subpages.py
Returns markdown formatted list of which page types can be added under which.
"""
def list_valid_page_subpages(readable=False, shorten=False):
from wagtail.core.models import Page

How do wagtail and django relate?

Django

is a web framework

Used by Instagram, Spotify, The Washington Post, loads of other big and small sites.

There are lots of different ways you can use python. Your end goal might be to use python to process data from spreadsheets, bulk edit a load of images, or analyse genetic code, anything really.

<script src="https://rca.accessplanit.com/accessplansandbox/NetLibrary/ClientScripts/webintegration.js"></script>
<script type="text/javascript">
console.log('script ran')
var courseOptions = {
ListID: 'courses',
CourseIDs: [731014],
CompanyID: "ROYALC9RCH",
CategoryIDs: []
}
var opportunityOptions = {
@tombola
tombola / csv_splitter.py
Last active November 8, 2019 10:48 — forked from jrivero/csv_splitter.py
A Python CSV splitter
import os
def split(filehandler, delimiter=',', row_limit=10000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True, verbose=False):
import csv
reader = csv.reader(filehandler, delimiter=delimiter)
current_piece = 1
current_out_path = os.path.join(
output_path,
output_name_template % current_piece

Keybase proof

I hereby claim:

  • I am tombola on github.
  • I am treadings (https://keybase.io/treadings) on keybase.
  • I have a public key ASC6_K6y-8coEJ4YZ33imFalIQWh0gdrpA7pFM52QvNtDgo

To claim this, I am signing this object:

@tombola
tombola / sshhosts.sh
Created January 8, 2018 17:22
List ssh aliases
# list ssh host aliases
alias sshhosts="grep -w -i "Host" ~/.ssh/config | sed 's/Host//' | sed 's/[[:blank:]]//g'"
sshhosts | grep '<part-of-host-name>'