Skip to content

Instantly share code, notes, and snippets.

@branneman
branneman / primitive-reference-types-javascript.md
Last active May 12, 2024 03:45
Primitive Types & Reference Types in JavaScript

Primitive Types & Reference Types in JavaScript

An explanation of JavaScript's pass-by-value, which is unlike pass-by-reference from other languages.

Facts

  • JavaScript has 2 kinds of variable types: primitive and reference.
  • A fixed amount of memory is reserved after creation of every variable.
  • When a variable is copied, it's in-memory value is copied.
  • Passing a variable to a function via a call also creates a copy of that variable.

Primitive Types

@hiepxanh
hiepxanh / style.css
Last active May 12, 2024 03:42
using vscode extension: custom css and js loader
.editor-group-watermark > .letterpress{
background-image: url("https://raw.githubusercontent.com/hiepxanh/hiepxanh/master/Angular.png") !important;
opacity: .75;
}
@mdgrs-mei
mdgrs-mei / ShellIntegration.ps1
Last active May 12, 2024 03:36
Adds escape codes to the prompt for the shell integration
# Reference:
# https://devblogs.microsoft.com/commandline/shell-integration-in-the-windows-terminal/
param
(
[ValidateSet('WindowsTerminal', 'ITerm2')]
[String]$TerminalProgram = 'WindowsTerminal'
)
# Restore hooked functions in case this script is executed accidentally twice
@amosbastian
amosbastian / route.ts
Last active May 12, 2024 03:35
Lemon Squeezy webhook using the new route handler in Next.js 13
import crypto from "crypto";
import { listAllSubscriptions } from "lemonsqueezy.ts";
import { NextRequest } from "next/server";
// Put this in your billing lib and just import the type instead
type LemonsqueezySubscription = Awaited<ReturnType<typeof listAllSubscriptions>>["data"][number];
const isError = (error: unknown): error is Error => {
return error instanceof Error;
};
@ryanhamley
ryanhamley / use-svg-as-icon-image-mapboxgl.js
Last active May 12, 2024 03:35
This gist shows how to use an <svg> element as an icon-image for a Mapbox GL symbol layer
// How to add an SVG as a symbol layer's icon image: https://github.com/mapbox/mapbox-gl-js/issues/5529#issuecomment-340011876
// Also see here: https://stackoverflow.com/a/11765731/2748013 (we need the data url stuff for the image src)
// NOTE: Importing SVGs requires an inline module loader such as https://github.com/webpack-contrib/svg-inline-loader
import template from './templates/marker.svg';
const width = 20;
const height = 40;
const img = new Image(width, height);
// map is your Mapbox GL map object
@Johel-code
Johel-code / comandos.md
Created May 12, 2024 03:35
Notas de comandos Git

Notas de comandos Git

Configuración inicial:

  • git config --global user.name "Tu Nombre": Configura tu nombre de usuario.
  • git config --global user.email "tu@email.com": Configura tu dirección de correo electrónico.

Creación de un repositorio:

@vasanthk
vasanthk / System Design.md
Last active May 12, 2024 03:33
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@fnky
fnky / ANSI.md
Last active May 12, 2024 03:30
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@insdavm
insdavm / wireguard-over-tcp.md
Last active May 12, 2024 03:28
WireGuard over TCP with udptunnel

WireGuard over TCP with udptunnel

udptunnel is a small program which can tunnel UDP packets bi-directionally over a TCP connection. Its primary purpose (and original motivation) is to allow multi-media conferences to traverse a firewall which allows only outgoing TCP connections.

Server

# udptunnel -s 443 127.0.0.1/51820

Client

@ohownew
ohownew / 知识星球视频增强.js
Last active May 12, 2024 03:27
知识星球原生视频组件,无法通过键盘操作前进、后退、暂停、播放,于是写了一个简单的脚本,要先安装好篡改猴Tampermonkey等插件管理器。然后新建脚本,并复制如下代码
// ==UserScript==
// @name 知识星球视频增强
// @namespace http://tampermonkey.net/
// @version 2024-04-21
// @description 知识星球视频,通过键盘控制: 前进 后退 暂停 开始 全屏
// @author ohownew
// @match https://wx.zsxq.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zsxq.com
// @grant none
// ==/UserScript==