Skip to content

Instantly share code, notes, and snippets.

View elliotchance's full-sized avatar
🤓
Building awesome stuff with V

Elliot Chance elliotchance

🤓
Building awesome stuff with V
View GitHub Profile
class ReadUncommittedTransaction(Transaction):
def record_is_locked(self, record):
return record['expired_xid'] != 0
def record_is_visible(self, record):
return record['expired_xid'] == 0
class Transaction:
def __init__(self, table, xid):
self.table = table
self.xid = xid
self.rollback_actions = []
def add_record(self, id, name):
record = {
'id': id,
'name': name,
import "golang.org/x/crypto/bcrypt"
// CheckPassword is used for Basic authentication to check the secret. The logic
// has been copied from the existing implementation in:
//
// protected/models/traits/HasPassword.php
//
// The PHP source code will be copied verbatim here, just in case something
// changes it can be compared:
//
package main
import (
"fmt"
"strings"
"sync"
"time"
)
type ChannelPerf struct {
package main
import (
"fmt"
"time"
)
func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string {
batches := make(chan []string)
package main
import (
"fmt"
"time"
)
func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string {
batches := make(chan []string)
package main
import (
"context"
"fmt"
"time"
)
func BatchStringsCtx(ctx context.Context, values <-chan string, maxItems int, maxTimeout time.Duration) chan []string {
batches := make(chan []string)
package main
import (
"fmt"
"time"
)
func BatchStrings(values <-chan string, maxItems int, maxTimeout time.Duration) chan []string {
batches := make(chan []string)