Skip to content

Instantly share code, notes, and snippets.

@gurisko
gurisko / functionName.js
Last active May 11, 2024 05:41
[NodeJS] Get the current function name or any other function while using strict mode
'use strict';
const findFirstOccurrence = (string, searchElements, fromIndex = 0) => {
let min = string.length;
for (let i = 0; i < searchElements.length; i += 1) {
const occ = string.indexOf(searchElements[i], fromIndex);
if (occ !== -1 && occ < min) {
min = occ;
}
}
@blixt
blixt / logger_middleware.go
Last active May 11, 2024 05:40
Logger middleware for Go HTTP servers which logs every request with response status code in the Apache format.
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"time"
)
@kennypete
kennypete / navigating_the_modes_of_Vim.md
Created April 18, 2024 20:46
Navigating the modes of Vim

Navigating the modes of Vim

This diagram illustrates navigating through Vim’s modes. It was built factoring Vim 9 (i.e., all its modes, including up to two new modes, cr and cvr, in November 2023). Information about the state() and 'showmode' is provided too.

SVG version

Some features are only available in the SVG version. It is not provided directly from within this gist’s files because SVGs do not always play nicely in GitHub (particularly, refusing to display embedded fonts).

The SVG version includes hover text help, which shows pertinent information about the underlying key, command, mode, etc.

@gyopiazza
gyopiazza / schema.ts
Last active May 11, 2024 05:40
Multi-tenant with Drizzle ORM (multiple sqlite databases) - PoC
import { integer, sqliteTableCreator, text } from 'drizzle-orm/sqlite-core'
const sqliteTable = (tenant?: string) =>
sqliteTableCreator(name => (tenant ? `${tenant}_${name}` : name))
export const users = sqliteTable()('users', {
id: integer('id', { mode: 'number' }).primaryKey({ autoIncrement: true }),
name: text('name'),
})
@JBGruber
JBGruber / docker-compose.yml
Last active May 11, 2024 05:40
My compose file to run ollama and ollama-webui
services:
# ollama and API
ollama:
image: ollama/ollama:latest
container_name: ollama
pull_policy: missing
tty: true
restart: unless-stopped
# Expose Ollama API outside the container stack
@bcheck555
bcheck555 / extractAndGeotagFrames.bat
Last active May 11, 2024 05:39 — forked from Krzysiu/extractAndGeotagFrames.bat
Extract frames from video every X seconds and geotag them using GPS data file. Requires exiftool and ffmpeg. Modified to prep Insta360 video for Streetview.
@echo off
rem Updates to prep Insta360 One X2 video for Streetview upload.
rem Brian Check
rem 13 Mar 2021
rem Ksheesh Geotag Video Frames 0.0.1
rem
rem Extract frames from video every X seconds and geotag them using GPS data file.
rem Requires exiftool and ffmpeg.
@robertwahler
robertwahler / FileIO.jslib
Created April 12, 2018 13:08
UnityEngine.PlayerPrefs wrapper for WebGL LocalStorage
var FileIO = {
SaveToLocalStorage : function(key, data) {
localStorage.setItem(Pointer_stringify(key), Pointer_stringify(data));
},
LoadFromLocalStorage : function(key) {
var returnStr = localStorage.getItem(Pointer_stringify(key));
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
@btoone
btoone / curl.md
Last active May 11, 2024 05:35
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@parmentf
parmentf / GitCommitEmoji.md
Last active May 11, 2024 05:36
Git Commit message Emoji
@IsaacXen
IsaacXen / README.md
Last active May 11, 2024 05:32
(Almost) Every WWDC videos download links for aria2c.