Skip to content

Instantly share code, notes, and snippets.

View jaehue's full-sized avatar

Jaehue Jang jaehue

  • Purpleworks
  • South Korea
View GitHub Profile
@jaehue
jaehue / number_code.go
Created April 14, 2020 09:48
number_code
package main
import (
"fmt"
"math"
"strings"
"testing"
"github.com/pangpanglabs/goutils/test"
)
@jaehue
jaehue / timeout.go
Created March 28, 2018 04:43
timeout
func TestTimeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*50)
defer cancel()
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
@jaehue
jaehue / cancelation.go
Created March 28, 2018 03:47
Cancelation Context
func TestCalcelation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
@jaehue
jaehue / eventbroker.go
Created December 18, 2017 16:04
이벤트브로커에서 이벤트 처리
func (j *Job) Run(in <-chan *sarama.ConsumerMessage) <-chan *sarama.ConsumerMessage {
out := make(chan *sarama.ConsumerMessage)
for msg := range in {
wg := sync.WaitGroup{}
for _, eh := range j.eventHandlers {
wg.Add(1)
go func(eh *eventbroker.EventHandler) {
defer wg.Done()
/************
@jaehue
jaehue / hooker.go
Last active June 6, 2017 07:49
logrus hooker for caller
type CallkerHook struct {
}
func (c *CallkerHook) Levels() []logrus.Level {
return []logrus.Level{
logrus.DebugLevel,
logrus.InfoLevel,
logrus.WarnLevel,
logrus.ErrorLevel,
}
using Dapper;
using Nancy;
using Nancy.IO;
using Nancy.ModelBinding;
using Nancy.Json;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
@jaehue
jaehue / sharedMap.go
Last active October 15, 2023 21:08
Built-in map doesn't support concurrent. This is concurrent map using channel, without mutex.
package main
import "fmt"
type sharedMap struct {
m map[string]interface{}
c chan command
}
type command struct {
@jaehue
jaehue / invoker.go
Created January 13, 2015 00:12
Golang Function Invoker
package main
import (
"fmt"
"reflect"
)
type Command struct {
Func interface{}
Args []interface{}