Skip to content

Instantly share code, notes, and snippets.

@StefanoChiodino
StefanoChiodino / commit-message
Last active January 5, 2023 11:39
Prefix commit messages with Jira ticket ID
#!/usr/bin/env python3
""" Finds a Jira ticket ID from the branch name and prefixes the commit message with it.
It won't add it if it was already found in the message.
Warns if it can't find the ticket ID.
TO INSTALL
Copy this file into your .git/hooks folder for each local repository.
Make sure to make it executable with: chmod +x .git/hooks/prepare-commit-msg.
Test with an empty commit: git commit --allow-empty -m "test"
python_regex = "((\\w{2,}\\.){2,}(\\w{2,}))";
path_regex = "(\\w+\\/){2,}(\\w+\\.\\w+)(:\\d+)?";
code_style = {}
code_style[DocumentApp.Attribute.FONT_FAMILY] = 'Courier New';
function styleMatches(regex) {
doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
match = null;
while (true) {
// Add a "on edit" trigger.
function onEdit(e) {
e.range
.setFontSize(10)
.setFontFamily("Arial");
}
@StefanoChiodino
StefanoChiodino / git_commit_sizes.py
Last active April 6, 2022 08:51
get all commits sizes in a file
#!/usr/bin/env python3
import csv
import subprocess
import sys
git_rev_list = subprocess.check_output(
"git log --no-merges --pretty='%H|%an|%aI|%s' origin/master".split(" ")).decode(
sys.stdout.encoding).rstrip().splitlines()
with open('commit_stats.csv', 'w', ) as file_handler:
$(document).ready(function () {
function scrollToFormIfInteractedWith() {
// Find a target to scroll to if the user is interacting with forms. This happens in different ways:
// - Find a submit message that is not wrapped in a form (the message is always present even when not visible
// as the form has just been loaded.
// - If the message wasn't found then try to target a form containing a hidden field that indicates that the form's
// step/page is not the first(0) one.
// - If that wasn't found either then try to find a form that has PreviousClicked = true where the user just
// navigated back. This is CURRENTLY NOT WORKING possibly because of an Umbraco Forms issue for which I've raise
@StefanoChiodino
StefanoChiodino / ErrorPageGeneratorEventHandlers.cs
Last active January 28, 2021 19:16
Generate a static html error page from umbraco dynamic one to make it more resilient
public class ErrorPageGeneratorEventHandlers : ApplicationEventHandler
{
private static readonly object Lock = new object();
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
GenerateStaticErrorPage();
ContentService.Published += (sender, args) => GenerateStaticErrorPage();
let get_sponsored_context = () => document.querySelector("div[aria-label=Sponsored]").parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector("div[aria-label='Actions for this post']");
let get_hide_this_ad = () => document.querySelector("[role=menuitem]");
let get_close_dialog = () => document.querySelector("div[role=dialog] [aria-label=Close]");
function click_close_dialog() {
let close_dialog = undefined;
try { close_dialog = get_close_dialog(); } catch{ }
if (close_dialog) {
console.log("Close dialog found.")
close_dialog.click();
TRUNCATE TABLE [dbo].[UFRecordDataBit]
TRUNCATE TABLE [dbo].[UFRecordDataDateTime]
TRUNCATE TABLE [dbo].[UFRecordDataInteger]
TRUNCATE TABLE [dbo].[UFRecordDataLongString]
TRUNCATE TABLE [dbo].[UFRecordDataString]
-- Delete allows to remove rows with constraints, in this case we removed all rows
-- that may reference these just above, but the server wouldn't know!
DELETE FROM [dbo].[UFRecordFields]
TRUNCATE TABLE [dbo].[UFRecords]
// Click actions dropdown.
$("#contentcolumn > div > div > form > div > div.umb-editor-header.umb-panel-header.ng-scope > div > div > div > div.umb-editor-header__actions-menu > div > a").click();
setTimeout(() =>
{
// Click the delete item.
$("#contentcolumn > div > div > form > div > div.umb-editor-header.umb-panel-header.ng-scope > div > div > div > div.umb-editor-header__actions-menu > div > ul > li:nth-child(1) > a").click();
setTimeout(() =>
{ // Click checkbox to confirm.
$("#old-dialog-service > div > div > ng-switch > div > label > input").click();
setTimeout(() => $("#old-dialog-service > div > div > ng-switch > div > div > div > div > a.btn.btn-primary.ng-scope > localize").click(), 200);
@StefanoChiodino
StefanoChiodino / Umbraco-DTGE-CssScoping.js+cs
Created January 11, 2019 16:15
Umbraco document type grid editor CSS scoping
.pipe(scopeCss('.umbraco-backend-scope'))
.pipe(insert.prepend(fs.readFileSync(path.resolve(__dirname, 'src/sass/_cms.scss'), { encoding: 'utf8' })))
.pipe(rename({
suffix: '-scoped'
}))