Skip to content

Instantly share code, notes, and snippets.

View philippta's full-sized avatar

Philipp Tanlak philippta

View GitHub Profile
[
{
"key": "cmd+[Semicolon]",
"command": "workbench.action.terminal.toggleTerminal"
},
{
"key": "ctrl+shift+[Equal]",
"command": "-workbench.action.terminal.toggleTerminal"
},
{
@philippta
philippta / main.go
Last active May 16, 2022 05:53
Detect uploaded file type
func uploadImage(w http.ResponseWriter, r *http.Request) {
// Create buffer to read magic number of uploaded file
magicNumber := make([]byte, 3)
// Read first 3 bytes of uploaded file
_, err := r.Body.Read(magicNumber)
// handle err
// Check magic number against png, jpg, gif
// https://en.wikipedia.org/wiki/List_of_file_signatures
@philippta
philippta / main.go
Last active August 13, 2020 18:32
Cleaner Go API example with access policies
package main
import (
"encoding/json"
"errors"
"net/http"
"github.com/go-chi/chi"
)
@philippta
philippta / main.go
Last active August 13, 2020 12:19
Clean Go API example with access policies
package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"github.com/go-chi/chi"
)
@philippta
philippta / docker-compose.yml
Created May 5, 2020 06:13
Go Web Examples Courses - goreddit
version: "3"
services:
db:
image: postgres
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: secret