id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c179400 | if ref.Value != nil {
facet.Value = Atom(*ref.Value)
} else {
facet.Value = protoToRange(ref.Range)
}
fres = append(fres, facet)
}
facets = append(facets, fres)
}
return facets, nil
} | |
c179401 | internal.Call(c, "app_identity_service", "GetDefaultGcsBucketName", req, res)
if err != nil {
return "", fmt.Errorf("file: no default bucket name returned in RPC response: %v", res)
}
return res.GetDefaultGcsBucketName(), nil
} | |
c179402 | && k.intID != 0 {
return false
}
if k.parent != nil {
if k.parent.Incomplete() {
return false
}
if k.parent.appID != k.appID || k.parent.namespace != k.namespace {
return false
}
}
}
return true
} | |
c179403 | k.namespace != o.namespace {
return false
}
k, o = k.parent, o.parent
}
return k == o
} | |
c179404 | k.parent != nil {
k = k.parent
}
return k
} | |
c179405 | {
b.WriteString(k.stringID)
} else {
b.WriteString(strconv.FormatInt(k.intID, 10))
}
} | |
c179406 | := bytes.NewBuffer(make([]byte, 0, 512))
k.marshal(b)
return b.String()
} | |
c179407 | != nil {
panic(err)
}
// Trailing padding is stripped.
return strings.TrimRight(base64.URLEncoding.EncodeToString(b), "=")
} | |
c179408 | }
ref := new(pb.Reference)
if err := proto.Unmarshal(b, ref); err != nil {
return nil, err
}
return protoToKey(ref)
} | |
c179409 | {
return NewKey(c, kind, "", 0, parent)
} | |
c179410 | namespace = internal.NamespaceFromContext(c)
}
return &Key{
kind: kind,
stringID: stringID,
intID: intID,
parent: parent,
appID: internal.FullyQualifiedAppID(c),
namespace: namespace,
}
} | |
c179411 |
}
// The protobuf is inclusive at both ends. Idiomatic Go (e.g. slices, for loops)
// is inclusive at the low end and exclusive at the high end, so we add 1.
low = res.GetStart()
high = res.GetEnd() + 1
if low+int64(n) != high {
return 0, 0, fmt.Errorf("datastore: internal error: could not allocate %d IDs", n)
}
return low, high, nil
} | |
c179412 | return ok && callErr.Code == 4
} | |
c179413 | == nil {
return nil, errNotAppEngineContext
}
return c, nil
} | |
c179414 | return send(c, "Send", msg)
} | |
c179415 | return send(c, "SendToAdmins", msg)
} | |
c179416 | {
if t.Result == FAIL {
count++
}
}
}
return count
} | |
c179417 | nil {
return
}
// Decode first typ3 byte.
typ = Typ3(value64 & 0x07)
// Decode num.
var num64 uint64
num64 = value64 >> 3
if num64 > (1<<29 - 1) {
err = fmt.Errorf("invalid field num %v", num64)
return
}
num = uint32(num64)
return
} | |
c179418 | err = fmt.Errorf("unexpected Typ3. want %v, got %v", typWanted, typ)
}
return
} | |
c179419 | typ3 byte: %v", Typ3(bz[0]).String())
return
}
typ = Typ3(bz[0])
n = 1
return
} | |
c179420 | PrefixBytes{}
copy(pb[:], prefixBytes)
return pb
} | |
c179421 | reflect.Int64,
reflect.Float32, reflect.Float64,
reflect.Complex64, reflect.Complex128:
s := info.Type.Size()
return fmt.Sprintf("0x%X", s)
default:
return "variable"
}
} | |
c179422 | info.Implementers[cinfo.Prefix] = append(
info.Implementers[cinfo.Prefix], cinfo)
}
}
} | |
c179423 | }
if !inPrio {
return fmt.Errorf("%v conflicts with %v other(s). Add it to the priority list for %v.",
cinfo.Type, len(cinfos), iinfo.Type)
}
}
}
return nil
} | |
c179424 | = cPtrRv.Elem()
irvSet = cPtrRv
} else {
crv = reflect.New(cinfo.Type).Elem()
irvSet = crv
}
return
} | |
c179425 | }
_n, err = w.Write(bz) // TODO: handle overflow in 32-bit systems.
n = int64(_n)
return
} | |
c179426 | {
return nil, err
}
err = cdc.encodeReflectBinary(buf, info, rv, FieldOptions{BinFieldNum: 1}, true)
if err != nil {
return nil, err
}
bz = buf.Bytes()
// If registered concrete, prepend prefix bytes.
if info.Registered {
pb := info.Prefix.Bytes()
bz = append(pb, bz...)
}
return bz, nil
} | |
c179427 |
} else if u64 < uint64(len(bz)-n) {
return fmt.Errorf("Bytes left over in UnmarshalBinaryLengthPrefixed, should read %v more bytes but have %v",
u64, len(bz)-n)
}
bz = bz[n:]
// Decode.
return cdc.UnmarshalBinaryBare(bz, ptr)
} | |
c179428 | bytes %X (since it is registered concrete) but got %X", pb, bz)
} else if !bytes.Equal(bz[:4], pb) {
return fmt.Errorf("UnmarshalBinaryBare expected to read prefix bytes %X (since it is registered concrete) but got %X...", pb, bz[:4])
}
bz = bz[4:]
}
// Decode contents into rv.
n, err := cdc.decodeReflectBinary(bz, info, rv, FieldOptions{BinFieldNum: 1}, true)
if err != nil {
return fmt.Errorf("unmarshal to %v failed after %d bytes (%v): %X", info.Type, n, err, bz)
}
if n != len(bz) {
return fmt.Errorf("unmarshal to %v didn't read all bytes. Expected to read %v, only read %v: %X", info.Type, len(bz), n, bz)
}
return nil
} | |
c179429 | {
bz, err := cdc.MarshalJSON(o)
if err != nil {
panic(err)
}
return bz
} | |
c179430 | := cdc.UnmarshalJSON(bz, ptr); err != nil {
panic(err)
}
} | |
c179431 | err = json.Indent(&out, bz, prefix, indent)
if err != nil {
return nil, err
}
return out.Bytes(), nil
} | |
c179432 |
reader := internalDataReader{
wrapped:r,
buffered:buffered,
}
return &reader
} | |
c179433 | _, err = r.buffered.Discard(1)
if nil != err {
return n, err
}
}
if SE == peeked[0] {
_, err = r.buffered.Discard(1)
if nil != err {
return n, err
}
break
}
}
}
case SE:
_, err = r.buffered.Discard(1)
if nil != err {
return n, err
}
default:
// If we get in here, this is not following the TELNET protocol.
//@TODO: Make a better error.
err = errCorrupted
return n, err
}
} else {
p[0] = b
n++
p = p[1:]
}
}
return n, nil
} | |
c179434 | SessionTicketsDisabled: server.TLSConfig.SessionTicketsDisabled,
SessionTicketKey: server.TLSConfig.SessionTicketKey,
ClientSessionCache: server.TLSConfig.ClientSessionCache,
MinVersion: server.TLSConfig.MinVersion,
MaxVersion: server.TLSConfig.MaxVersion,
CurvePreferences: server.TLSConfig.CurvePreferences,
}
}
tlsConfigHasCertificate := len(tlsConfig.Certificates) > 0 || nil != tlsConfig.GetCertificate
if "" == certFile || "" == keyFile || !tlsConfigHasCertificate {
tlsConfig.Certificates = make([]tls.Certificate, 1)
var err error
tlsConfig.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
if nil != err {
return err
}
}
tlsListener := tls.NewListener(listener, tlsConfig)
return server.Serve(tlsListener)
} | |
c179435 | Handler {
return fn(ctx, name, args...)
} | |
c179436 | for i, datum := range args {
argsCopy[i] = datum
}
handler := internalPromotedHandlerFunc{
err:nil,
fn:fn,
stdin:stdin,
stdout:stdout,
stderr:stderr,
stdinPipe:stdinPipe,
stdoutPipe:stdoutPipe,
stderrPipe:stderrPipe,
args:argsCopy,
}
return &handler
} | |
c179437 | := &Server{Handler: handler}
return server.Serve(listener)
} | |
c179438 | if err != nil {
//@TODO: Could try to recover from certain kinds of errors. Maybe waiting a while before trying again.
return err
}
logger.Debugf("Received new connection from %q.", conn.RemoteAddr())
// Handle the new TELNET client connection by spawning
// a new goroutine.
go server.handle(conn, handler)
logger.Debugf("Spawned handler to handle connection from %q.", conn.RemoteAddr())
}
} | |
c179439 |
fmt.Fprintln(os.Stderr, "error:", msg)
os.Exit(-1)
} | |
c179440 | // prefix with a space
fmt.Fprint(w, " ")
if !spec.required {
fmt.Fprint(w, "[")
}
fmt.Fprint(w, synopsis(spec, "--"+spec.long))
if !spec.required {
fmt.Fprint(w, "]")
}
}
// write the positional component of the usage message
for _, spec := range positionals {
// prefix with a space
fmt.Fprint(w, " ")
up := strings.ToUpper(spec.long)
if spec.multiple {
if !spec.required {
fmt.Fprint(w, "[")
}
fmt.Fprintf(w, "%s [%s ...]", up, up)
if !spec.required {
fmt.Fprint(w, "]")
}
} else {
fmt.Fprint(w, up)
}
}
fmt.Fprint(w, "\n")
} | |
c179441 | }
}
// write the list of options
fmt.Fprint(w, "\nOptions:\n")
for _, spec := range options {
printOption(w, spec)
}
// write the list of built in options
printOption(w, &spec{boolean: true, long: "help", short: "h", help: "display this help and exit"})
if p.version != "" {
printOption(w, &spec{boolean: true, long: "version", help: "display version and exit"})
}
} | |
c179442 |
if err == ErrVersion {
fmt.Println(p.version)
os.Exit(0)
}
if err != nil {
p.Fail(err.Error())
}
return p
} | |
c179443 | dest...)
if err != nil {
return err
}
return p.Parse(flags())
} | |
c179444 | := v.Field(i)
expand := visit(field, val, t)
if expand && field.Type.Kind() == reflect.Struct {
walkFields(val, visit)
}
}
} | |
c179445 | arg == "--help" {
return ErrHelp
}
if arg == "--version" {
return ErrVersion
}
if arg == "--" {
break
}
}
// Process all command line arguments
return process(p.specs, args)
} | |
c179446 |
for _, s := range values {
v := reflect.New(elem)
if err := scalar.ParseValue(v.Elem(), s); err != nil {
return err
}
if !ptr {
v = v.Elem()
}
dest.Set(reflect.Append(dest, v))
}
return nil
} | |
c179447 |
// Look inside pointer types (again, in case of []*Type)
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
parseable = scalar.CanParse(t)
boolean = isBoolean(t)
if parseable {
return
}
return false, false, false
} | |
c179448 |
case t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Bool:
return true
default:
return false
}
} | |
c179449 | := &Tree{root: &node{}}
for k, v := range m {
t.Insert(k, v)
}
return t
} | |
c179450 | }
parent.updateEdge(search[0], child)
// Restore the existing node
child.addEdge(edge{
label: n.prefix[commonPrefix],
node: n,
})
n.prefix = n.prefix[commonPrefix:]
// Create a new leaf node
leaf := &leafNode{
key: s,
val: v,
}
// If the new key is a subset, add to to this node
search = search[commonPrefix:]
if len(search) == 0 {
child.leaf = leaf
return nil, false
}
// Create a new edge for the node
child.addEdge(edge{
label: search[0],
node: &node{
leaf: leaf,
prefix: search,
},
})
return nil, false
}
} | |
c179451 | search = search[len(n.prefix):]
} else {
break
}
}
return nil, false
DELETE:
// Delete the leaf
leaf := n.leaf
n.leaf = nil
t.size--
// Check if we should delete this node from the parent
if parent != nil && len(n.edges) == 0 {
parent.delEdge(label)
}
// Check if we should merge this node
if n != t.root && len(n.edges) == 1 {
n.mergeChild()
}
// Check if we should merge the parent's other child
if parent != nil && parent != t.root && len(parent.edges) == 1 && !parent.isLeaf() {
parent.mergeChild()
}
return leaf.val, true
} | |
c179452 | t.deletePrefix(nil, t.root, s)
} | |
c179453 | Check if we should merge the parent's other child
if parent != nil && parent != t.root && len(parent.edges) == 1 && !parent.isLeaf() {
parent.mergeChild()
}
t.size -= subTreeSize
return subTreeSize
}
// Look for an edge
label := prefix[0]
child := n.getEdge(label)
if child == nil || (!strings.HasPrefix(child.prefix, prefix) && !strings.HasPrefix(prefix, child.prefix)) {
return 0
}
// Consume the search prefix
if len(child.prefix) > len(prefix) {
prefix = prefix[len(prefix):]
} else {
prefix = prefix[len(child.prefix):]
}
return t.deletePrefix(n, child, prefix)
} | |
c179454 |
}
// Consume the search prefix
if strings.HasPrefix(search, n.prefix) {
search = search[len(n.prefix):]
} else {
break
}
}
return nil, false
} | |
c179455 | }
// Consume the search prefix
if strings.HasPrefix(search, n.prefix) {
search = search[len(n.prefix):]
} else {
break
}
}
if last != nil {
return last.key, last.val, true
}
return "", nil, false
} | |
c179456 | n = n.edges[0].node
} else {
break
}
}
return "", nil, false
} | |
c179457 | if n == nil {
break
}
// Consume the search prefix
if strings.HasPrefix(search, n.prefix) {
search = search[len(n.prefix):]
} else if strings.HasPrefix(n.prefix, search) {
// Child may be under our search prefix
recursiveWalk(n, fn)
return
} else {
break
}
}
} | |
c179458 | e := range n.edges {
if recursiveWalk(e.node, fn) {
return true
}
}
return false
} | |
c179459 | v interface{}) bool {
out[k] = v
return false
})
return out
} | |
c179460 | {
ipnumtmp.Rsh(ipnum, 16)
ipnumtmp.Lsh(ipnumtmp, 3)
ipindex = uint32(ipnumtmp.Add(ipnumtmp, big.NewInt(int64(meta.ipv4indexbaseaddr))).Uint64())
}
} else if iptype == 6 {
if meta.ipv6indexbaseaddr > 0 {
ipnumtmp.Rsh(ipnum, 112)
ipnumtmp.Lsh(ipnumtmp, 3)
ipindex = uint32(ipnumtmp.Add(ipnumtmp, big.NewInt(int64(meta.ipv6indexbaseaddr))).Uint64())
}
}
return
} | |
c179461 | binary.Read(buf, binary.LittleEndian, &retval)
if err != nil {
fmt.Println("Binary read failed:", err)
}
return retval
} | |
c179462 | to big endian
for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 {
data[i], data[j] = data[j], data[i]
}
retval.SetBytes(data)
return retval
} | |
c179463 | = mesg
x.Areacode = mesg
x.Weatherstationcode = mesg
x.Weatherstationname = mesg
x.Mcc = mesg
x.Mnc = mesg
x.Mobilebrand = mesg
x.Usagetype = mesg
return x
} | |
c179464 | %s\n", x.Areacode)
fmt.Printf("weatherstationcode: %s\n", x.Weatherstationcode)
fmt.Printf("weatherstationname: %s\n", x.Weatherstationname)
fmt.Printf("mcc: %s\n", x.Mcc)
fmt.Printf("mnc: %s\n", x.Mnc)
fmt.Printf("mobilebrand: %s\n", x.Mobilebrand)
fmt.Printf("elevation: %f\n", x.Elevation)
fmt.Printf("usagetype: %s\n", x.Usagetype)
} | |
c179465 |
gc.Restore()
// Return the output filename
return samples.Output("gopher", ext), nil
} | |
c179466 | pdf.OutputFileAndClose(filePath)
} | |
c179467 | when no move has been done
p.MoveTo(x, y)
} else {
p.appendToPath(CubicCurveToCmp, cx1, cy1, cx2, cy2, x, y)
}
p.x = x
p.y = y
} | |
c179468 | > 0 {
p.LineTo(startX, startY)
} else {
p.MoveTo(startX, startY)
}
p.appendToPath(ArcToCmp, cx, cy, rx, ry, startAngle, angle)
p.x = cx + math.Cos(endAngle)*rx
p.y = cy + math.Sin(endAngle)*ry
} | |
c179469 | p.Points[j+4], p.Points[j+5])
j = j + 6
case ArcToCmp:
s += fmt.Sprintf("ArcTo: %f, %f, %f, %f, %f, %f\n", p.Points[j], p.Points[j+1], p.Points[j+2], p.Points[j+3], p.Points[j+4], p.Points[j+5])
j = j + 6
case CloseCmp:
s += "Close\n"
}
}
return s
} | |
c179470 | j + 6
case ArcToCmp:
p.Points[j+1] = -p.Points[j+1]
p.Points[j+3] = -p.Points[j+3]
p.Points[j+4] = -p.Points[j+4] // start angle
p.Points[j+5] = -p.Points[j+5] // angle
j = j + 6
case CloseCmp:
}
}
p.y = -p.y
return p
} | |
c179471 | &GlyphCacheImp {
glyphs: glyphs,
}
} | |
c179472 | nil {
glyphCache.glyphs[fontName][chr] = renderGlyph(gc, fontName, chr)
}
return glyphCache.glyphs[fontName][chr].Copy()
} | |
c179473 |
gc.BeginPath()
width := gc.CreateStringPath(string(chr), 0, 0)
path := gc.GetPath()
return &Glyph{
Path: &path,
Width: width,
}
} | |
c179474 | g.Path.Copy(),
Width: g.Width,
}
} | |
c179475 | {
gc.Save()
gc.BeginPath()
gc.Translate(x, y)
gc.Fill(g.Path)
gc.Restore()
return g.Width
} | |
c179476 | 105, 35, 25)
gc.SetFillColor(color.RGBA{0xff, 0xff, 0x44, 0xff})
gc.FillStroke()
// Return the output filename
return samples.Output("line", ext), nil
} | |
c179477 | {
// Draw a line
gc.MoveTo(x0, y0)
gc.LineTo(x1, y1)
gc.Stroke()
} | |
c179478 | ci := len(p.colors)
p.vertices = p.vertices[0 : vi+vlenrequired]
p.colors = p.colors[0 : ci+clenrequired]
var (
colors []uint8
vertices []int32
)
for _, s := range ss {
a := uint8((s.Alpha * p.ca / M16) >> 8)
colors = p.colors[ci:]
colors[0] = p.cr
colors[1] = p.cg
colors[2] = p.cb
colors[3] = a
colors[4] = p.cr
colors[5] = p.cg
colors[6] = p.cb
colors[7] = a
ci += 8
vertices = p.vertices[vi:]
vertices[0] = int32(s.X0)
vertices[1] = int32(s.Y)
vertices[2] = int32(s.X1)
vertices[3] = int32(s.Y)
vi += 4
}
} | |
c179479 | uint8((r * M16 / a) >> 8)
p.cg = uint8((g * M16 / a) >> 8)
p.cb = uint8((b * M16 / a) >> 8)
p.ca = a
}
} | |
c179480 |
p.colors = make([]uint8, 0, 1024)
return p
} | |
c179481 | }
if err := gc.glyphBuf.Load(gc.Current.Font, fixed.Int26_6(gc.Current.Scale), index, font.HintingNone); err != nil {
log.Println(err)
return 0, 0, 0, 0
}
e0 := 0
for _, e1 := range gc.glyphBuf.Ends {
ps := gc.glyphBuf.Points[e0:e1]
for _, p := range ps {
x, y := pointToF64Point(p)
top = math.Min(top, y)
bottom = math.Max(bottom, y)
left = math.Min(left, x+cursor)
right = math.Max(right, x+cursor)
}
}
cursor += fUnitsToFloat64(f.HMetric(fixed.Int26_6(gc.Current.Scale), index).AdvanceWidth)
prev, hasPrev = index, true
}
return left, top, right, bottom
} | |
c179482 | = gc.Current.FontSize * float64(gc.DPI) * (64.0 / 72.0)
} | |
c179483 | *truetype.Font) {
gc.Current.Font = font
} | |
c179484 |
// replace groups with new masked group
gc.svg.Groups = []*Group{newGroup}
} | |
c179485 | }
// create elements
svgText := Text{}
group := gc.newGroup(drawType)
// set attrs to text element
svgText.Text = text
svgText.FontSize = gc.Current.FontSize
svgText.X = x
svgText.Y = y
svgText.FontFamily = gc.Current.FontData.Name
// attach to group
group.Texts = []*Text{&svgText}
left, _, right, _ := gc.GetStringBounds(text)
return right - left
} | |
c179486 |
if len(gc.Current.Dash) > 0 {
group.StrokeDasharray = toSvgArray(gc.Current.Dash)
group.StrokeDashoffset = toSvgLength(gc.Current.DashOffset)
}
}
if drawType&filled == filled {
group.Fill = toSvgRGBA(gc.Current.FillColor)
group.FillRule = toSvgFillRule(gc.Current.FillRule)
}
group.Transform = toSvgTransform(gc.Current.Tr)
// attach
gc.svg.Groups = append(gc.svg.Groups, &group)
return &group
} | |
c179487 | attach mask
gc.svg.Masks = append(gc.svg.Masks, mask)
mask.Id = "mask-" + strconv.Itoa(len(gc.svg.Masks))
return mask
} | |
c179488 |
svgFont.Glyphs = append(svgFont.Glyphs, &Glyph{
Rune: Rune(rune),
Desc: toSvgPathDesc(glypPath),
HorizAdvX: glyph.Width,
})
}
// set attrs
svgFont.Id = "font-" + strconv.Itoa(len(gc.svg.Fonts))
svgFont.Name = fontName
// TODO use css @font-face with id instead of this
svgFont.Face = &Face{Family: fontName, Units: 2048, HorizAdvX: 2048}
return svgFont
} | |
c179489 | = math.Abs(((c[2]-c[4])*dy - (c[3]-c[5])*dx))
// if it's flat then trace a line
if (d*d) <= flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-6 {
t.LineTo(c[4], c[5])
i -= 6
} else {
// second half of bezier go lower onto the stack
SubdivideQuad(c, curves[i+6:], curves[i:])
i += 6
}
}
return nil
} | |
c179490 |
return fmt.Sprintf("%s:%d:%d:%9.2f", fontData.Name, fontData.Family, fontData.Style, cs.FontSize)
} | |
c179491 | 1.0
gc.Current.StrokeColor = image.Black
gc.Current.FillColor = image.White
gc.Current.Cap = draw2d.RoundCap
gc.Current.FillRule = draw2d.FillRuleEvenOdd
gc.Current.Join = draw2d.RoundJoin
gc.Current.FontSize = 10
gc.Current.FontData = DefaultFontData
return gc
} | |
c179492 | make(map[string]*truetype.Font),
folder: folder,
namer: FontFileName,
}
} | |
c179493 | make(map[string]*truetype.Font),
folder: folder,
namer: FontFileName,
}
} | |
c179494 | 48, 240, 72)
gc.Restore()
// Return the output filename
return samples.Output("gopher2", ext), nil
} | |
c179495 | compatible with draw2d
pdf.SetMargins(0, 0, 0)
pdf.SetDrawColor(0, 0, 0)
pdf.SetFillColor(255, 255, 255)
pdf.SetLineCapStyle("round")
pdf.SetLineJoinStyle("round")
pdf.SetLineWidth(1)
pdf.AddPage()
return pdf
} | |
c179496 |
draw2dkit.Rectangle(gc, x1, y1, x2, y2)
gc.Fill()
// restore state
gc.SetFillColor(f)
gc.pdf.MoveTo(x, y)
} | |
c179497 | := &GraphicContext{draw2dbase.NewStackGraphicContext(), pdf, DPI}
gc.SetDPI(DPI)
return gc
} | |
c179498 | := gc.pdf.GetPageSize()
clearRect(gc, 0, 0, width, height)
} | |
c179499 | if d.Ascent == 0 {
// not defined (standard font?), use average of 81%
top = 0.81 * h
} else {
top = -float64(d.Ascent) * h / float64(d.Ascent-d.Descent)
}
return 0, top, gc.pdf.GetStringWidth(s), top + h
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.