Skip to content

Instantly share code, notes, and snippets.

@miguelmota
miguelmota / terminal.go
Created December 18, 2018 22:25
Golang terminal package example
package main
import (
"bufio"
"fmt"
"os"
"unicode"
"golang.org/x/crypto/ssh/terminal"
)
----------------------------------------
Setup Install HAProxy 1.8 on Ubuntu 16
----------------------------------------
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:vbernat/haproxy-1.8
sudo apt-get update
apt-cache policy haproxy
sudo apt install haproxy
sudo update-rc.d haproxy enable
@tabjy
tabjy / ws.js
Created March 11, 2021 00:31
WebSocket from scratch. In Node.js
const http = require('http')
const crypto = require('crypto')
const server = http.createServer((req, res) => {
console.log('got request', req.url)
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('okay')
})
server.on('upgrade', function (req, socket) {
@notlin4
notlin4 / without-auth_e-book_tutorial_免登入電子書教學.md
Last active March 28, 2024 15:49 — forked from aliyaliu368/without-auth_e-book_tutorial_免登入電子書教學.md
教學用電子書與相關工具免登入教學 | 本指令碼用於繞過臺灣電子書與教學工具的前端身分驗證,達成不需要教師帳號即可使用。支援 翰林、南一、康軒、何嘉仁 四大出版社 | 請勿將本指令碼作為抄答案、侵權等惡意用途,使用本指令碼,請自行承擔所有後果與風險

教學用電子書與相關工具免登入教學

使用本指令碼即代表你同意本免責聲明

免責聲明

請勿將本指令碼作為抄答案、侵權等惡意用途,使用本指令碼,請「自行承擔」所有後果與風險。

簡介

本指令碼用於繞過臺灣電子書與教學工具的前端驗證,達成不需要教師帳號即可使用。

@jboner
jboner / latency.txt
Last active March 28, 2024 15:49
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@OrionReed
OrionReed / DOM3D.js
Last active March 28, 2024 15:49
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@joelstransky
joelstransky / custom-file-size-units.js
Last active March 28, 2024 15:45
Custom Intl.NumberFormat units
sizeFormatter = new Intl.NumberFormat([], {
style: "unit",
unit: "byte",
notation: "compact",
unitDisplay: "narrow",
});
(_bytes) => {
const units = { B: " bytes", KB: " kb", MB: " mb", GB: " gb", TB: " tb" };
const parts = sizeFormatter.formatToParts(_bytes);
@rap2hpoutre
rap2hpoutre / laravel-forge-deploy.sh
Last active March 28, 2024 15:45
Laravel Forge deploy script without downtime
# stop script on error signal
set -e
# remove old deployment folders
if [ -d "/home/forge/deploy" ]; then
rm -R /home/forge/deploy
fi
if [ -d "/home/forge/backup" ]; then
rm -R /home/forge/backup
fi
@cassidoo
cassidoo / base-css.md
Created May 4, 2022 06:37
Base CSS for a plain HTML document

If you don't want to deal with styling a mostly text-based HTML document, plop these lines in and it'll look good:

html {
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  font-size: 1.3em;
  max-width: 40rem;
  padding: 2rem;
  margin: auto;
 line-height: 1.5rem;
@tanaikech
tanaikech / submit.md
Created December 3, 2020 07:08
Sample Scripts for Creating New Event with Google Meet Link to Google Calendar using Various Languages

Sample Scripts for Creating New Event with Google Meet Link to Google Calendar using Various Languages

This is the sample scripts for creating new event with Google Meet link to Google Calendar using various languages. When I saw the official document of "Add video and phone conferences to events", in the current stage, I can see only the sample script for Javascript. But I saw the several questions related to this for various languages. So I published the sample scripts for creating new event with Google Meet link to Google Calendar using various languages.

In order to create new event with Google Meet link to Google Calendar, it is required to set the request body and query parameter as follows.

Please add the following object to the request body.

conferenceData: {