Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@dele454
dele454 / dob.phtml
Last active June 1, 2018 13:56
Magento DOB widget with DOB Validation
<?php
/**
* @see Mage_Customer_Block_Widget_Dob
*/
?>
<label class="dob-label" for="<?php echo $this->getFieldId('month')?>"<?php if ($this->isRequired()) { echo ' class="required"'; } ?>><?php echo $this->__('Birthday') ?></label>
<div class="customer-dob input-box">
<div class="dob-year">
<?php $currentYear = intval(date("Y")); ?>
<select name="<?php echo $this->getFieldName('year'); ?>" id="<?php echo $this->getFieldId('year'); ?>">
@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
@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 / 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 / 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 / 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_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 / 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/[email protected]/dist/css/bootstrap.min.css">
</head>
<body class="">
<div class="container-fluid">
<h1>{{.FileName}}</h1>
<table class="table table-striped">
@dele454
dele454 / concurrency_reader.go
Last active August 9, 2022 10:34
Concurrency
package cmd
import (
"context"
"encoding/csv"
"io"
"os"
"sync"
"time"
)