Skip to content

Instantly share code, notes, and snippets.

View bonniss's full-sized avatar
🥐
Cancer - Croissant

Dan Teddy bonniss

🥐
Cancer - Croissant
View GitHub Profile
@bonniss
bonniss / github-search-cheatsheet.md
Last active March 18, 2025 16:53
Github search cheatsheet from official docs.

Github Search Cheat Sheet

GitHub’s search supports a variety of different operations. Here’s a quick cheat sheet for some of the common searches.

For more information, visit our search help section.

Basic search

Geo Location 101

Tips apply globally with a few adjustments depending on the hemisphere. Here's how you can recognize latitude and longitude anywhere:

Latitude and Longitude

1. Latitude (Vĩ độ) — Measures North-South

  • Ranges: -90° to 90°
  • Northern Hemisphere (N): Positive (0° to 90°) → e.g., Vietnam, USA, Europe
  • Southern Hemisphere (S): Negative (0° to -90°) → e.g., Australia, Argentina

In useSWR, both isLoading and isValidating represent states of the data-fetching process, but they serve different purposes:


isLoading

  • Definition: Indicates the very first fetch for the given SWR key.
  • State: true only when there is no cached data and the fetch is in progress.
  • Lifecycle:
    • Active during the initial fetch when no data exists.
  • Becomes false once data is fetched or available in the cache.
@bonniss
bonniss / better-sqlite3-cheatsheet.md
Last active December 9, 2024 00:07
better-sqlite3 cheatsheet

Refs:

// Init new db
// If the database file does not exist, it is created
// This happens synchronously, which means you can start executing queries right away
const Database = require('better-sqlite3');
@bonniss
bonniss / postgres-cheatsheet.md
Last active October 8, 2024 14:03 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Connect to DB

psql -U postgres

# then enter password for user `postgres`
@bonniss
bonniss / AppAgencyRole.java
Last active August 4, 2024 18:38
Entity sample sinh bởi JHipster
package vn.ric.dragon.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.io.Serializable;
import java.time.Instant;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.domain.Persistable;
@bonniss
bonniss / swap-space-ubuntu-guide.md
Last active June 16, 2024 15:07
Guide to add Swap Space on Ubuntu

Guide to add Swap Space on Ubuntu

Tested on Ubuntu Server 18.04, 20.04

  • Swap is a portion of hard drive storage that has been set aside for the OS to temporarily store data that it can no longer hold in RAM.
    • The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data.
  • Though the information written to disk will be significantly slower than information kept in RAM, the OS will prefer to keep running application data in memory and use swap for the older data.

It is believed that placing swap partitions on an SSD drive is not advisable, as it may harm the device. Actually, the write-cycle on modern SSDs is good enough that you'll likely replace the drive before it becomes a problem. Read this Reddit post, these AskUbuntu [one](https://askubuntu.com/questions/652337/why-are-swap-partitions-discouraged-on-ssd-drives-a

@bonniss
bonniss / esm-package.md
Created June 9, 2024 13:38 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@bonniss
bonniss / ts-setup.md
Last active June 4, 2024 07:24
A lean Typescript setup for Node.js development

Typescript setup for Node.js development

1. Initialize the Project

First, create a new directory for your project and initialize it with npm.

mkdir my-tool
cd my-tool
npm init -y
@bonniss
bonniss / sample-watercss.html
Created January 9, 2024 12:09
Beautiful sample HTML page - grab and replace your NGINX default site!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css"
/>
<title>Beautiful Sample Page</title>