Skip to content

Instantly share code, notes, and snippets.

View borlaym's full-sized avatar

Marton Borlay borlaym

  • Budapest, Hungary
View GitHub Profile
@borlaym
borlaym / pixel.js
Last active October 7, 2025 08:19
Updated Shopify Web Pixel code for Snowplow
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//cdn.jsdelivr.net/npm/@snowplow/javascript-tracker@4/dist/sp.js","snowplow"));
async function hashStringSHA256(inputString) {
const encoder = new TextEncoder();
const data = encoder.encode(inputString);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}
type FiveCardModular = {
name: 'FiveCardModular',
}
type FourCardModular = {
name: 'FourCardModular',
}
type HorizontalList = {
name: 'HorizontalList',
@borlaym
borlaym / curated-front-page-final-data.js
Last active December 16, 2019 14:28
Final type of data structure for curated front page
type SideHeader = {
type: 'SideHeader',
title: string,
useLogo? : boolean,
description? : string,
customImage: SimpleImage,
links: Array <{
url: string,
text: string
}>
@borlaym
borlaym / curated-front-page-data.js
Last active December 2, 2019 17:06
Curated front page
// Here is the proposed data structure for the new home page, which consists entirely of these modules.
// Here is a wip doc for the modules: https://docs.google.com/document/d/1eA8CZmEVfwge3oNBOyD1YCiK1UIz2HXLbnBmdRzPYps/edit#
// A single blog would have an array of these modules
// HELP WANTED: help us find a freakin name for these CurationBlocks that make sense and doesn't conflict with anything
// we have currently.
type CurationBlock = {
id: CurationBlockId, // We store an id for each one so when you edit it, we can save based on id and not index
layout: string, // enum, each layout has its own name
autofill?: { // If this is not undefined, the module will autofill and ignore the cards array (for now)
@borlaym
borlaym / DeletedEmbedJSON.js
Created October 3, 2019 14:03
DeletedEmbedJSON Exact
export type DeletedEmbedJSON = {|
type: 'DeletedEmbed',
originalContent: {type?: string},
deletedReason: ?DeletedReason
|};
@borlaym
borlaym / DeletedEmbedJSON.js
Created October 3, 2019 13:50
DeletedEmbedJSON
export type DeletedEmbedJSON = {
type: 'DeletedEmbed',
originalContent: {type?: string},
deletedReason: ?DeletedReason
};
@borlaym
borlaym / DeletedEmbedJSON.js
Created October 3, 2019 13:50
DeletedEmbedJSON
export type DeletedEmbedJSON = {
type: 'DeletedEmbed',
originalContent: {type?: string},
deletedReason: ?DeletedReason
};
@borlaym
borlaym / issue.js
Created October 3, 2019 13:45
The issue
get featuredVideoUrl(): ?string {
if (this.featuredMedia && this.featuredMedia.id) {
let videoParams;
switch (this.featuredMedia.type) {
case 'YoutubeVideo':
videoParams = {
id: `youtube-video-${this.featuredMedia.id}`,
start: this.featuredMedia.start
};
break;
@borlaym
borlaym / solution.js
Created October 3, 2019 13:18
The solution
function getKinjaVideoForPost(post: Post): Array<string> {
const videoNodes = post.body.reduce<Array<KinjaVideoJSON>>((acc, n) => {
if (n.type === 'KinjaVideo') {
return [...acc, n];
}
return acc;
}, []);
return videoNodes.map(vn => vn.id);
}
@borlaym
borlaym / issue.js
Created October 3, 2019 13:07
The issue
function isKinjaVideo(blockNode: BlockNodeJSON): boolean {
return blockNode.type === 'KinjaVideo';
}
export default function getKinjaVideoForPost(post: Post): Array<string> {
const videoNodes = post.body.filter(n => isKinjaVideo(n));
return videoNodes.map(vn => vn.id);
}