Skip to content

Instantly share code, notes, and snippets.

@timakin
timakin / go-job-worker.md
Last active June 6, 2024 07:06
Go製ジョブワーカーライブラリの比較

ライブラリ検索するときに便利 -> https://golanglibs.com

  • benmans/goworker(1584 stars)
    • redis-backed
    • Go製のジョブワーカーでは一番メジャーぽい
    • 当初Enqueueがなかったようだが、2015/12に追加されてる: 参考
    • リポジトリ自体は4年前からあって、7か月前にも更新はされてる
  • rallison/go-workers(816 stars)
    • redis-backed  - 機能的にはgoworkerとほぼ変わらなさそう
@timakin
timakin / cloudSettings
Created February 21, 2017 05:44
Visual Studio Code Sync Settings Gist
{"lastUpload":"2017-02-21T05:44:57.092Z","extensionVersion":"v2.4.4"}
@timakin
timakin / gist:d0269bde13f7ba4c1d86e86187fafd6f
Last active April 6, 2017 12:41
App structについて⑴
// ⑴App structにLoggerやDB Clientを持たせるのと、
// フレームワークの"Context"(context.Contextとは別物)に
// 同様のオブジェクトを持たせるのは、同じ意味なのか?
////////////////////////////////
// achikuさんの例
////////////////////////////////
// App application
type App struct {
@timakin
timakin / gist:5c79adbf6d439f4104f7654b83e10a82
Created April 6, 2017 12:29
App structについて⑵
// ⑵構造体の要素として、context使わなきゃいけない要素は持てるのか
// appengineを使う場合、context.Contextの拡張の、appengine/contextをセットして、
// Log表示やDBへの接続等を行いますが、そういった要素はどう管理するべきか、
// というかそもそも共通の構造体みたいなものに持てないのでは?...という質問でした。
// (これはappengine特有かもしれないので、摑みどころがなければ、スルーしていただいて結構です。)
// 以下実際のappengineのコード例(リクエストハンドラ直下)です。
import "google.golang.org/appengine/datastore"
@timakin
timakin / recog.go
Created June 8, 2017 06:04
image recognition
package main
import (
"errors"
"fmt"
"image"
"image/jpeg"
"image/png"
"log"
"os"
package main
func main() {
PopWithCopy()
}
func PopWithCopy() string {
strs := []string{
"AAAAAAAAAAA",
"AAAAAAAAAAA",
@timakin
timakin / gist:9c64bf1b9fa737f6cae04fbe1f952700
Last active August 17, 2017 15:03
vagrantfile for godev
# -*- mode: ruby -*-
# vi: set ft=ruby :
# http://www.vagrantbox.es/
# $ vagrant box add ubuntu/trusty64
# $ vagrant init ubuntu/trusty64
# $ vagrant up
# $ vagrant ssh-config
# $ ssh-keygen -yf /Users/hogeee/go/src/.vagrant/machines/default/virtualbox/private_key > public_key
# $ cat public_key
@timakin
timakin / langToMap.go
Created October 26, 2017 13:07
langToMap.go
package main
import (
"fmt"
)
type Language struct {
ID int
Code string
}
@timakin
timakin / convert.sh
Last active November 15, 2017 15:07
files="./*.mp4"
for filepath in $files; do
fname_ext="${filepath##*/}"
fname="${fname_ext%.*}"
echo $fname
ffmpeg -i "${fname}.mp4" -vcodec h264 -acodec aac "${fname}_comp.mp4"
done
@timakin
timakin / sub.go
Last active May 29, 2018 06:05
Live status subscription
// StartStatusSubscription ... ライブ動画の放送状況の監視
func (s *liveProgramService) StartStatusSubscription(ctx context.Context) {
s.subLock.Do(func() {
sub, err := s.sub.GetSubscriber()
if err != nil {
panic(err)
}
go func(sub *redis.PubSub) {
defer sub.Close()
for {