id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c172400 | file.m.Lock()
file.doc.ChunkSize = bytes
file.m.Unlock()
} | |
c172401 |
file.m.Lock()
file.doc.Id = id
file.m.Unlock()
} | |
c172402 |
file.m.Lock()
file.doc.Filename = name
file.m.Unlock()
} | |
c172403 |
file.m.Lock()
file.doc.ContentType = ctype
file.m.Unlock()
} | |
c172404 | = file.doc.Length
file.m.Unlock()
return
} | |
c172405 |
file.m.Lock()
file.doc.UploadDate = t
file.m.Unlock()
} | |
c172406 | must be called on file opened for writing")
}
file.err = errors.New("write aborted")
} | |
c172407 | file.wbuf = append(file.wbuf, data[:missing]...)
data = data[missing:]
file.insertChunk(file.wbuf)
file.wbuf = file.wbuf[0:0]
}
// Then, flush all chunks from data without copying.
for len(data) > chunkSize {
size := chunkSize
if size > len(data) {
size = len(data)
}
file.insertChunk(data[:size])
data = data[size:]
}
// And append the rest for a future call.
file.wbuf = append(file.wbuf, data...)
return n, file.err
} | |
c172408 | file.rbuf = file.rbuf[i:]
if i == len(b) || file.offset == file.doc.Length {
break
}
b = b[i:]
file.rbuf, err = file.getChunk()
}
return n, err
} | |
c172409 | SetConsoleCursorPosition(h.fd, position)
if err != nil {
return err
}
h.logf("Cursor position set: (%d, %d)", position.X, position.Y)
return err
} | |
c172410 |
// Black with no intensity
windowsMode = (windowsMode &^ BACKGROUND_MASK) | (baseMode & BACKGROUND_MASK)
case ansiterm.ANSI_SGR_BACKGROUND_BLACK:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK)
case ansiterm.ANSI_SGR_BACKGROUND_RED:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED
case ansiterm.ANSI_SGR_BACKGROUND_GREEN:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN
case ansiterm.ANSI_SGR_BACKGROUND_YELLOW:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN
case ansiterm.ANSI_SGR_BACKGROUND_BLUE:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_BLUE
case ansiterm.ANSI_SGR_BACKGROUND_MAGENTA:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_BLUE
case ansiterm.ANSI_SGR_BACKGROUND_CYAN:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE
case ansiterm.ANSI_SGR_BACKGROUND_WHITE:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
}
return windowsMode, inverted
} | |
c172411 | & windowsMode) << 4) | ((BACKGROUND_MASK & windowsMode) >> 4)
} | |
c172412 | err := SetConsoleCursorPosition(h.fd, pos); err != nil {
return false, err
}
}
return true, nil
} else if pos.Y < info.Window.Bottom {
// Let Windows handle the LF.
pos.Y++
if includeCR {
pos.X = 0
}
h.updatePos(pos)
return false, nil
} else {
// The cursor is at the bottom of the screen but outside the scroll
// region. Skip the LF.
h.logf("Simulating LF outside scroll region")
if includeCR {
if err := h.Flush(); err != nil {
return false, err
}
pos.X = 0
if err := SetConsoleCursorPosition(h.fd, pos); err != nil {
return false, err
}
}
return true, nil
}
} | |
c172413 | err := h.Flush(); err != nil {
return err
}
h.logf("Resetting cursor position for LF without CR")
if err := SetConsoleCursorPosition(h.fd, pos); err != nil {
return err
}
}
}
return nil
} | |
c172414 | top >= bottom {
top = window.Top
bottom = window.Bottom
}
return scrollRegion{top: top, bottom: bottom}
} | |
c172415 |
// Origin to which area should be copied
destOrigin := COORD{
X: 0,
Y: sr.top - int16(param),
}
char := CHAR_INFO{
UnicodeChar: ' ',
Attributes: h.attributes,
}
if err := ScrollConsoleScreenBuffer(h.fd, scrollRect, scrollRect, destOrigin, char); err != nil {
return err
}
return nil
} | |
c172416 | Y: position.Y,
}
char := CHAR_INFO{
UnicodeChar: ' ',
Attributes: h.attributes,
}
if err := ScrollConsoleScreenBuffer(h.fd, scrollRect, scrollRect, destOrigin, char); err != nil {
return err
}
return nil
} | |
c172417 | hex[i] = fmt.Sprintf("%X", ch)
}
return strings.Join(hex, "")
} | |
c172418 | os.RemoveAll(e.ExpandedDirectoryPath)
if err != nil {
fmt.Fprintln(os.Stderr, "Unable to remove cached directory", err)
}
} else {
// Double the size to account for both assets
e.Size = e.Size * 2
}
} else {
f, err = os.Open(e.FilePath)
if err != nil {
return nil, err
}
}
e.incrementFileInUseCount()
if _, err := f.Seek(0, os.SEEK_SET); err != nil {
return nil, err
}
readCloser := NewFileCloser(f, func(filePath string) {
lock.Lock()
e.decrementFileInUseCount()
lock.Unlock()
})
return readCloser, nil
} | |
c172419 | cache,
cacheLocation: filepath.Join(cache.CachedPath, "saved_cache.json"),
uncachedPath: createTempCachedDir(cache.CachedPath),
downloader: downloader,
transformer: transformer,
lock: &sync.Mutex{},
inProgress: map[string]chan struct{}{},
}
} | |
c172420 |
}
if filename == "" {
return download{}, true, 0, nil
}
fileInfo, err := os.Stat(filename)
if err != nil {
return download{}, false, 0, err
}
defer os.Remove(filename)
cachedFile, err := ioutil.TempFile(c.uncachedPath, "transformed")
if err != nil {
return download{}, false, 0, err
}
err = cachedFile.Close()
if err != nil {
return download{}, false, 0, err
}
cachedSize, err := transformer(filename, cachedFile.Name())
if err != nil {
return download{}, false, 0, err
}
return download{
path: cachedFile.Name(),
size: cachedSize,
cachingInfo: cachingInfo,
}, false, fileInfo.Size(), nil
} | |
c172421 | ui.LogBGColor.Bright)
ui.UI.Log(message)
ct.ResetColor()
} | |
c172422 | ui.OutputBGColor.Bright)
ui.UI.Output(message)
ct.ResetColor()
} | |
c172423 | ui.SuccessBGColor.Bright)
ui.UI.Success(message)
ct.ResetColor()
} | |
c172424 | ui.InfoBGColor.Bright)
ui.UI.Info(message)
ct.ResetColor()
} | |
c172425 | ui.ErrorBGColor.Bright)
ui.UI.Error(message)
ct.ResetColor()
} | |
c172426 | ui.WarnBGColor.Bright)
ui.UI.Warn(message)
ct.ResetColor()
} | |
c172427 | ui.RunningBGColor.Bright)
ui.UI.Running(message)
ct.ResetColor()
} | |
c172428 |
message = timeString + ": " + message
ui.Output(message)
} | |
c172429 | message)
fmt.Fprint(ui.Writer, "\n")
} | |
c172430 |
fmt.Fprint(ui.Writer, message)
fmt.Fprint(ui.Writer, "\n")
}
} | |
c172431 |
} else if ui.LogPrefix != "" {
message = ui.LogPrefix + " " + message
}
ui.UI.Log(message)
} | |
c172432 |
} else if ui.OutputPrefix != "" {
message = ui.OutputPrefix + " " + message
}
ui.UI.Output(message)
} | |
c172433 | one
message = ui.SuccessPrefix + message
} else if ui.SuccessPrefix != "" {
message = ui.SuccessPrefix + " " + message
}
ui.UI.Success(message)
} | |
c172434 |
} else if ui.InfoPrefix != "" {
message = ui.InfoPrefix + " " + message
}
ui.UI.Info(message)
} | |
c172435 |
} else if ui.ErrorPrefix != "" {
message = ui.ErrorPrefix + " " + message
}
ui.UI.Error(message)
} | |
c172436 |
} else if ui.WarnPrefix != "" {
message = ui.WarnPrefix + " " + message
}
ui.UI.Warn(message)
} | |
c172437 | one
message = ui.RunningPrefix + message
} else if ui.RunningPrefix != "" {
message = ui.RunningPrefix + " " + message
}
ui.UI.Running(message)
} | |
c172438 |
return &BasicUI{
Reader: reader,
Writer: writer,
ErrorWriter: errorWriter,
}
} | |
c172439 | None,
WarnFGColor: warnColor,
WarnBGColor: None,
RunningFGColor: runningColor,
RunningBGColor: None,
AskFGColor: askColor,
AskBGColor: None,
ResponseFGColor: responseColor,
ResponseBGColor: None,
UI: ui,
}
} | |
c172440 | defer ui.l.Unlock()
ui.UI.Log(message)
} | |
c172441 | c.EnsureIndex(mgo.Index{
Key: []string{"modified"},
Background: true,
Sparse: true,
ExpireAfter: time.Duration(maxAge) * time.Second,
})
}
return store
} | |
c172442 | m.Options.Secure,
HttpOnly: m.Options.HttpOnly,
}
session.IsNew = true
var err error
if cook, errToken := m.Token.GetToken(r, name); errToken == nil {
err = securecookie.DecodeMulti(name, cook, &session.ID, m.Codecs...)
if err == nil {
err = m.load(session)
if err == nil {
session.IsNew = false
} else {
err = nil
}
}
}
return session, err
} | |
c172443 | defer s.Unlock()
s.s = append(s.s, id)
} | |
c172444 |
}
id := s.s[s.Len()-1]
s.s = s.s[:s.Len()-1]
return id, true
} | |
c172445 | return rootSegment
}
return s.s[s.Len()-1]
} | |
c172446 |
go func() {
for _ = range ticker.C {
r.Record()
}
}()
} | |
c172447 | sdk.InitEmbeddedMode(key, app); err != nil {
panic(err)
}
} | |
c172448 | errNoMap[errno]; ok {
errMsg = e
}
return errno, errors.New(fmt.Sprintf("newrelic[%s]: %s", caller(), errMsg))
}
return errno, nil
} | |
c172449 | name = filepath.Base(runtime.FuncForPC(pc).Name())
}
return name
} | |
c172450 | defer C.free(unsafe.Pointer(cappName))
clang := C.CString("Go")
defer C.free(unsafe.Pointer(clang))
clangVersion := C.CString(runtime.Version())
defer C.free(unsafe.Pointer(clangVersion))
errno := C.newrelic_init(clicense, cappName, clang, clangVersion)
return errNo(errno)
} | |
c172451 | return errNo(C.newrelic_request_shutdown(creason))
} | |
c172452 | txnType: WebTransaction,
ss: NewSegmentStack(),
mtx: &sync.Mutex{},
}
} | |
c172453 | := NewTx(name)
t.url = url
return t
} | |
c172454 |
t := NewTx(name)
t.txnType = OtherTransaction
t.category = category
return t
} | |
c172455 | }
if err = t.Tracer.SetTransactionType(t.id, t.txnType); err != nil {
return err
}
if t.url != "" {
if err = t.Tracer.SetTransactionRequestURL(t.id, t.url); err != nil {
return err
}
}
if t.category != "" {
if err = t.Tracer.SetTransactionCategory(t.id, t.category); err != nil {
return err
}
}
return nil
} | |
c172456 | != rootSegment {
t.EndSegment() // discarding errors?
}
return t.Tracer.EndTransaction(t.id)
} | |
c172457 | t.ss.Peek(), name)
if err != nil {
return err
}
t.ss.Push(id)
return nil
} | |
c172458 |
id, err := t.Tracer.BeginDatastoreSegment(t.id, t.ss.Peek(), table, operation, sql, rollupName)
if err != nil {
return err
}
t.ss.Push(id)
return nil
} | |
c172459 |
id, err := t.Tracer.BeginExternalSegment(t.id, t.ss.Peek(), host, name)
if err != nil {
return err
}
t.ss.Push(id)
return nil
} | |
c172460 |
return t.Tracer.EndSegment(t.id, id)
}
return nil
} | |
c172461 | t.Reporter.ReportError(t.id, exceptionType, errorMessage, stackTrace, stackFrameDelim)
return err
} | |
c172462 | {
return context.WithValue(ctx, txKey, t)
} | |
c172463 | ok := ctx.Value(txKey).(Tx)
return t, ok
} | |
c172464 | {
return trace(ctx, name, func(tx Tx) error {
return tx.StartExternal(host, name)
})
} | |
c172465 | {
return trace(ctx, name, func(tx Tx) error {
return tx.StartGeneric(name)
})
} | |
c172466 |
return tx.StartDatastore(table, operation, sql, rollupName)
})
} | |
c172467 | func() error {
return tx.EndSegment()
},
}
}
return &Trace{nil, func() error { return nil }}
} | |
c172468 | {
if fs.Exists(urlPrefix, c.Request.URL.Path) {
fileserver.ServeHTTP(c.Writer, c.Request)
c.Abort()
}
}
} | |
c172469 | delete(c.items, k)
}
c.evictList.Init()
} | |
c172470 |
kv := ent.Value.(*entry)
return kv.key, kv.value, true
}
return "", 0, false
} | |
c172471 | {
keys[i] = ent.Value.(*entry).key
i++
}
return keys
} | |
c172472 |
kv := e.Value.(*entry)
delete(c.items, kv.key)
} | |
c172473 | okList: make([]bool, 0),
mutex: &sync.RWMutex{},
}
} | |
c172474 | DefaultCluster()
for _, host := range hosts {
cluster.AddHost(host)
}
return cluster
} | |
c172475 | append(c.hosts, address)
c.okList = append(c.okList, true)
} | |
c172476 | break
}
}
c.lastHostIdx++
c.mutex.Unlock()
if host != nil {
return host
}
c.reset()
return host
} | |
c172477 | if uri.Equals(address) {
c.okList[i] = false
break
}
}
} | |
c172478 | if c.okList[i] {
hosts = append(hosts, *host)
}
}
return hosts
} | |
c172479 | return b.ColumnID < ob.ColumnID
}
return b.RowID < ob.RowID
}
return false
} | |
c172480 | := other.(FieldValue); ok {
return v.ColumnID < ov.ColumnID
}
return false
} | |
c172481 | indexOptions := &IndexOptions{}
indexOptions.addOptions(options...)
return s.indexWithOptions(name, 0, indexOptions)
} | |
c172482 | := range s.indexes {
result[k] = v.copy()
}
return result
} | |
c172483 | ok := s.indexes[indexName]
return ok
} | |
c172484 | return &PQLBaseQuery{
index: index,
pql: pql,
err: err,
hasKeys: index.options.keys,
}
} | |
c172485 | serializedQuery := query.Serialize()
q.hasKeys = q.hasKeys || serializedQuery.HasWriteKeys()
q.queries = append(q.queries, serializedQuery.String())
} | |
c172486 | return &PQLRowQuery{
index: index,
pql: pql,
err: err,
hasKeys: index.options.keys,
}
} | |
c172487 | mopt["trackExistence"] = io.trackExistence
}
return fmt.Sprintf(`{"options":%s}`, encodeMap(mopt))
} | |
c172488 | options.keys = keys
options.keysSet = true
}
} | |
c172489 | options.trackExistence = trackExistence
options.trackExistenceSet = true
}
} | |
c172490 | options: options.withDefaults(),
fields: map[string]*Field{},
}
} | |
c172491 | := range idx.fields {
result[k] = v.copy()
}
return result
} | |
c172492 | ok := idx.fields[fieldName]
return ok
} | |
c172493 | = fieldOptions.withDefaults()
fieldOptions.addOptions(options...)
return idx.fieldWithOptions(name, fieldOptions)
} | |
c172494 | serializedQuery := query.Serialize()
hasKeys = hasKeys || serializedQuery.HasWriteKeys()
stringQueries = append(stringQueries, serializedQuery.String())
}
return &PQLBatchQuery{
index: idx,
queries: stringQueries,
hasKeys: hasKeys,
}
} | |
c172495 | idx, nil)
// NOTE: raw queries always assumed to have keys set
q.hasKeys = true
return q
} | |
c172496 | requires at least 1 row"))
}
return idx.rowOperation("Intersect", rows...)
} | |
c172497 | return NewPQLRowQuery(fmt.Sprintf("Not(%s)", row.serialize()), idx, row.Error())
} | |
c172498 | NewPQLBaseQuery(fmt.Sprintf("Count(%s)", serializedQuery.String()), idx, nil)
q.hasKeys = q.hasKeys || serializedQuery.HasWriteKeys()
return q
} | |
c172499 | for _, opt := range opts {
opt(oo)
}
text := fmt.Sprintf("Options(%s,%s)", row.serialize(), oo.marshal())
return NewPQLBaseQuery(text, idx, nil)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.