Skip to content

Instantly share code, notes, and snippets.

import * as fsPromises from 'node:fs/promises'
import * as fs from 'node:fs'
import * as path from 'path'
import { SourceMapConsumer } from 'source-map'
import * as archiver from 'archiver'
async function readHarFile(fileName) {
const harFileContent = await fsPromises.readFile(fileName, 'utf8')
const harFile = JSON.parse(harFileContent)
return harFile
@craftamap
craftamap / keyboard-color.lua
Created January 21, 2024 13:16
nvim colored keyboard
vim.api.nvim_create_autocmd("ModeChanged", {
callback = function ()
local new_mode = vim.v.event.new_mode
local color = ""
if new_mode == "n" or new_mode == "nt" then
color = "1e66f5"
elseif new_mode == "i" or new_mode == "t" then
color = "40a02b"
elseif new_mode == "c" then
color = "fe640b"
@craftamap
craftamap / main.go
Created December 15, 2021 12:50
REST API pagination with generics in go 1.18beta1
package main
import (
"encoding/json"
"log"
"net/http"
)
type Spaceship struct {
Name string `json:"name"`
{
"aboutConfig": {
"creditsURL": "https://github.com/teamulster/soHappy",
"feedbackURL": "https://github.com/teamulster/soHappy",
"imprintURL": "https://github.com/teamulster/soHappy",
"issueURL": "https://github.com/teamulster/soHappy",
"licenseURL": "https://github.com/teamulster/soHappy",
"privacyURL": "https://github.com/teamulster/soHappy"
},
"imageAnalyzerConfig": {
@craftamap
craftamap / markdown.css
Created July 15, 2020 09:31
Good looking markdown css
@media print {
@page {
margin: 0;
}
body {
margin: 2.5cm;
}
}
img {
#!/usr/bin/bash
#
# This script transcodes the input video into x265 30fps
#
INPUT=$1
SEC=$2
[[ -f "$INPUT" ]] || (echo "No input file specified" && exit 1)
[ -z "$SEC" ] && OUTPUT="${INPUT%.*}.mp4" || OUTPUT="$SEC"
@craftamap
craftamap / middleware-example.go
Created June 6, 2020 20:23
Golang Middleware Example
package main
import (
"fmt"
"net/http"
"net/url"
"os"
"github.com/gorilla/context"
"github.com/gorilla/handlers"
import requests
import json
from bs4 import BeautifulSoup
BASE_URL = "https://coinmarketcap.com/currencies/{currency}/historical-data/"
def main():
url = BASE_URL.format(currency="bitcoin")
payload = {
@craftamap
craftamap / fonts.conf
Last active October 7, 2019 11:02
Emoji-Support🎉🥳 for Fira Code on Linux: Add this to your fontconfig (~/.config/fontconfig.conf) (Tested with Konsole on Arch Linux and Ubuntu 18.04)
<fontconfig>
...
<match target="pattern">
<test qual="any" name="family"><string>monospace</string></test>
<edit name="family" mode="assign" binding="same"><string>Iosevka Custom</string></edit>
<edit name="family" mode="append" binding="weak"><string>JoyPixels</string></edit>
</match>
...
</fontconfig>