Skip to content

Instantly share code, notes, and snippets.

View SaltyAom's full-sized avatar
💤
Take it easy!

SaltyAom SaltyAom

💤
Take it easy!
View GitHub Profile
@SaltyAom
SaltyAom / es6.html
Last active August 12, 2024 10:23
Wake up babe, new code golf challenge has just drop
<!DOCTYPE html>
<html>
<head>
<title>ES6 Demonstration</title>
<style>
.pager { margin: 5px 10px; user-select: none; -webkit-user-select: none; font-family: sans-serif; }
.pager .page { display: inline-block; padding: 0px 5px; cursor: pointer; }
.pager .page:active { color: red; }
.selected { font-weight: bold; color: red; }
.paged-content { font: bold 250% sans-serif; padding: 25px 10px; }
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run the `open default settings` command
// from the command palette or from `Zed` application menu.
{
"theme": "Catppuccin Latte - No Italics",
@SaltyAom
SaltyAom / serve.ts
Created June 26, 2024 08:23
Bun.serve AbortSignal
Bun.serve({
port: 3000,
async fetch(request) {
request.signal.onabort = () => {
console.log('abort')
// ? Throwing an error will stop the whole process
// throw new Error('abort')
}
@SaltyAom
SaltyAom / spawn.ts
Created April 7, 2024 13:09
Spawn Bun server using multi-process
import { $ } from 'bun'
import { cpus } from 'os'
const total = cpus().length - 1
const ops = []
for (let i = 0; i < total; i++)
ops.push($`NODE_ENV=production bun example/a.ts`)
await Promise.all(ops)
@SaltyAom
SaltyAom / gist:fb4fb0b5cb46429a76ced074aa5222cc
Created August 9, 2023 03:28
(Arc Boost) Replace X with Twitter icon@elon
const twitterIcon = `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 248 204" style="padding: 8px">
<path fill="#1d9bf0" d="M221.95 51.29c.15 2.17.15 4.34.15 6.53 0 66.73-50.8 143.69-143.69 143.69v-.04c-27.44.04-54.31-7.82-77.41-22.64 3.99.48 8 .72 12.02.73 22.74.02 44.83-7.61 62.72-21.66-21.61-.41-40.56-14.5-47.18-35.07 7.57 1.46 15.37 1.16 22.8-.87-23.56-4.76-40.51-25.46-40.51-49.5v-.64c7.02 3.91 14.88 6.08 22.92 6.32C11.58 63.31 4.74 33.79 18.14 10.71c25.64 31.55 63.47 50.73 104.08 52.76-4.07-17.54 1.49-35.92 14.61-48.25 20.34-19.12 52.33-18.14 71.45 2.19 11.31-2.23 22.15-6.38 32.07-12.26-3.77 11.69-11.66 21.62-22.2 27.93 10.01-1.18 19.79-3.86 29-7.95-6.78 10.16-15.32 19.01-25.2 26.16z"/>
</svg>`
document.addEventListener("DOMContentLoaded", () => {
const timer = setInterval(() => {
const element = document.querySelector('a[href="/home"] > div')
if(element.firstChild) clearInterval(timer)
// @see https://github.com/SaltyAom/bun-http-framework-benchmark
use actix_web::{ HttpServer, App, get, post, web::{ Path, Query, Json }, HttpResponse };
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct QueryParams {
name: String
}