Skip to content

Instantly share code, notes, and snippets.

@dele454
dele454 / title.basics.tsv
Last active August 10, 2022 03:19
Concurrency
tconst titleType primaryTitle originalTitle isAdult startYear endYear runtimeMinutes genres
tt0000001 short Carmencita Carmencita 0 1894 \N 1 Documentary,Short
tt0000002 short Le clown et ses chiens Le clown et ses chiens 0 1892 \N 5 Animation,Short
tt0000003 short Pauvre Pierrot Pauvre Pierrot 0 1892 \N 4 Animation,Comedy,Romance
tt0000004 short Un bon bock Un bon bock 0 1892 \N 12 Animation,Short
tt0000005 short Blacksmith Scene Blacksmith Scene 0 1893 \N 1 Comedy,Short
tt0000006 short Chinese Opium Den Chinese Opium Den 0 1894 \N 1 Short
tt0000007 short Corbett and Courtney Before the Kinetograph Corbett and Courtney Before the Kinetograph 0 1894 \N 1 Short,Sport
tt0000008 short Edison Kinetoscopic Record of a Sneeze Edison Kinetoscopic Record of a Sneeze 0 1894 \N 1 Documentary,Short
tt0000009 movie Miss Jerry Miss Jerry 0 1894 \N 45 Romance
@dele454
dele454 / concurrency_receiver.go
Last active August 10, 2022 03:16
Concurrency
package cmd
import (
"context"
"fmt"
"reflect"
"sync"
)
// using sync.Pool to manage Movie structs
@dele454
dele454 / concurrency_reader.go
Last active August 9, 2022 10:34
Concurrency
package cmd
import (
"context"
"encoding/csv"
"io"
"os"
"sync"
"time"
)
@dele454
dele454 / output.tmpl
Created August 6, 2022 03:44
Part 1 - CSV Transformation
<!doctype html>
<html lang="en">
<head>
<title>{{.FileName}}</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css">
</head>
<body class="">
<div class="container-fluid">
<h1>{{.FileName}}</h1>
<table class="table table-striped">
@dele454
dele454 / snippet_html_transformer.go
Created August 6, 2022 03:42
Part 1 - CSV Transformation
// ProcessRecord process records received via the chan
func (tr *HTMLTransformer) ProcessRecord(wg *sync.WaitGroup, record <-chan []string, done <-chan bool) {
var (
now = time.Now()
data []utils.SalesRecord
end bool
ctx = context.Background()
)
defer func() {
@dele454
dele454 / snippet_csv_parser.go
Last active August 6, 2022 03:50
Part 1 - CSV Transformation
// Read reads from the csv file
func (c *CSVParser) Read(wg *sync.WaitGroup, record chan<- []string, done chan<- bool) {
start := time.Now()
defer func() {
close(done)
close(record)
c.reporter.AddDuration(time.Since(start).Seconds())
wg.Done()
@dele454
dele454 / snippet_report.go
Created August 6, 2022 03:34
Part 1 - CSV Transformation
// WriteReportToStdOut writes report to stdout
func (t *TransformationReporter) WriteReportToStdOut(ctx context.Context) error {
var err error
path := utils.RootDir()
// create template
tmpl, err := template.Must(template.New("STDOUT"), err).
ParseFiles(path + "/internal/transform/template/report.tmpl")
if err != nil {
@dele454
dele454 / cmd.go
Last active August 6, 2022 03:31
Part 1 - CSV Transformation
package cmd
import (
"sync"
"github.com/dele454/medium/csv-transform-to-html/internal/parser"
"github.com/dele454/medium/csv-transform-to-html/internal/report"
"github.com/dele454/medium/csv-transform-to-html/internal/transform"
)
@dele454
dele454 / main.go
Last active August 6, 2022 03:32
Part 1 - CSV Transformation
package main
import (
"flag"
"os"
"github.com/dele454/medium/csv-transform-to-html/cmd"
"github.com/dele454/medium/csv-transform-to-html/internal/errs"
)
@dele454
dele454 / golang_resources.txt
Last active January 10, 2024 20:42
Golang resources
Coding Standards
++++++++++++++++
https://golang.org/doc/effective_go.html
Go In General
+++++++++++++
https://gobyexample.com/
https://golang.org/doc/code.html
http://www.go-gazelle.com