This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tryParseJson(string) { | |
try { | |
const output = JSON.parse(string); | |
if (output && typeof output === "object") { | |
return output; | |
} | |
} catch {} | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get -y install sysbench | |
sysbench --test=cpu --cpu-max-prime=20000 run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. /etc/os-release | |
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list | |
curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add - | |
sudo apt update | |
sudo apt -y install podman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fastify = require("fastify"); | |
const sqlite3 = require("sqlite3"); | |
const { nanoid } = require("nanoid"); | |
const app = fastify(); | |
const db = new sqlite3.Database(":memory:"); | |
db.serialize(); | |
db.run(` | |
CREATE TABLE data ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Begin..." | |
sudo dd if=/dev/zero of=/swapfile bs=128M count=16 | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo swapon -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt update && sudo apt install certbot python-certbot-nginx | |
sudo certbot --nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
box-sizing: border-box; | |
} | |
[class^=col-] { | |
flex: 0 0 100%; | |
padding: 0 15px; | |
} | |
.container { | |
max-width: 540px; | |
margin: 0 auto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _QUEUE_H | |
#define _QUEUE_H | |
#undef min | |
#undef max | |
#include <queue> | |
template <class T> | |
class Queue { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function withTimeout(fn, ms = 400) { | |
return new Promise(async (resolve, reject) => { | |
setTimeout(() => { | |
reject(); | |
}, ms); | |
resolve(await fn()); | |
}); | |
} | |
async function delay(ms = 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Fragment } from "preact"; | |
import { useState, useLayoutEffect } from "preact/hooks"; | |
import { createPortal } from "preact/compat"; | |
export default ({ children, into }) => { | |
const [target, setTarget] = useState(null); | |
useLayoutEffect(() => { | |
setTarget(document.querySelector(into)); | |
}, []); |
NewerOlder