Skip to content

Instantly share code, notes, and snippets.

View MadFaill's full-sized avatar

Nikolay MadFaill

View GitHub Profile
@MadFaill
MadFaill / least_squares.go
Created April 21, 2024 06:54 — forked from sukamenev/least_squares.go
Golang least squares method: traditional and minimizing sum of squares of perpendicular lengths approach.
/*
Код взят отсюда и доработан
https://gist.github.com/ota42y/db4ff0298d9c945cd261
Код применим только для y = ax + b
Для вертикальных прямых неприменим.
Least Squares Fitting: Perpendicular Offsets
Мы используем продвинутую версию метода наименьших квадратов, где меряется расстояние перпендикуляра до прямой
https://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html
@MadFaill
MadFaill / index.html
Created March 11, 2021 09:27 — forked from rpaul-stripe/index.html
Stripe Checkout Go Example
<html>
<head>
<title>Checkout Example</title>
</head>
<body>
<form action="/charge" method="post" class="payment">
<article>
<label class="amount">
<span>Amount: $5.00</span>
//
// Companion code to https://medium.com/statuscode/pipeline-patterns-in-go-a37bb3a7e61d
//
// To run:
// go get github.com/pkg/errors
// go run -race pipeline_demo.go
//
package main
@MadFaill
MadFaill / bitbucket-pipelines.yml
Created August 5, 2019 07:32 — forked from pyldin601/bitbucket-pipelines.yml
Bitbucket pipelines for docker swarm service with deploy via SSH.
image: node
pipelines:
branches:
staging:
- step:
script:
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- make TAG=staging docker-build docker-push
- step:
@MadFaill
MadFaill / ttfb.sh
Created January 28, 2019 13:00 — forked from sandeepraju/ttfb.sh
curl command to check the time to first byte
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
@MadFaill
MadFaill / Explanation.txt
Created January 25, 2019 14:53 — forked from melo/Explanation.txt
strange nginx behaviour with error_page + proxy_pass
I expected the first configuration below, simple.conf, to work just fine.
But it doesn't. My app server receives the second hit with the same URI as the first hit.
On the second config, wtf.conf, I keep the original URL on a variable to use in the error redirect.
My question is this: why doesn't the first simple.conf configuration works?
@MadFaill
MadFaill / site.conf
Created December 11, 2018 10:46 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
@MadFaill
MadFaill / proxy.go
Created January 24, 2017 19:01 — forked from ericflo/proxy.go
Golang TCP Proxy
package proxy
import (
"io"
"net"
"sync"
log "github.com/Sirupsen/logrus"
)
@MadFaill
MadFaill / proxy.go
Created January 24, 2017 07:03 — forked from vmihailenco/proxy.go
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"