Skip to content

Instantly share code, notes, and snippets.

@bitbonsai
bitbonsai / code-editor-rules.md
Created February 7, 2025 20:55 — forked from yifanzz/code-editor-rules.md
EP12 - The One File to Rule Them All

[Project Name]

Every time you choose to apply a rule(s), explicitly state the rule(s) in the output. You can abbreviate the rule description to a single word or phrase.

Project Context

[Brief description ]

  • [more description]
  • [more description]
  • [more description]
@bitbonsai
bitbonsai / geo.js
Created December 1, 2023 01:10
Serverless function that returns continent from Cloudfare Pages
export function onRequest(context) {
return new Response(JSON.stringify({
continent: context.request.cf.continent
}))
}
@bitbonsai
bitbonsai / getcontinent.js
Created December 1, 2023 01:05
Get continent from serverless function in Cloudfare pages and show/hide content
// Localized content
const showContentByContinent = (continent) => {
const contentElements = document.querySelectorAll('.content')
if (['NA', 'OC', 'EU'].includes(continent)) {
contentElements.forEach(div => {
if (div.classList.contains(continent)) {
div.classList.remove('hid')
} else {

Numbered lists

  1. Item number 1
  2. Item number 2

Using only 1.

  1. Item number 1
  2. This also uses 1., but will render as 2.
  3. This is also 1., but will render as 3.
@bitbonsai
bitbonsai / async.js
Last active December 19, 2018 07:47
// or even better: https://blog.risingstack.com/mastering-async-await-in-nodejs/
// https://github.com/iagodahlem/clima-cli/blob/master/src/utils/weather.js
// https://github.com/axios/axios
async function f() {
let result = await e(1500);
let output = await d(result);
git branch --no-color | while read sha ref; do
git branch -D $sha
done
@bitbonsai
bitbonsai / .fun_npm_update.sh
Created June 2, 2018 07:09
Update all npm global packages
function npm_update() {
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f2)
do
npm -g install "$package"
done
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>test</title>
</head>
<body>
<style>
me at node1 in ~
NSS_SDB_USE_CACHE=YES strace -fc -e trace=access curl 'https://foobar.booking.com/' > /dev/null
Process 14247 attached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000009 0 32 30 access
------ ----------- ----------- --------- --------- ----------------
100.00 0.000009 32 30 total
me at node1 in ~
NSS_SDB_USE_CACHE=YES strace -fc -e trace=access curl 'https://foobar.booking.com/' > /dev/null
Process 14247 attached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000009 0 32 30 access
------ ----------- ----------- --------- --------- ----------------
100.00 0.000009 32 30 total