Skip to content

Instantly share code, notes, and snippets.

@wdzajicek
wdzajicek / last-mod-time.rb
Last active June 15, 2021 19:48
Create a sitemap in a Jekyll project with 2 files
# Save this file in your Jekyll `_plugins/` dir
Jekyll::Hooks.register :pages, :pre_render do |page|
# get the page's last modified time
modification_time = File.mtime( page.path )
# inject modification_time into page's data.
page.data['last-mod-time'] = modification_time
end
@wdzajicek
wdzajicek / json-to-markdown-files.js
Created February 24, 2021 14:59
Hack a SharePoint 2013 list into individual markdown files w/ YAML front-matter
// Save file as index.js and run with node:
// node index.js
// =================================================================================================================== //
// We have an old SharePoint 2013 site that has over 2,400 articles created with a single sharepoint-list that grew over the years
// We needed to backup all these articles so we could ditch our dying, ancient CMS
// This "hack" was needed to rescue/migrate our massive list from the grips of SharePoint 2013
// =================================================================================================================== //
// To use:
// Create an RSS feed from the SharePoint 2013 list
// Convert the RSS feed into a JS object using an online converter e.g. <https://rsstojson.com>
@wdzajicek
wdzajicek / random_string.sh
Last active December 19, 2020 02:52
Terminal random password generator
# Create a random string of characters that are safe for passwords
## Terminal random password generator
## The "translate characters" (`tr`) command didn't work on my Mac without prepending with `LC_ALL=C`
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 13 ; echo
## Change the length of the outputed string by adjusting the number at the end of the command: `| head -c 13 ; echo`
## The line of code above will generate a random string that is 13 characters long.
## 16 chars would end with: `| head -c 16 ; echo`
@wdzajicek
wdzajicek / hard-line-breaks-in-markdown.md
Last active December 3, 2020 00:37
Creating hard line breaks in markdown files

Methods for making linebreaks in markdown

The linebreak is pretty essential element in content,
yet it's hard to find info about creating them in Markdown.

HTML line break

foo <br>
bar
Spreadsheet must be "Published" to view the JSON feed:
Go to "File" > "Publish to web..." to publish
https://spreadsheets.google.com/feeds/list/<SPREADSHEETID#>/od6/public/basic?alt=json
Where <SPREADSHEETID#> is the unique spreadsheet ID like: 1zBMYYFRJLLgUu9XKR8voz37o5Nz1dMVAdfy3cj3W_PI
Example:
This link goes to the first sheet in the workbook with the above ID
https://spreadsheets.google.com/feeds/list/1zBMYYFRJLLgUu9XKR8voz37o5Nz1dMVAdfy3cj3W_PI/od6/public/basic?alt=json
<!doctype html>
<!-- Automatically create a table, formated w/ thead & tbody, from a Google Sheet -->
<!-- Based from Gist: https://gist.github.com/terrywbrady/a03b25fe42959b304b1e#file-googlespreadsheet-html -->
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script type="text/javascript">
var spData = null; // Set to null in-case the data is not there
function doData(json) { // There's a callback on this function ( 'https://...&callback=doData' ) the end of the spreadsheet URL inside a script tag in the page
spData = json.feed.entry; // Set it to the json feed of the sheet
<!doctype html>
<!-- From Gist: https://gist.github.com/terrywbrady/a03b25fe42959b304b1e#file-googlespreadsheet-html -->
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}
@wdzajicek
wdzajicek / web.config
Created November 6, 2018 20:49
Prevent Caching in IIS Servers!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</configuration>
<style>
//add bellow styles to only display in CC editor interface
// ==============================================================
.editor-link {
display: none;
}
.cms-editor-active .editor-link {
display: block;
}
@wdzajicek
wdzajicek / gist:150ead3f48be74d8c89b3b3a431cd093
Created July 24, 2018 14:38
Have Terminal Echo Characters That Must Be Escaped
#!/bin/bash
# Save this code as 'bashreg.sh' and run it in terminal `$ sh bashreg.sh`
special=$'`!@#$%^&*()-_+={}|[]\\;\':",.<>?/ '
for ((i=0; i < ${#special}; i++)); do
char="${special:i:1}"
printf -v q_char '%q' "$char"
if [[ "$char" != "$q_char" ]]; then
printf 'Yes - character %s needs to be escaped\n' "$char"
else
printf 'No - character %s does not need to be escaped\n' "$char"