Skip to content

Instantly share code, notes, and snippets.

View emmiep's full-sized avatar

Emmie Päivärinta emmiep

View GitHub Profile
@emmiep
emmiep / tailwind-config.json
Created February 11, 2024 13:34
Tailwind 3.4.1 base configuration
{
"theme": {
"accentColor": {
"inherit": "inherit",
"current": "currentColor",
"transparent": "transparent",
"black": "#000",
"white": "#fff",
"slate": {
"50": "#f8fafc",
@emmiep
emmiep / input.scss
Last active May 17, 2023 09:11
Generated by SassMeister.com.
@use "sass:math";
$type-size-root: 14px;
$type-ratio: 7px / 6px;
$type-names: (
50: -2,
75: -1,
100: 0,
200: 1,
300: 2,
@emmiep
emmiep / validate.js
Created July 2, 2021 17:49
JS validate date
function validateDate(year, month, day) {
const date = new Date(year, month, day);
if (year !== date.getFullYear() || month !== date.getMonth() || day !== date.getDate()) {
throw new Error('Invalid date');
}
return date;
}
@emmiep
emmiep / hljs-languages.json
Created July 1, 2021 11:08
Highlight.js language aliases
{
"languages": {
"1c": {
"aliases": [
"1c"
]
},
"abnf": {
"aliases": [
"abnf"
@emmiep
emmiep / graphcms-loader.js
Created June 29, 2021 18:48
GraphCMS image loader for Next.js example
// GraphQL query
const GetPhotos = gql`
query GetPhotos {
assets {
id
url
width
height
}
@emmiep
emmiep / graphql.config.js
Created May 27, 2021 14:29
VSCode next+graphql setup
/** @typedef {import("graphql-config").IGraphQLConfig} IGraphQLConfig */
const {loadEnvConfig} = require('@next/env');
loadEnvConfig(__dirname, true);
/** @type IGraphQLConfig */
const config = {
schema: process.env.GRAPHCMS_ENDPOINT,
extensions: {
@emmiep
emmiep / nodemon.json
Last active May 31, 2020 10:17
Nodemon watch go server
{
"execMap": {
"go": "go run {{filename}} || exit 1"
},
"ext": "go"
}
@emmiep
emmiep / hexbytes.go
Created April 15, 2020 18:58
Hex byte array JSON encoding
package main
import (
"encoding/hex"
"encoding/json"
"fmt"
)
type HexEncodedByteArray []byte
@emmiep
emmiep / Dockerfile
Created March 3, 2020 19:12
Caddy cross-platform Docker build
FROM --platform=${BUILDPLATFORM} golang:1.14 AS build
ARG TARGETOS
ARG TARGETARCH
ARG caddy_version=v1.0.4
ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
WORKDIR /usr/local/src/caddy
COPY ./main.go ./
@emmiep
emmiep / instance_typeof.cr
Created November 20, 2019 13:33
Using typeof with instance methods in Crystal
require "json"
class Container(T)
getter value : T
def initialize(@value)
end
end
def new_container(json : String, t_class : T.class) : T forall T