Skip to content

Instantly share code, notes, and snippets.

View dzungtran's full-sized avatar
🎯
Focusing

Dzung Tran dzungtran

🎯
Focusing
View GitHub Profile
@dzungtran
dzungtran / main.go
Created November 10, 2020 11:31
Example dependencies injection with dig
package main
import (
"fmt"
"go.uber.org/dig"
)
type Say struct {
Name string
}
@dzungtran
dzungtran / main.go
Last active November 14, 2023 06:35
[Golang] Read large csv file with worker pool
package main
// Sample file for test: https://drive.google.com/file/d/1DFkJdX5UTnB_xL7g8xwkkdE8BxdurAhN/view?usp=sharing
import (
"encoding/csv"
"encoding/json"
"fmt"
"io"
"os"
"strconv"
"sync"
@dzungtran
dzungtran / install-protoc-gen-go.md
Last active December 29, 2023 06:25
Install specify version for protoc-gen-go
GIT_TAG='v1.1.0'
go get -d -u github.com/golang/protobuf/protoc-gen-go
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
go install github.com/golang/protobuf/protoc-gen-go

Check current protoc-gen-go location

@dzungtran
dzungtran / README.md
Last active August 1, 2019 08:03
Create request logging server on local

Create request logging server on local (for testing purpose)

  • Create index.php
  • Start php built-in server on local by command: php -S localhost:8000
  • Publish local server to serveo: ssh -o ServerAliveInterval=60 -R 80:localhost:8000 serveo.net
@dzungtran
dzungtran / ys.zsh-theme
Last active July 25, 2019 03:03
Custom ys theme zsh
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
#
# Mar 2013 Yad Smood
# VCS
YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
@dzungtran
dzungtran / awesome-bash.sh
Last active December 14, 2017 11:18
[Updating] Awesome bash commands will help to save time for your life
# USER GUIDE:
# Do not run this script directly
# Compress multiple folders, each into its own zip archive
# BEGIN
for i in */; do zip -r "${i%/}.zip" "$i"; done
# OR
for i in *
do
[ -d "$i" ] && zip -r "$i.zip" "$i"
@dzungtran
dzungtran / logstash.conf
Last active July 26, 2019 15:06
Logstash config for laravel
input {
#logstash -f logstash.conf < request.log > output.txt
stdin {
type => "laravel_logs"
codec => multiline {
pattern => "^\["
what => "previous"
negate => true
}
@dzungtran
dzungtran / magento-reset-files-mode.sh
Last active August 29, 2015 14:21
Magento reset files mode
#!/bin/bash
if [ ! -f ./app/etc/local.xml ]; then
echo "-- ERROR"
echo "-- This doesn't look like a Magento install. Please make sure"
echo "-- that you are running this from the Magento main doc root dir"
exit
fi
if [ `id -u` != 0 ]; then
@dzungtran
dzungtran / list.md
Created March 24, 2015 03:30
List of tables to safely truncate in Magento

Before you do anything

  • Make sure you test clearing this data in a non-production environment first.
  • Always make backups before you lose data forever.
  • Make sure you're truncateing, not droping.
  • Probably a good idea to reindex everything via shell after mass deleting records

To expand on Jim's answer, Magento Support doesn't need the contents of these tables when they ask for a copy of your DB, so you could consider them non-essential.

@dzungtran
dzungtran / truncate.sql
Last active August 29, 2015 14:06
Truncate tables in magento
SET foreign_key_checks = 0;
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;