This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
// Set is a simple set implementation using a map. | |
type Set[T comparable] map[T]struct{} | |
// NewSet creates and returns a new Set. | |
func NewSet[T comparable]() Set[T] { | |
return make(Set[T]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose' | |
import { mainSchema } from '../schemas.js' | |
/** | |
* @type {import('moleculer').ServiceSchema} | |
*/ | |
// eslint-disable-next-line import/prefer-default-export | |
export const mongoDbMixin = { | |
name: 'mongoDbMixin', | |
async started() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import winston from 'winston'; | |
export const logger = winston.createLogger({ | |
format: winston.format.json(), | |
transports: [new winston.transports.Console()], | |
}); | |
export const snsClientBuilder = (token) => { | |
const client = axios.create({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const managers = [ | |
{ name: "Manager 1", weight: 0.6, tasks: 0 }, | |
{ name: "Manager 2", weight: 0.2, tasks: 0 }, | |
{ name: "Manager 3", weight: 0.1, tasks: 0 }, | |
{ name: "Manager 4", weight: 0.1, tasks: 0 } | |
]; | |
// Create a cumulative weight array | |
let cumWeight = 0; | |
for (let i = 0; i < managers.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum update -y && amazon-linux-extras install epel -y && yum install p7zip -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use | |
// .className | |
// @include fluidFontSize(12, 60, 320, 1440) | |
// | |
@function calcFluidFontSize($f-min, $f-max, $v-min, $v-max) | |
$k: ($f-max - $f-min)/($v-max - $v-min) | |
$b: $f-min - $k * $v-min | |
$b: $b * 1px | |
@return calc( #{$k} * 100vw + #{$b} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shuffleArray(array) { | |
for (let i = array.length - 1; i > 0; i--) { | |
const j = Math.floor(Math.random() * (i + 1)); | |
[array[i], array[j]] = [array[j], array[i]]; | |
} | |
} |