This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # better verion of simultaneous fill ranges on a neo pixel ring | |
| led = ['-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'] | |
| def print_led(): | |
| for x in led: | |
| print(x,end='') | |
| print() | |
| def fill(start, end, color='*', bgcolor='-'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl "https://dmhguatsc9-solr.azurewebsites.net/solr/dmhg_filtermetadata_master_index/select?fl=filter_type:filtergroupname_s,filter_name:_name,%20metadata:filtermetadata_sm&fq=haschildren_b:false&q=_templatename:FilterDataItem&rows=1000&sort=filtergroupname_s%20asc,%20_name%20asc&wt=csv" -o metadata_uat.csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime, time, timedelta | |
| ex={} | |
| ex[1] = datetime.today() # current time | |
| ex[2] = datetime.now() # current time but with additional tz param | |
| ex[3] = datetime(year=2020,month=1,day=15) # 15Jan2020 date with time of 00:00:00 | |
| ex[4] = datetime(2020,1,15,23,59,59,999999) # date with time 23:59:59.999999 | |
| ex[5] = datetime.combine(datetime.now(),time(hour=20,minute=30)) # combine datetime + time, todays date @ 20:30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Print format examples | |
| [pos][sign][width][.precision]type | |
| Positional args | |
| < left aligned | |
| > right aligned | |
| 0 leading zeroes | |
| , comma for thousands symbol | |
| = padding after sign but before numeric value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # MDE (MetaData Enhance) - enhance CSV metadata file dump from DoH | |
| from datetime import datetime | |
| # from utils import keyCount | |
| import csv | |
| import sys | |
| import os | |
| """ | |
| Use this curl to query the Solr index and generate the JSON input file. # TODO fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Example of calling functions by reference, with some not easy to read code. | |
| """ | |
| # define our functions | |
| def square(x): | |
| return x*x | |
| def cube(x): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get the current loop count | |
| myList = ['zero','one', 'two', 'three', 'four', 'five'] | |
| for idx, x in enumerate(myList): | |
| print(f"{idx}:{x}") # "0:zero", "1:one", "2:two"... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Email regex with TLD min of 2 chars long | |
| var validateEmail = function (email) { | |
| return /^[^\s@]+@[^\s@\.]+(\.[^\s@\.]{2,})+$/.test(email); | |
| }; | |
| console.log(validateEmail("r.ora@nowhere.co.uk")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Lists and slicing example | |
| """ | |
| # Append value | |
| x=['a','b','c'] | |
| x.append('d') # ['a','b','c','d'] | |
| # Append list | |
| x=['a','b','c'] | |
| y=['x','y','z'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * YouTube iframe hook | |
| * | |
| * Attaches to a tagged YouTube iframe element so we can detect when the video has been watched and take action. In this case update the user profile in Sitecore. | |
| * Handles multiple elements. Does not require url to contain the enablejsapi parameter. Identifies the player via the id of the iframe element and the YouTube video embed code. | |
| * | |
| */ | |
| function onYouTubeIframeAPIReady() { | |
| $(() => { | |
| const IframeElements = $("iframe .youtube-iframe-hook"); |
OlderNewer