Skip to content

Instantly share code, notes, and snippets.

View johnnypea's full-sized avatar
🏠
Working from home

Ján Bočínec johnnypea

🏠
Working from home
View GitHub Profile
@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.

@radermacher
radermacher / boost.js
Last active August 28, 2023 10:55 — forked from b-nnett/boost.js
Arc ChatGPT Boost
// fork of https://gist.github.com/b-nnett/2749adb44566239e4c85ad1a8937c2bc
// origin by @B_nnett → https://twitter.com/joshm/status/1648346253355282432?s=20
/*
To set up this boost for chat.openai.com:
1) open Arc browser and login at chat.openai.com.
2) Head over to the + button in your sidebar and select New Boost.
Or hit ⌘ + T and type New Boost into your Command Bar.
3) Click the `Code` button.
@ttscoff
ttscoff / lexers.rb
Last active June 6, 2023 21:54
Find the perfect lexer to highlight your fenced code blocks and other fancy stuff. If you know the common name of a language or a common file extension for it, this script will tell you exactly what most syntax highlighters will recoghize.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
# Have you ever been adding code to a Markdown post and
# wondered what syntax label would give you the right
# highlighting for your fenced code block? This script can
# take either a file extension or a common name of a language
# and let you know what lexers are supported for it, as well
@barvian
barvian / index.svelte
Last active January 23, 2023 17:36
Vite plugin for SvelteKit
<script context="module" lang="ts">
import type * as $types from './$types'
export const csr = false
export const getData = (async (event) => {
return {
server: event.data.server,
client: 'client data!'
}
@omar2205
omar2205 / +page.svelte
Created January 15, 2023 12:03
Update status action - a toggle/switch action to send a form action
<script lang="ts">
import { updatestatus } from '$lib/UpdateStatus'
import type { PageData } from './$types'
export let data: PageData
</script>
{#each data.users as user}
<input
name="status"
@29decibel
29decibel / build.mjs
Created March 8, 2022 17:51
Use Svelte in Phoenix the simple way
import esbuild from "esbuild";
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";
import { readdir } from "fs/promises";
async function allSvelteComponents() {
const baseDir = "./js/app/";
const all = await readdir(baseDir);
return all.filter((f) => f.endsWith(".svelte")).map((f) => `${baseDir}${f}`);
}
@filiplikavcan
filiplikavcan / deep-compare.js
Last active February 4, 2022 15:37
Recursively compares two javascript variables and ignores order of array items and object properties
function compare(a, b) {
if (a instanceof Array && b instanceof Array) {
return a.length === b.length &&
a.length === a.filter(function (e1) {
return b.some(function (e2) {
return compare(e1, e2);
})
}).length;
}
@ciaranmcnulty
ciaranmcnulty / notes.md
Last active March 25, 2024 06:36
Notes on using Docker on ARM Macs (November 2021)

Docker for Mac

On M1 machines, Docker for Mac is running a lightweight linux ARM VM, then running containers within that, so containers are essentially running natively. Don't be fooled by the fact the UI or binary CLI tools (e.g. docker) might require Rosetta.

Within that VM is an emulation layer called QEmu. This can be used by docker to run Intel containers. This does not use Rosetta at all, and has a roughly 5-6X performance penalty. (If you just upgraded your CPU this may result in a similar performance to your old machine!)

Pulling and running with Docker

Many images in public registries are multi-architecture. For instance at the time of writing on Docker Hub the php:8.0-cli image has the following digests:

@howellcc
howellcc / backupHubitat.sh
Last active April 30, 2024 23:13
Backup script for Hubitat Elevation that runs on Synology NAS
#!/bin/bash
#https://gist.github.com/howellcc/70f5c45a9902f9a3fe4e566ceedf1bca
#This is a backup script that I'm running on my Synology NAS to back up my Hubitat Elevation.
he_login=[Hubitat Username]
he_passwd=[Hubitat Password]
he_ipaddr=[Hubitat IP Address]
backupdir='[Backup Location]' #no trailing space
hubname='Hubitat' #in case you have multiple hubs
@silverbackdan
silverbackdan / OrSearchFilter.php
Last active July 12, 2023 09:30
The API Platform filter will allow you to pass a query `or[field1,field2]=value` to search multiple fields for a search value. It works by using the standard API Platform SearchFilter as a basis, and wrapping all of your OR queried inside a single AND query so you can combine with other where bys
<?php
declare(strict_types=1);
namespace App\Filter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use App\Entity\Term;