Skip to content

Instantly share code, notes, and snippets.

View greggnakamura's full-sized avatar

Gregg Nakamura greggnakamura

View GitHub Profile
@greggnakamura
greggnakamura / random-code-samples.njk
Last active March 3, 2021 22:18
Nunjucks: Random code samples
{# render component #}
{% render '@carousel' %}
{# render component with arguments #}
{% render '@hyperlink', {
url: '/path/to/page',
link_text: 'Learn more',
aria_label: 'Learn more about this item',
target: '_blank',
aria_describedby: 'new-window' }
@greggnakamura
greggnakamura / slickjs-a11y-fixes.js
Last active December 20, 2019 18:16
Slick JS A11y `listbox`, `aria-selected`, `aria-describedby`, add `role="option"
/* a11y fixes */
// a11y fixes: init
var $slickSlide = $('.slick-slide');
// a11y fixes: set aria attributes
$slickSlide
.attr('role', 'option')
.attr('aria-selected', 'false')
.removeAttr('aria-describedby');
@greggnakamura
greggnakamura / bizform-transformation.ascx
Created December 4, 2019 15:17
Kentico: Bizform in Transformation with conditional visibility of repeater content
<script runat="server">
protected override void OnDataBinding(EventArgs e)
{
ModalBizForm.FormName = Eval<string>("HorizontalCTABizform");
ModalBizForm.ReloadData();
}
</script>
<div class="col-12 col-md-6 col-lg-4 mb-3 mb-lg-0">
<asp:placeholder runat="server" Visible='<%# Eval<string>("HorizontalCTADisplayAs") == "link" %>'>
@greggnakamura
greggnakamura / space-usage.sql
Created November 12, 2019 21:21
SQL: Get space usage of all tables
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
@greggnakamura
greggnakamura / rename.sql
Created November 12, 2019 21:21
SQL Server: Rename DB with alter and rename
USE [master]
alter database exeterHospital
set single_user with rollback immediate;
Go
alter database exeterHospital modify name = exeterHospital_prep_for_9_to_10_upgrade
GO
alter database exeterHospital_prep_for_9_to_10_upgrade set multi_user
Go
@greggnakamura
greggnakamura / web.config
Created August 20, 2019 19:49
web.config: IIS clientCache example
<location path="App_Themes">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
</system.webServer>
</location>
<system.webServer>
<staticContent>
@greggnakamura
greggnakamura / ClonedCustomTableForm.ascx.cs
Last active October 4, 2018 20:14
Kentico: Custom Table `ItemKeyName` set to non-Primary key
/* default */
form.ItemID = QueryHelper.GetInteger(ItemKeyName, 0);
/* by `ItemGUID` */
var ItemKeyNameID = QueryHelper.GetGuid(ItemKeyName, Guid.Empty);
/* option 1: get `ItemID` by custom table generated code */
/* saved code will be placed in /App_Code/CMSClasses */
@greggnakamura
greggnakamura / slickjs.js
Last active August 28, 2018 15:07
slickjs: Carousel with thumbs, `pauseVideo` on slide change
// virtual map: handle playing of slickjs videos when slides change
// slickjs: main
$('.slickjs-media').slick({
accessibility: true,
focusOnSelect: true,
pauseOnFocus: true,
pauseOnHover: true,
arrows: false,
fade: true,
@greggnakamura
greggnakamura / video-autoplay.html
Created May 22, 2018 17:54
HTML: Video `autoplay` with `promise` and `muted` default
<video id="ouazPromo" muted autoplay>
<source src="https://www.ottawa.edu/OttawaU/media/OttawaSurprise/Video/OUAZPromo.mp4" type="video/mp4" />
<source src="https://www.ottawa.edu/OttawaU/media/OttawaSurprise/Video/OUAZPromo.webm" type="video/webm" />
<source src="https://www.ottawa.edu/OttawaU/media/OttawaSurprise/Video/OUAZPromo.ogv" type="video/ogg" />
</video>
<button id="unmuteButton" class="sr-only"></button>
<script>
var promise = document.getElementById('ouazPromo').play();
@greggnakamura
greggnakamura / query-repeater-joins.sql
Created May 17, 2018 21:33
Kentico: QueryRepeater JOINS
SELECT 0 AS TableID -- IFDA_Event Identifier
,EventTitle AS Title
,EventSummary AS EventSummary
,AlignContent AS AlignContent
,EventLocation AS LocationTopic
,EventDate AS ItemDate
,EventDateEnd AS ItemDateEnd
,FeaturedEvent AS Featured
,EventBannerImage AS BannerImage
,EventFacility AS Facility