Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bitbonsai's full-sized avatar

Mauricio Wolff bitbonsai

View GitHub Profile
@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
while (true); do
echo "$graphite_name_space.$(hostname|sed -e 's/\./_/g').dentry $(sudo slabtop -o | egrep 'dentry'|awk '{print $1}') $(date '+%s')"| nc 127.0.0.1 3002;
sleep 0.9;
done