Skip to content

Instantly share code, notes, and snippets.

View synsa's full-sized avatar

Steve Lang synsa

View GitHub Profile
@synsa
synsa / log.go
Created March 25, 2021 19:14 — forked from Tantas/log.go
Apache access logs for golang.
import (
"fmt"
"io"
"net/http"
"strings"
"time"
)
// https://httpd.apache.org/docs/2.2/logs.html#combined + execution time.
const apacheFormatPattern = "%s - - [%s] \"%s %s %s\" %d %d \"%s\" \"%s\" %.4f\n"
@synsa
synsa / log.go
Created March 25, 2021 19:14 — forked from cespare/log.go
Golang apache logging
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}
@synsa
synsa / setup_go.md
Created March 24, 2021 20:35 — forked from rubencaro/setup_go.md
Golang installation guide

Golang installation guide

Since Golang version 1.11 this process is finally (almost) as easy as it should (!!). You can see full docs here. For older guides see here.

These are my notes, not a generic solution. They are not meant to work anywhere outside my machines. Update version numbers to whatever are the current ones while you do this.

Installing everything needed the first time

Install asdf and its golang plugin, then install golang

@synsa
synsa / connect.sh
Created March 12, 2021 05:02 — forked from kfatehi/connect.sh
Secure SSH VNC Tunnel Bash/Ruby Script on Mac OS X
#!/bin/bash
TARGET_IP="xx.xx.xx.xx"
TARGET_LOCAL_VNC_PORT=5901
LOCAL_VNC_PORT=31543
TARGET_WAN_SSH_PORT=22345
TARGET_USER="keyvan"
ruby secure_vnc_tunnel.rb $LOCAL_VNC_PORT $TARGET_IP $TARGET_LOCAL_VNC_PORT $TARGET_WAN_SSH_PORT $TARGET_USER
echo "Entering SSH session ($TARGET_IP:$TARGET_WAN_SSH_PORT)"
ssh -p $TARGET_WAN_SSH_PORT $TARGET_USER@$TARGET_IP
@synsa
synsa / cookie_jar_golang.go
Created March 9, 2021 23:09 — forked from varver/cookie_jar_golang.go
Login to a website with this golang code using persistent cookies or cookie jar .
@synsa
synsa / set_cookiejar.go
Created March 9, 2021 22:03 — forked from HugoPresents/set_cookiejar.go
golang set cookieJar example
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
)
@synsa
synsa / auth.go
Created March 9, 2021 20:20
Golang basic auth example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@synsa
synsa / main.go
Created February 26, 2021 20:22 — forked from ka2n/main.go
Parse yaml with dynamic key name usign go.
package main
import (
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
type Config struct {
@synsa
synsa / nginx.local.dev
Created February 26, 2021 00:38 — forked from unr/nginx.local.dev
Example Nginx file for a Laravel/Nuxt php server locally. Production runs something similar, but more complex with load balancers.
server {
listen 80;
server_name site.com www.site.com *.site.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name site.com www.site.com *.site.com;
root /;
@synsa
synsa / DNS_TO_LOCALHOST.markdown
Created February 21, 2021 19:45 — forked from tinogomes/DNS_TO_LOCALHOST.markdown
Public DNS Pointing To localhost (127.0.0.1)

Available Wildcarded DNS Domains

It turns out that some kind hearted people already set up wildcarded domains for you already. You can use any domain below and/or any subdomain of these and they will always resolve back to 127.0.0.1 (your local machine). Here's the list of ones I know about. Let me know if there are more!

  • localhost - It will always works. Do you know why? I hope so.
  • [*.]fuf.me - Managed by @fidian; it will always point to localhost for IPv4 and IPv6
  • [*.]localtest.me
  • [*.]127-0-0-1.org.uk
  • [*.]vcap.me
  • [*.]yoogle.com