Skip to content

Instantly share code, notes, and snippets.

View jason-shen's full-sized avatar
🗼
Coding........

Jason Shen jason-shen

🗼
Coding........
View GitHub Profile
@jason-shen
jason-shen / HaversinFormula.go
Created October 28, 2023 15:39 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@jason-shen
jason-shen / instructions.md
Created May 25, 2023 08:21 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@jason-shen
jason-shen / gstreamermixer.md
Last active July 31, 2022 17:01
gstreamer video mix

#gstreamer mixer

gst-launch-1.0 -e \
videomixer name=mix background=1 \
        sink_1::xpos=0   sink_1::ypos=0 \
        sink_2::xpos=200 sink_2::ypos=0 \
        sink_3::xpos=0 sink_3::ypos=100 \
        sink_4::xpos=200 sink_4::ypos=100 \
    ! autovideosink \
//Self-Signed Certificate for using with VS Code Live Server
//Save both files in a location you will remember
1. create a private key
openssl genrsa -aes256 -out localhost.key 2048
// you will be prompted to provide a password
//this will create localhost.key (call it whatever you like)
2. create the certificate
@jason-shen
jason-shen / vim_cheatsheet.md
Created February 21, 2022 11:04 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@jason-shen
jason-shen / webrtc_simulcast.js
Created November 6, 2021 17:45 — forked from hissinger/webrtc_simulcast.js
webrtc simulcast example
document.getElementById("btn").onclick = async () => {
await run();
}
async function run() {
let stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false });
/* sender */
let sender = new RTCPeerConnection();
sender.onicecandidate = e => receiver.addIceCandidate(e.candidate);
@jason-shen
jason-shen / caddy https
Created October 9, 2021 13:10
New Gist
Caddy is ready to serve your site over HTTPS:
Point your domain's A/AAAA DNS records at this machine.
Upload your site's files to /var/www/html.
Edit your Caddyfile at /etc/caddy/Caddyfile:
Replace :80 with your domain name
Change the site root to /var/www/html
Reload the configuration: systemctl reload caddy
Visit your site!
@jason-shen
jason-shen / Docker Compose + NATS example
Created August 15, 2021 12:03 — forked from wallyqs/Docker Compose + NATS example
NATS Docker blog post/HTTP Server
FROM golang:1.6.2
COPY . /go
RUN go get github.com/nats-io/nats
RUN go build api-server.go
EXPOSE 8080
ENTRYPOINT ["/go/api-server"]
@jason-shen
jason-shen / ws.go
Created July 23, 2021 06:56 — forked from bradfitz/ws.go
pre-Go1.12 websocket hijack+proxy
httpsServer := &http.Server{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hj, isHJ := w.(http.Hijacker)
if r.Header.Get("Upgrade") == "websocket" && isHJ {
c, br, err := hj.Hijack()
if err != nil {
log.Printf("websocket websocket hijack: %v", err)
http.Error(w, err.Error(), 500)
return
}
@jason-shen
jason-shen / volume_meter.html
Created April 20, 2021 05:46 — forked from yying/volume_meter.html
WebAudio volume meter using a MediaStream (can be easily applied to MediaStream from WebRTC)
<!DOCTYPE html>
<html lang="en">
<head>
<title> </title>
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/min/1.5/min.min.css">
<style>
body,textarea,input,select {
background:0;
border-radius:0;
font:16px sans-serif;