has_many :active_events, :through => :event_users,
:class_name => "Event",
:source => :event,
:conditions => ['event_users.active = ?',true]
serialize :column, JSON
realy faster then standart YAML serialize
class Some < ActiveRecord:Base
Get package from here
// import "golorize"
fmt.Println( golorize.Red("[FAIL] Some Errors Occurred") )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// Creates a router without any middleware by default | |
r := gin.New() | |
r.Use(gin.Recovery()) | |
r.Use(logger.Logger()) // use this logger without colors | |
*/ | |
package logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"strings" | |
"time" | |
"github.com/peterh/liner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in this example the Event is an event, that requires updates in our Root | |
func startHandlingSomePack(events <-chan Event, pack *skyobject.Pack, | |
n *node.Node, wg *sync.WaitGroup) { | |
go handleSomePack(n, pack, events, n.Quiting(), wg) | |
} | |
func handleSomePack(n *node.Node, pack *cxo.Pack, events <-chan Event, | |
quit <-chan struct{}, wg *sync.WaitGroup) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Len(pack Pack) (ln int, err error) | |
// presence check | |
HasHash(pack Pack, hash cipher.SHA256) (ok bool, err error) | |
// short hand for HasHash + pack.Get(hash) + encoder.DeserializeRaw | |
ValueByHash(pack Pack, hash cipher.SHA256, obj interface{}) (err error) | |
// the IndexByHash is useful only if the Refs contains only unique | |
// elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MessengerFactory struct { | |
factory.MessengerFactory | |
isInitialized bool | |
} | |
func (m *MessengerFactory) IsInitialized() bool { return m.isInitialized } | |
func (m *MessengerFactory) Connect(address string) (conn *Connection, err error) { | |
return m.ConnectWithConfig(address, nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pool | |
import ( | |
"sync" | |
"testing" | |
"time" | |
) | |
// perform: | |
// go test -bench syncPool |
OlderNewer