Skip to content

Instantly share code, notes, and snippets.

View nuke66's full-sized avatar

nuke nuke66

  • Brisbane, Australia
  • 08:03 (UTC +10:00)
View GitHub Profile
@nuke66
nuke66 / qualtrics_dl.py
Last active November 7, 2023 22:40
Python - Qualtrics download and BigQuery upload POC
"""
qualtrics_dl.py
Download survey data from Qualtrics using the API to CSV files. Upload CSV data into tables into BigQuery.
Environment vars need to be defined for the following, these can be put into a .env file in the project directory
QUALTRICS_API_TOKEN
QUALTRICS_SURVEY_ID
QUALTRICS_DATA_CENTER
GOOGLE_APPLICATION_CREDENTIALS
@nuke66
nuke66 / .env
Created November 7, 2023 22:11
python example .env file for dotenv library
QUALTRICS_API_TOKEN = <api token>
QUALTRICS_DATA_CENTER = <data center id>
QUALTRICS_SURVEY_ID = <survey id>
GOOGLE_APPLICATION_CREDENTIALS = "\\path\\filename.json"
@nuke66
nuke66 / log.conf
Last active November 7, 2023 22:12
Python - example logger configuration file
[loggers]
keys=root,processingLogger
[handlers]
keys=fileHandler,consoleHandler,errorHandler
[formatters]
keys=fileFormatter,consoleFormatter,errorFormatter
[logger_root]
@nuke66
nuke66 / sticky-section.js
Created August 17, 2023 22:19
Sticky header/footer in a section where you cannot use sticky css property
/*
* sticky-section.js
*
* Implements a sticky header for sections. The header turns sticky within the section.
* Tagged anchor links in the header
*
* Tag the container that wraps the sticky header and the sections with the class 'js-sticky-section-area'
* Tag the container for the header that is to become sticky with 'js-sticky-section-header'
* Tag the anchor links to the sections with 'sticky-section__link'
*
@nuke66
nuke66 / SC-get-item.py
Created September 20, 2022 01:39
Python - example of calling ItemService REST API in Sitecore
# test to access Sitecore items through Python
#
# https://data.bangtech.com/python/python-consume-sitecore-itemservice.htm
import requests
import json
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # disable warning messages about insure connections
sHost = "https://sdi101sc.dev.local/sitecore/api/ssc/"
@nuke66
nuke66 / download-img.py
Created September 19, 2022 13:15
Python - read input file of image urls and save images to target directory
# Read a .txt file containing image urls, extract the name and save it in the target directory.
#
# download-img.py [target directory] [input filename]
#
# Example:
# > python Z:\xtemp\download-img.py .\4793224 4793224.txt
#
#
import requests
@nuke66
nuke66 / RHC-hostnames.py
Created September 9, 2022 00:13
Python - Extract site records from a Sitecore.config file
# RHC-hostnames.py - Pull out <site> data from a Sitecore.config file
# You will need to install the BeautifulSoup package -> https://pypi.org/project/beautifulsoup4/
# Beautiful Soup documentation -> https://www.crummy.com/software/BeautifulSoup/bs4/doc/
#
from datetime import datetime
import csv
import sys
import os
from bs4 import BeautifulSoup
from dataclasses import dataclass
@nuke66
nuke66 / gist:c4394c1d731f0d558f4cab1368d0d7a8
Created October 7, 2021 02:16
Rasp Pi - set up bluetooth keyboard / mouse
I was unable to connect my Logitect BT keyboard and mouse using the gui, instead I followed these instructions:
https://www.digikey.com.au/en/maker/blogs/raspberry-pi-wi-fi-bluetooth-setup-how-to-configure-your-pi-4-model-b-3-model-b
STEPS
(keyboard)
In a terminal start bluetooth control
@nuke66
nuke66 / tv-csv.py
Last active June 7, 2022 23:35
Python - Scrapes summary page from a Total Validator Pro report producing a csv file containing each page and their summary error/warning stats.
# tv-csv.py - Total Validator CSV output. Report to dump the page stats from the TotalValidator report, in this case all the pages for an entire website.
# You will need to install the BeautifulSoup package -> https://pypi.org/project/beautifulsoup4/
# Beautiful Soup documentation -> https://www.crummy.com/software/BeautifulSoup/bs4/doc/
#
# 7-Jun-22 - Updates for latest version of Total Validator, put in checks to stop operations on empty datasets
from datetime import datetime
import csv
import sys
import os
@nuke66
nuke66 / git-reset.md
Last active December 15, 2020 01:17
git reset

This has saved my life so many times. Typically I have made a commit against develop branch by accident which I need to get rid of but also want to keep the changes in the commit so I can apply them to the correct branch. This is for local commits, you may have to set other options if you have pushed the commit to remote.

In Git Bash (and in the branch you want to roll back) this will roll back the last commit.

git reset --soft HEAD~1

Doco for git-reset https://git-scm.com/docs/git-reset