Skip to content

Instantly share code, notes, and snippets.

View SemmiDev's full-sized avatar
🎯
Focusing

Sammi Aldhi Yanto SemmiDev

🎯
Focusing
View GitHub Profile
package main
import (
"context"
"os"
"sync"
"github.com/google/go-github/v53/github"
"golang.org/x/exp/slog"
"golang.org/x/oauth2"
package main
import (
"sync"
"testing"
"golang.org/x/exp/slog"
)
func TestMain(m *testing.M) {
@SemmiDev
SemmiDev / main.go
Created July 10, 2023 07:40
url shortener
package main
import (
"encoding/json"
"fmt"
"html/template"
"log"
"net/http"
"sync"
@SemmiDev
SemmiDev / shortener.go
Created July 10, 2023 07:41
url shortener
package shortener
import (
"bytes"
"fmt"
"github.com/bwmarrin/snowflake"
)
const (
base62Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
@SemmiDev
SemmiDev / shortener_test.go
Created July 10, 2023 07:42
url shortener
package shortener
import (
"sync"
"testing"
)
func TestShorten(t *testing.T) {
var ids []Response
@SemmiDev
SemmiDev / main_test.go
Created July 10, 2023 07:42
url shortener
package main
import (
"bytes"
"net/http"
"net/http/httptest"
"strings"
"testing"
"url-shortener/shortener"
)
@SemmiDev
SemmiDev / index.html
Created July 10, 2023 07:43
url shortener
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Shortener</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
version: "3.9"
services:
postgres:
image: postgres:14-alpine
environment:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=fts
ports:
- "5432:5432"
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE instructors
(
id UUID PRIMARY KEY,
name VARCHAR NOT NULL,
occupation VARCHAR NOT NULL,
email VARCHAR NOT NULL,
name_tsvector TSVECTOR GENERATED ALWAYS AS (TO_TSVECTOR('indonesian', name)) STORED,
occupation_tsvector TSVECTOR GENERATED ALWAYS AS (TO_TSVECTOR('indonesian', occupation)) STORED,
package main
import (
"context"
"errors"
"fmt"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"net/mail"
"strings"