This file contains hidden or 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 _ from "lodash"; | |
| import { useState, useLayoutEffect, useMemo } from "preact/hooks"; | |
| export const useModel = (origin) => { | |
| const [model, setModel] = useState(origin); | |
| function reset() { | |
| setModel(_.cloneDeep(origin)); | |
| } |
This file contains hidden or 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
| #include <iostream> | |
| void toJSON() { | |
| std::string json; | |
| int prependComma = 0; | |
| int rows = 0; | |
| auto _beginBlock = [&] () { prependComma = 1; rows = 0; }; | |
| auto _endBlock = [&] () { prependComma = 0; rows = 0; }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 { |
NewerOlder