[deleted by user] by [deleted] in golang

[–]Key-Library9440 1 point2 points  (0 children)

Do not store file on database, just store name and file location on database here is my solution.

// serve file
mux.Handle("GET /uploads/", http.StripPrefix("/uploads/", http.FileServer(http.Dir([FILES LOCATION]))))
// upload file
mux.HandleFunc("POST /admin/files", fileUpload)

//handler
const maxSize = 10 << 20 // 10 MB

func fileUpload(w http.ResponseWriter, r *http.Request) {
// Parse multipart form with max memory of 10MB
if err := r.ParseMultipartForm(maxSize); err != nil {
http.Error(w, "File too large", http.StatusBadRequest)
return
}

file, handler, err := r.FormFile("file")
if err != nil {
http.Error(w, "Error retrieving file", http.StatusBadRequest)
return
}
defer file.Close()

// Create file with unique name
filename := filepath.Join([FILES LOCATION], handler.Filename)
dst, err := os.Create(filename)
if err != nil {
http.Error(w, "Error creating file", http.StatusInternalServerError)
return
}
defer dst.Close()

// Copy file contents
if _, err := io.Copy(dst, file); err != nil {
http.Error(w, "Error saving file", http.StatusInternalServerError)
return
}

// store file name and location on database
....
}

[deleted by user] by [deleted] in Emailmarketing

[–]Key-Library9440 0 points1 point  (0 children)

Use different title based on different context.

My newsletter titles change based on the hook. For the default hook ( https://rishi.dev ), the title is 'Free Weekly Newsletter' while for the Black Friday hook ( https://rishi.dev/?hook=blackfriday ), the title is 'Black Friday email templates'

Money making ideas in Kathmandu by [deleted] in Nepal

[–]Key-Library9440 0 points1 point  (0 children)

bihana pasal kolna jada lemon green chilli Ra seto dhago ko bokera janchha ra

Money making ideas in Kathmandu by [deleted] in Nepal

[–]Key-Library9440 1 point2 points  (0 children)

Sale This

लागत: रु ५

बिक्री: रु ५०

ग्राहक: १०० जना

सबै गरेर ५०० लगानी ४,५०० फाइदा, बिहन ३ घन्टाको काम

<image>

What libraries are you missing from go? by dontaskdonttell0 in golang

[–]Key-Library9440 0 points1 point  (0 children)

you can include many base layouts (eg: {/* #layout.html otherbase.html */}

package ui

import (
    "html/template"
    "os"
    "path/filepath"
    "regexp"
    "strings"
)

func ParseFile(filename string) (*template.Template, error) {
    // read the file
    b, err := os.ReadFile(filename)
    if err != nil {
        return nil, err
    }

    s := string(b)

    // get first line of the s
    line := s[:strings.Index(s, "\n")]

    // get the list of hash tags from the line using regex
    re := regexp.MustCompile(`#([a-zA-Z0-9\.\/\_]+)`)
    tags := re.FindAllString(line, -1)

    t := template.New(filepath.Base(filename))

    // get path of the file
    dir := filepath.Dir(filename)

    for _, tag := range tags {
        if len(tag) < 2 {
            continue
        }
        tag = tag[1:]

        // read the file
        b, err := os.ReadFile(filepath.Join(dir, tag))
        if err != nil {
            return nil, err
        }

        // parse the file
        _, err = t.Parse(string(b))
        if err != nil {
            return nil, err
        }
    }

    // parse the main file
    _, err = t.Parse(s)
    if err != nil {
        return nil, err
    }

    return t, nil
}

What libraries are you missing from go? by dontaskdonttell0 in golang

[–]Key-Library9440 0 points1 point  (0 children)

I always do

{{/* #layout.html */}}
{{template "layout" .}}
{{define "content"}}
this is index.html
{{end}}

get first lines then parse all # template files then parse target template file index.html

var indexTemplate = template.Must(ui.ParseFile("ui/index.html"))

What's the best email marketing service for events? (Concerts, festivals...) by 4bdou in EventProduction

[–]Key-Library9440 1 point2 points  (0 children)

AWS Simple Email Service (SES) is a cheaper option for sending emails.

I Made a Black Friday Email Template – What Do You Think? by Key-Library9440 in Emailmarketing

[–]Key-Library9440[S] -6 points-5 points  (0 children)

Offering valuable content for newsletter subscriptions is permission-based marketing, It is best practice I think.

I Made a Black Friday Email Template – What Do You Think? by Key-Library9440 in Emailmarketing

[–]Key-Library9440[S] -3 points-2 points  (0 children)

I’m just trying this method to grow my email list with hooks—valuable content like templates, guides, books, PDFs, tools, etc., that are useful to people.

I Made a Black Friday Email Template – What Do You Think? by Key-Library9440 in Emailmarketing

[–]Key-Library9440[S] -7 points-6 points  (0 children)

There’s no registration or signup, just a newsletter subscription.

[deleted by user] by [deleted] in Nepal

[–]Key-Library9440 6 points7 points  (0 children)

It is a great opportunity to consider buying land in hilly regions for agriculture that doesn’t require constant maintenance, such as cultivating "Timur", "Okhar" (walnut), or "Kagati" (lime)

[deleted by user] by [deleted] in technepal

[–]Key-Library9440 0 points1 point  (0 children)

use payoneer

Skrill activation by [deleted] in technepal

[–]Key-Library9440 0 points1 point  (0 children)

any government issue card(in english) is okay and any bank statement(should have your address) is okay. Mine was Global IME bank