Skip to content

Instantly share code, notes, and snippets.

View arielsalminen's full-sized avatar
🌸

Ariel Salminen arielsalminen

🌸
View GitHub Profile
@arielsalminen
arielsalminen / clamp.js
Last active October 24, 2022 19:00
getContrastRatio.js
/*
* Clamp util.
*/
const clamp = (val, min, max) => {
return Math.min(Math.max(val, min), max)
}
export default clamp
@arielsalminen
arielsalminen / aws-twitter-search-bot.js
Created November 18, 2015 20:25 — forked from russellbeattie/aws-twitter-search-bot.js
AWS Lambda Twitter Search Bot... uses S3 for persistence and SNS to send out messages.
var querystring = require('querystring');
var https = require('https');
var aws = require('aws-sdk');
var s3 = new aws.S3();
var sns = new aws.SNS({
region: 'us-east-1'
});
var query = '#SEARCH TERM HERE';
@arielsalminen
arielsalminen / readme.md
Created August 16, 2022 13:10
Lit vs. Stencil.js

Some of you who have followed our previous design systems adventures on Twitter might know that both me (Viljami) and Nick Williams, our newest Frontend Developer, have a long experience working with Stencil and Web Components. So you naturally might wonder why are we migrating away from Stencil?

Please note that this isn’t meant to be an advice against Stencil. Stencil has its place in the ecosystem, and depending on your company’s needs it can still be an amazing tool. Heck, I even wrote an article praising the tool a couple years back. With Nord Design System, it mainly came down to these reasons:

  • For developers Stencil is a bit of a “black box” in certain cases and it often requires a lot of digging via the source code to understand specifically why something works like it does. We prefer trans
@arielsalminen
arielsalminen / search.js
Last active April 6, 2022 14:07
Demo of how we create a JSON based search index and search functionality for Nord Design System’s Eleventy based documentation at https://nordhealth.design/
/* eslint-disable no-undef */
;(function (window, document) {
"use strict"
/**
* The Nord Documentation object
*
* @constructor
*/
function NordDocs() {
@arielsalminen
arielsalminen / figma-project-stats.js
Created March 22, 2022 18:30 — forked from rsms/figma-project-stats.js
Script that generates statistics for a Figma project, like number of files, frames, versions etc
//
// Figma project stats
// Pulls statistics like number of files, frames, versions etc for a project.
//
// Usage:
// export FIGMA_API_ACCESS_TOKEN='your-token'
// node figma-project-stats.js <project-id>
//
// You can generate tokens in your account settings or at
// https://www.figma.com/developers/explorer#personal-access-token
/* ---------------------------------------------
/ RESET STYLES
/ --------------------------------------------- */
html,body,div,span,h1,h2,h3,h4,h5,p,blockquote,
pre,a,code,img,svg,small,strike,strong,sub,sup,
b,u,i,ol,ul,li,form,label,table,caption,tbody,
tfoot,thead,tr,th,td,main,article,aside,canvas,
input,footer,header,nav,section,time,button,
video,textarea,input {
function onOpen(e) {
SlidesApp.getUi()
.createMenu("Custom Fonts")
.addItem("Georgia", "formatText")
.addToUi();
}
function formatText() {
var selection = SlidesApp.getActivePresentation().getSelection();
if (selection) {
---
permalink: search.json
eleventyExcludeFromCollections: true
---
{"search" : [
{%- for page in collections.all %}
{
"url" : "{{ page.url }}",
"title" : "{% if page.data.title %}{{ page.data.title }}{% else %}Nord Design System{%- endif -%}",
@arielsalminen
arielsalminen / endlessPagination.js
Created May 8, 2012 10:08
Custom endless pagination for isotope (supports query strings in url and updates the page count after each load)
jQuery(function () {
var $feed = $(".feed"),
$trigger = $(".next_page"),
$spinner = $(".spinner"),
spinner = "<div class=\"spinner\"></div>";
var isotopeSettings = {
itemSelector: ".box"
}
@arielsalminen
arielsalminen / converts-webfont-to-base64.js
Last active August 28, 2020 06:07
Convert Google WOFF font to base64 format and inline to <head> of document
// Get binary file using XMLHttpRequest
function getBinary(file) {
var xhr = new XMLHttpRequest();
xhr.open("GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
return xhr.responseText;
}
// Base64 encode binary string