id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
138,500 | zach-klippenstein/goregen | internal_generator.go | newGenerators | func newGenerators(regexps []*syntax.Regexp, args *GeneratorArgs) ([]*internalGenerator, error) {
generators := make([]*internalGenerator, len(regexps), len(regexps))
var err error
// create a generator for each alternate pattern
for i, subR := range regexps {
generators[i], err = newGenerator(subR, args)
if e... | go | func newGenerators(regexps []*syntax.Regexp, args *GeneratorArgs) ([]*internalGenerator, error) {
generators := make([]*internalGenerator, len(regexps), len(regexps))
var err error
// create a generator for each alternate pattern
for i, subR := range regexps {
generators[i], err = newGenerator(subR, args)
if e... | [
"func",
"newGenerators",
"(",
"regexps",
"[",
"]",
"*",
"syntax",
".",
"Regexp",
",",
"args",
"*",
"GeneratorArgs",
")",
"(",
"[",
"]",
"*",
"internalGenerator",
",",
"error",
")",
"{",
"generators",
":=",
"make",
"(",
"[",
"]",
"*",
"internalGenerator",... | // Create a new generator for each expression in regexps. | [
"Create",
"a",
"new",
"generator",
"for",
"each",
"expression",
"in",
"regexps",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/internal_generator.go#L71-L84 |
138,501 | zach-klippenstein/goregen | internal_generator.go | newGenerator | func newGenerator(regexp *syntax.Regexp, args *GeneratorArgs) (generator *internalGenerator, err error) {
simplified := regexp.Simplify()
factory, ok := generatorFactories[simplified.Op]
if ok {
return factory(simplified, args)
}
return nil, fmt.Errorf("invalid generator pattern: /%s/ as /%s/\n%s",
regexp, s... | go | func newGenerator(regexp *syntax.Regexp, args *GeneratorArgs) (generator *internalGenerator, err error) {
simplified := regexp.Simplify()
factory, ok := generatorFactories[simplified.Op]
if ok {
return factory(simplified, args)
}
return nil, fmt.Errorf("invalid generator pattern: /%s/ as /%s/\n%s",
regexp, s... | [
"func",
"newGenerator",
"(",
"regexp",
"*",
"syntax",
".",
"Regexp",
",",
"args",
"*",
"GeneratorArgs",
")",
"(",
"generator",
"*",
"internalGenerator",
",",
"err",
"error",
")",
"{",
"simplified",
":=",
"regexp",
".",
"Simplify",
"(",
")",
"\n\n",
"factor... | // Create a new generator for r. | [
"Create",
"a",
"new",
"generator",
"for",
"r",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/internal_generator.go#L87-L97 |
138,502 | zach-klippenstein/goregen | internal_generator.go | noop | func noop(regexp *syntax.Regexp, args *GeneratorArgs) (*internalGenerator, error) {
return &internalGenerator{regexp.String(), func() string {
return ""
}}, nil
} | go | func noop(regexp *syntax.Regexp, args *GeneratorArgs) (*internalGenerator, error) {
return &internalGenerator{regexp.String(), func() string {
return ""
}}, nil
} | [
"func",
"noop",
"(",
"regexp",
"*",
"syntax",
".",
"Regexp",
",",
"args",
"*",
"GeneratorArgs",
")",
"(",
"*",
"internalGenerator",
",",
"error",
")",
"{",
"return",
"&",
"internalGenerator",
"{",
"regexp",
".",
"String",
"(",
")",
",",
"func",
"(",
")... | // Generator that does nothing. | [
"Generator",
"that",
"does",
"nothing",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/internal_generator.go#L100-L104 |
138,503 | zach-klippenstein/goregen | internal_generator.go | opCharClass | func opCharClass(regexp *syntax.Regexp, args *GeneratorArgs) (*internalGenerator, error) {
enforceOp(regexp, syntax.OpCharClass)
charClass := parseCharClass(regexp.Rune)
return createCharClassGenerator(regexp.String(), charClass, args)
} | go | func opCharClass(regexp *syntax.Regexp, args *GeneratorArgs) (*internalGenerator, error) {
enforceOp(regexp, syntax.OpCharClass)
charClass := parseCharClass(regexp.Rune)
return createCharClassGenerator(regexp.String(), charClass, args)
} | [
"func",
"opCharClass",
"(",
"regexp",
"*",
"syntax",
".",
"Regexp",
",",
"args",
"*",
"GeneratorArgs",
")",
"(",
"*",
"internalGenerator",
",",
"error",
")",
"{",
"enforceOp",
"(",
"regexp",
",",
"syntax",
".",
"OpCharClass",
")",
"\n",
"charClass",
":=",
... | // Handles syntax.ClassNL because the parser uses that flag to generate character
// classes that respect it. | [
"Handles",
"syntax",
".",
"ClassNL",
"because",
"the",
"parser",
"uses",
"that",
"flag",
"to",
"generate",
"character",
"classes",
"that",
"respect",
"it",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/internal_generator.go#L155-L159 |
138,504 | zach-klippenstein/goregen | internal_generator.go | enforceOp | func enforceOp(r *syntax.Regexp, op syntax.Op) {
if r.Op != op {
panic(fmt.Sprintf("invalid Op: expected %s, was %s", opToString(op), opToString(r.Op)))
}
} | go | func enforceOp(r *syntax.Regexp, op syntax.Op) {
if r.Op != op {
panic(fmt.Sprintf("invalid Op: expected %s, was %s", opToString(op), opToString(r.Op)))
}
} | [
"func",
"enforceOp",
"(",
"r",
"*",
"syntax",
".",
"Regexp",
",",
"op",
"syntax",
".",
"Op",
")",
"{",
"if",
"r",
".",
"Op",
"!=",
"op",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"opToString",
"(",
"op",
")",
",",
"opToStr... | // Panic if r.Op != op. | [
"Panic",
"if",
"r",
".",
"Op",
"!",
"=",
"op",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/internal_generator.go#L221-L225 |
138,505 | zach-klippenstein/goregen | internal_generator.go | enforceSingleSub | func enforceSingleSub(regexp *syntax.Regexp) error {
if len(regexp.Sub) != 1 {
return generatorError(nil,
"%s expected 1 sub-expression, but got %d: %s", opToString(regexp.Op), len(regexp.Sub), regexp)
}
return nil
} | go | func enforceSingleSub(regexp *syntax.Regexp) error {
if len(regexp.Sub) != 1 {
return generatorError(nil,
"%s expected 1 sub-expression, but got %d: %s", opToString(regexp.Op), len(regexp.Sub), regexp)
}
return nil
} | [
"func",
"enforceSingleSub",
"(",
"regexp",
"*",
"syntax",
".",
"Regexp",
")",
"error",
"{",
"if",
"len",
"(",
"regexp",
".",
"Sub",
")",
"!=",
"1",
"{",
"return",
"generatorError",
"(",
"nil",
",",
"\"",
"\"",
",",
"opToString",
"(",
"regexp",
".",
"... | // Return an error if r has 0 or more than 1 sub-expression. | [
"Return",
"an",
"error",
"if",
"r",
"has",
"0",
"or",
"more",
"than",
"1",
"sub",
"-",
"expression",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/internal_generator.go#L228-L234 |
138,506 | zach-klippenstein/goregen | regexp_format.go | inspectRegexpToString | func inspectRegexpToString(r *syntax.Regexp) string {
var buffer bytes.Buffer
inspectRegexpToWriter(&buffer, r)
return buffer.String()
} | go | func inspectRegexpToString(r *syntax.Regexp) string {
var buffer bytes.Buffer
inspectRegexpToWriter(&buffer, r)
return buffer.String()
} | [
"func",
"inspectRegexpToString",
"(",
"r",
"*",
"syntax",
".",
"Regexp",
")",
"string",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"inspectRegexpToWriter",
"(",
"&",
"buffer",
",",
"r",
")",
"\n",
"return",
"buffer",
".",
"String",
"(",
")",
"\n... | // inspectRegexpToString returns a string describing a regular expression. | [
"inspectRegexpToString",
"returns",
"a",
"string",
"describing",
"a",
"regular",
"expression",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/regexp_format.go#L27-L31 |
138,507 | zach-klippenstein/goregen | regexp_format.go | inspectPatternsToString | func inspectPatternsToString(simplify bool, patterns ...string) string {
var buffer bytes.Buffer
for _, pattern := range patterns {
inspectPatternsToWriter(simplify, &buffer, pattern)
}
return buffer.String()
} | go | func inspectPatternsToString(simplify bool, patterns ...string) string {
var buffer bytes.Buffer
for _, pattern := range patterns {
inspectPatternsToWriter(simplify, &buffer, pattern)
}
return buffer.String()
} | [
"func",
"inspectPatternsToString",
"(",
"simplify",
"bool",
",",
"patterns",
"...",
"string",
")",
"string",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"pattern",
":=",
"range",
"patterns",
"{",
"inspectPatternsToWriter",
"(",
"simpli... | // inspectPatternsToString returns a string describing one or more regular expressions. | [
"inspectPatternsToString",
"returns",
"a",
"string",
"describing",
"one",
"or",
"more",
"regular",
"expressions",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/regexp_format.go#L34-L40 |
138,508 | zach-klippenstein/goregen | regexp_format.go | parseOrPanic | func parseOrPanic(simplify bool, pattern string) *syntax.Regexp {
regexp, err := syntax.Parse(pattern, 0)
if err != nil {
panic(err)
}
if simplify {
regexp = regexp.Simplify()
}
return regexp
} | go | func parseOrPanic(simplify bool, pattern string) *syntax.Regexp {
regexp, err := syntax.Parse(pattern, 0)
if err != nil {
panic(err)
}
if simplify {
regexp = regexp.Simplify()
}
return regexp
} | [
"func",
"parseOrPanic",
"(",
"simplify",
"bool",
",",
"pattern",
"string",
")",
"*",
"syntax",
".",
"Regexp",
"{",
"regexp",
",",
"err",
":=",
"syntax",
".",
"Parse",
"(",
"pattern",
",",
"0",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
... | // ParseOrPanic parses a regular expression into an AST.
// Panics on error. | [
"ParseOrPanic",
"parses",
"a",
"regular",
"expression",
"into",
"an",
"AST",
".",
"Panics",
"on",
"error",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/regexp_format.go#L74-L83 |
138,509 | zach-klippenstein/goregen | regexp_format.go | runesToString | func runesToString(runes ...rune) string {
defer func() {
if err := recover(); err != nil {
panic(fmt.Errorf("RunesToString panicked"))
}
}()
var buffer bytes.Buffer
for _, r := range runes {
buffer.WriteRune(r)
}
return buffer.String()
} | go | func runesToString(runes ...rune) string {
defer func() {
if err := recover(); err != nil {
panic(fmt.Errorf("RunesToString panicked"))
}
}()
var buffer bytes.Buffer
for _, r := range runes {
buffer.WriteRune(r)
}
return buffer.String()
} | [
"func",
"runesToString",
"(",
"runes",
"...",
"rune",
")",
"string",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"recover",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
... | // runesToString converts a slice of runes to the string they represent. | [
"runesToString",
"converts",
"a",
"slice",
"of",
"runes",
"to",
"the",
"string",
"they",
"represent",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/regexp_format.go#L86-L97 |
138,510 | zach-klippenstein/goregen | regexp_format.go | runesToDecimalString | func runesToDecimalString(runes []rune) string {
var buffer bytes.Buffer
for _, r := range runes {
buffer.WriteString(fmt.Sprintf("%d, ", r))
}
return buffer.String()
} | go | func runesToDecimalString(runes []rune) string {
var buffer bytes.Buffer
for _, r := range runes {
buffer.WriteString(fmt.Sprintf("%d, ", r))
}
return buffer.String()
} | [
"func",
"runesToDecimalString",
"(",
"runes",
"[",
"]",
"rune",
")",
"string",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"runes",
"{",
"buffer",
".",
"WriteString",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
... | // RunesToDecimalString converts a slice of runes to their comma-separated decimal values. | [
"RunesToDecimalString",
"converts",
"a",
"slice",
"of",
"runes",
"to",
"their",
"comma",
"-",
"separated",
"decimal",
"values",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/regexp_format.go#L100-L106 |
138,511 | zach-klippenstein/goregen | regexp_format.go | opToString | func opToString(op syntax.Op) string {
switch op {
case syntax.OpNoMatch:
return "OpNoMatch"
case syntax.OpEmptyMatch:
return "OpEmptyMatch"
case syntax.OpLiteral:
return "OpLiteral"
case syntax.OpCharClass:
return "OpCharClass"
case syntax.OpAnyCharNotNL:
return "OpAnyCharNotNL"
case syntax.OpAnyChar:... | go | func opToString(op syntax.Op) string {
switch op {
case syntax.OpNoMatch:
return "OpNoMatch"
case syntax.OpEmptyMatch:
return "OpEmptyMatch"
case syntax.OpLiteral:
return "OpLiteral"
case syntax.OpCharClass:
return "OpCharClass"
case syntax.OpAnyCharNotNL:
return "OpAnyCharNotNL"
case syntax.OpAnyChar:... | [
"func",
"opToString",
"(",
"op",
"syntax",
".",
"Op",
")",
"string",
"{",
"switch",
"op",
"{",
"case",
"syntax",
".",
"OpNoMatch",
":",
"return",
"\"",
"\"",
"\n",
"case",
"syntax",
".",
"OpEmptyMatch",
":",
"return",
"\"",
"\"",
"\n",
"case",
"syntax"... | // opToString gets the string name of a regular expression operation. | [
"opToString",
"gets",
"the",
"string",
"name",
"of",
"a",
"regular",
"expression",
"operation",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/regexp_format.go#L109-L152 |
138,512 | zach-klippenstein/goregen | char_class.go | newCharClass | func newCharClass(start rune, end rune) *tCharClass {
charRange := newCharClassRange(start, end)
return &tCharClass{
Ranges: []tCharClassRange{charRange},
TotalSize: charRange.Size,
}
} | go | func newCharClass(start rune, end rune) *tCharClass {
charRange := newCharClassRange(start, end)
return &tCharClass{
Ranges: []tCharClassRange{charRange},
TotalSize: charRange.Size,
}
} | [
"func",
"newCharClass",
"(",
"start",
"rune",
",",
"end",
"rune",
")",
"*",
"tCharClass",
"{",
"charRange",
":=",
"newCharClassRange",
"(",
"start",
",",
"end",
")",
"\n",
"return",
"&",
"tCharClass",
"{",
"Ranges",
":",
"[",
"]",
"tCharClassRange",
"{",
... | // NewCharClass creates a character class with a single range. | [
"NewCharClass",
"creates",
"a",
"character",
"class",
"with",
"a",
"single",
"range",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/char_class.go#L37-L43 |
138,513 | zach-klippenstein/goregen | char_class.go | GetRuneAt | func (class *tCharClass) GetRuneAt(i int32) rune {
for _, r := range class.Ranges {
if i < r.Size {
return r.Start + rune(i)
}
i -= r.Size
}
panic("index out of bounds")
} | go | func (class *tCharClass) GetRuneAt(i int32) rune {
for _, r := range class.Ranges {
if i < r.Size {
return r.Start + rune(i)
}
i -= r.Size
}
panic("index out of bounds")
} | [
"func",
"(",
"class",
"*",
"tCharClass",
")",
"GetRuneAt",
"(",
"i",
"int32",
")",
"rune",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"class",
".",
"Ranges",
"{",
"if",
"i",
"<",
"r",
".",
"Size",
"{",
"return",
"r",
".",
"Start",
"+",
"rune",
"... | // GetRuneAt gets a rune from CharClass as a contiguous array of runes. | [
"GetRuneAt",
"gets",
"a",
"rune",
"from",
"CharClass",
"as",
"a",
"contiguous",
"array",
"of",
"runes",
"."
] | 795b5e3961ea1912fde60af417ad85e86acc0d6a | https://github.com/zach-klippenstein/goregen/blob/795b5e3961ea1912fde60af417ad85e86acc0d6a/char_class.go#L83-L91 |
138,514 | anacrolix/missinggo | hostmaybeport.go | SplitHostMaybePort | func SplitHostMaybePort(hostport string) HostMaybePort {
host, portStr, err := net.SplitHostPort(hostport)
if err != nil {
if strings.Contains(err.Error(), "missing port") {
return HostMaybePort{
Host: hostport,
NoPort: true,
}
}
return HostMaybePort{
Err: err,
}
}
portI64, err := strconv... | go | func SplitHostMaybePort(hostport string) HostMaybePort {
host, portStr, err := net.SplitHostPort(hostport)
if err != nil {
if strings.Contains(err.Error(), "missing port") {
return HostMaybePort{
Host: hostport,
NoPort: true,
}
}
return HostMaybePort{
Err: err,
}
}
portI64, err := strconv... | [
"func",
"SplitHostMaybePort",
"(",
"hostport",
"string",
")",
"HostMaybePort",
"{",
"host",
",",
"portStr",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"hostport",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"strings",
".",
"Contains",
"(",
"... | // Parse a "hostport" string, a concept that floats around the stdlib a lot
// and is painful to work with. If no port is present, what's usually present
// is just the host. | [
"Parse",
"a",
"hostport",
"string",
"a",
"concept",
"that",
"floats",
"around",
"the",
"stdlib",
"a",
"lot",
"and",
"is",
"painful",
"to",
"work",
"with",
".",
"If",
"no",
"port",
"is",
"present",
"what",
"s",
"usually",
"present",
"is",
"just",
"the",
... | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/hostmaybeport.go#L27-L52 |
138,515 | anacrolix/missinggo | resource/resource.go | ReadSeeker | func ReadSeeker(r Instance) io.ReadSeeker {
fi, err := r.Stat()
if err != nil {
return nil
}
return io.NewSectionReader(r, 0, fi.Size())
} | go | func ReadSeeker(r Instance) io.ReadSeeker {
fi, err := r.Stat()
if err != nil {
return nil
}
return io.NewSectionReader(r, 0, fi.Size())
} | [
"func",
"ReadSeeker",
"(",
"r",
"Instance",
")",
"io",
".",
"ReadSeeker",
"{",
"fi",
",",
"err",
":=",
"r",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"io",
".",
"NewSectionReader",
"(",
... | // Creates a io.ReadSeeker to an Instance. | [
"Creates",
"a",
"io",
".",
"ReadSeeker",
"to",
"an",
"Instance",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/resource/resource.go#L20-L26 |
138,516 | anacrolix/missinggo | resource/resource.go | Move | func Move(from, to Instance) (err error) {
rc, err := from.Get()
if err != nil {
return
}
defer rc.Close()
err = to.Put(rc)
if err != nil {
return
}
from.Delete()
return
} | go | func Move(from, to Instance) (err error) {
rc, err := from.Get()
if err != nil {
return
}
defer rc.Close()
err = to.Put(rc)
if err != nil {
return
}
from.Delete()
return
} | [
"func",
"Move",
"(",
"from",
",",
"to",
"Instance",
")",
"(",
"err",
"error",
")",
"{",
"rc",
",",
"err",
":=",
"from",
".",
"Get",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"defer",
"rc",
".",
"Close",
"(",
")... | // Move instance content, deleting the source if it succeeds. | [
"Move",
"instance",
"content",
"deleting",
"the",
"source",
"if",
"it",
"succeeds",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/resource/resource.go#L29-L41 |
138,517 | anacrolix/missinggo | section_read_seeker.go | NewSectionReadSeeker | func NewSectionReadSeeker(base io.ReadSeeker, off, size int64) (ret ReadSeekContexter) {
ret = §ionReadSeeker{
base: base,
off: off,
size: size,
}
seekOff, err := ret.Seek(0, io.SeekStart)
if err != nil {
panic(err)
}
if seekOff != 0 {
panic(seekOff)
}
return
} | go | func NewSectionReadSeeker(base io.ReadSeeker, off, size int64) (ret ReadSeekContexter) {
ret = §ionReadSeeker{
base: base,
off: off,
size: size,
}
seekOff, err := ret.Seek(0, io.SeekStart)
if err != nil {
panic(err)
}
if seekOff != 0 {
panic(seekOff)
}
return
} | [
"func",
"NewSectionReadSeeker",
"(",
"base",
"io",
".",
"ReadSeeker",
",",
"off",
",",
"size",
"int64",
")",
"(",
"ret",
"ReadSeekContexter",
")",
"{",
"ret",
"=",
"&",
"sectionReadSeeker",
"{",
"base",
":",
"base",
",",
"off",
":",
"off",
",",
"size",
... | // Returns a ReadSeeker on a section of another ReadSeeker. | [
"Returns",
"a",
"ReadSeeker",
"on",
"a",
"section",
"of",
"another",
"ReadSeeker",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/section_read_seeker.go#L20-L34 |
138,518 | anacrolix/missinggo | copy.go | CopyExact | func CopyExact(dest interface{}, src interface{}) {
dV := reflect.ValueOf(dest)
sV := reflect.ValueOf(src)
if dV.Kind() == reflect.Ptr {
dV = dV.Elem()
}
if dV.Kind() == reflect.Array && !dV.CanAddr() {
panic(fmt.Sprintf("dest not addressable: %T", dest))
}
if sV.Kind() == reflect.Ptr {
sV = sV.Elem()
}
... | go | func CopyExact(dest interface{}, src interface{}) {
dV := reflect.ValueOf(dest)
sV := reflect.ValueOf(src)
if dV.Kind() == reflect.Ptr {
dV = dV.Elem()
}
if dV.Kind() == reflect.Array && !dV.CanAddr() {
panic(fmt.Sprintf("dest not addressable: %T", dest))
}
if sV.Kind() == reflect.Ptr {
sV = sV.Elem()
}
... | [
"func",
"CopyExact",
"(",
"dest",
"interface",
"{",
"}",
",",
"src",
"interface",
"{",
"}",
")",
"{",
"dV",
":=",
"reflect",
".",
"ValueOf",
"(",
"dest",
")",
"\n",
"sV",
":=",
"reflect",
".",
"ValueOf",
"(",
"src",
")",
"\n",
"if",
"dV",
".",
"K... | // Copy elements from src to dst. Panics if the length of src and dst are
// different. | [
"Copy",
"elements",
"from",
"src",
"to",
"dst",
".",
"Panics",
"if",
"the",
"length",
"of",
"src",
"and",
"dst",
"are",
"different",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/copy.go#L10-L34 |
138,519 | anacrolix/missinggo | limitlen.go | LimitLen | func LimitLen(b []byte, max ...interface{}) []byte {
return b[:MinInt(len(b), max...)]
} | go | func LimitLen(b []byte, max ...interface{}) []byte {
return b[:MinInt(len(b), max...)]
} | [
"func",
"LimitLen",
"(",
"b",
"[",
"]",
"byte",
",",
"max",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"return",
"b",
"[",
":",
"MinInt",
"(",
"len",
"(",
"b",
")",
",",
"max",
"...",
")",
"]",
"\n",
"}"
] | // Sets an upper bound on the len of b. max can be any type that will cast to
// int64. | [
"Sets",
"an",
"upper",
"bound",
"on",
"the",
"len",
"of",
"b",
".",
"max",
"can",
"be",
"any",
"type",
"that",
"will",
"cast",
"to",
"int64",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/limitlen.go#L5-L7 |
138,520 | anacrolix/missinggo | flag.go | AddCondToFlags | func AddCondToFlags(cond *sync.Cond, flags ...*Flag) {
for _, f := range flags {
f.addCond(cond)
}
} | go | func AddCondToFlags(cond *sync.Cond, flags ...*Flag) {
for _, f := range flags {
f.addCond(cond)
}
} | [
"func",
"AddCondToFlags",
"(",
"cond",
"*",
"sync",
".",
"Cond",
",",
"flags",
"...",
"*",
"Flag",
")",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"flags",
"{",
"f",
".",
"addCond",
"(",
"cond",
")",
"\n",
"}",
"\n",
"}"
] | // Adds the sync.Cond to all the given Flag's. | [
"Adds",
"the",
"sync",
".",
"Cond",
"to",
"all",
"the",
"given",
"Flag",
"s",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/flag.go#L37-L41 |
138,521 | anacrolix/missinggo | tls.go | BestNamedCertificate | func BestNamedCertificate(c *tls.Config, clientHello *tls.ClientHelloInfo) (*tls.Certificate, bool) {
name := strings.ToLower(clientHello.ServerName)
for len(name) > 0 && name[len(name)-1] == '.' {
name = name[:len(name)-1]
}
if cert, ok := c.NameToCertificate[name]; ok {
return cert, true
}
// try replacin... | go | func BestNamedCertificate(c *tls.Config, clientHello *tls.ClientHelloInfo) (*tls.Certificate, bool) {
name := strings.ToLower(clientHello.ServerName)
for len(name) > 0 && name[len(name)-1] == '.' {
name = name[:len(name)-1]
}
if cert, ok := c.NameToCertificate[name]; ok {
return cert, true
}
// try replacin... | [
"func",
"BestNamedCertificate",
"(",
"c",
"*",
"tls",
".",
"Config",
",",
"clientHello",
"*",
"tls",
".",
"ClientHelloInfo",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"bool",
")",
"{",
"name",
":=",
"strings",
".",
"ToLower",
"(",
"clientHello",
"."... | // Select the best named certificate per the usual behaviour if
// c.GetCertificate is nil, and c.NameToCertificate is not. | [
"Select",
"the",
"best",
"named",
"certificate",
"per",
"the",
"usual",
"behaviour",
"if",
"c",
".",
"GetCertificate",
"is",
"nil",
"and",
"c",
".",
"NameToCertificate",
"is",
"not",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/tls.go#L10-L32 |
138,522 | anacrolix/missinggo | httptoo/gzip.go | GzipHandler | func GzipHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") || w.Header().Get("Content-Encoding") != "" || w.Header().Get("Vary") != "" {
h.ServeHTTP(w, r)
return
}
w.Header().Set("Conte... | go | func GzipHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") || w.Header().Get("Content-Encoding") != "" || w.Header().Get("Vary") != "" {
h.ServeHTTP(w, r)
return
}
w.Header().Set("Conte... | [
"func",
"GzipHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"!",
"string... | // Gzips response body if the request says it'll allow it. | [
"Gzips",
"response",
"body",
"if",
"the",
"request",
"says",
"it",
"ll",
"allow",
"it",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/gzip.go#L34-L49 |
138,523 | anacrolix/missinggo | conntrack/instance.go | wakeOne | func (i *Instance) wakeOne() {
i.waitersByPriority.Iter(func(key interface{}) bool {
value := i.waitersByPriority.Get(key).(entryHandleSet)
for eh := range value {
i.wakeEntry(eh.e)
break
}
return false
})
} | go | func (i *Instance) wakeOne() {
i.waitersByPriority.Iter(func(key interface{}) bool {
value := i.waitersByPriority.Get(key).(entryHandleSet)
for eh := range value {
i.wakeEntry(eh.e)
break
}
return false
})
} | [
"func",
"(",
"i",
"*",
"Instance",
")",
"wakeOne",
"(",
")",
"{",
"i",
".",
"waitersByPriority",
".",
"Iter",
"(",
"func",
"(",
"key",
"interface",
"{",
"}",
")",
"bool",
"{",
"value",
":=",
"i",
".",
"waitersByPriority",
".",
"Get",
"(",
"key",
")... | // Wakes the highest priority waiter. | [
"Wakes",
"the",
"highest",
"priority",
"waiter",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/conntrack/instance.go#L97-L106 |
138,524 | anacrolix/missinggo | conntrack/instance.go | wakeEntry | func (i *Instance) wakeEntry(e Entry) {
if _, ok := i.entries[e]; ok {
panic(e)
}
i.entries[e] = make(handles, len(i.waitersByEntry[e]))
for eh := range i.waitersByEntry[e] {
i.entries[e][eh] = struct{}{}
i.deleteWaiter(eh)
eh.wake.Unlock()
}
if i.waitersByEntry[e] != nil {
panic(i.waitersByEntry[e])
}... | go | func (i *Instance) wakeEntry(e Entry) {
if _, ok := i.entries[e]; ok {
panic(e)
}
i.entries[e] = make(handles, len(i.waitersByEntry[e]))
for eh := range i.waitersByEntry[e] {
i.entries[e][eh] = struct{}{}
i.deleteWaiter(eh)
eh.wake.Unlock()
}
if i.waitersByEntry[e] != nil {
panic(i.waitersByEntry[e])
}... | [
"func",
"(",
"i",
"*",
"Instance",
")",
"wakeEntry",
"(",
"e",
"Entry",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"i",
".",
"entries",
"[",
"e",
"]",
";",
"ok",
"{",
"panic",
"(",
"e",
")",
"\n",
"}",
"\n",
"i",
".",
"entries",
"[",
"e",
"]",
... | // Wakes all waiters on an entry. Note that the entry is also woken
// immediately, the waiters are all let through. | [
"Wakes",
"all",
"waiters",
"on",
"an",
"entry",
".",
"Note",
"that",
"the",
"entry",
"is",
"also",
"woken",
"immediately",
"the",
"waiters",
"are",
"all",
"let",
"through",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/conntrack/instance.go#L151-L164 |
138,525 | anacrolix/missinggo | conntrack/instance.go | Wait | func (i *Instance) Wait(ctx context.Context, e Entry, reason string, p priority) (eh *EntryHandle) {
eh = &EntryHandle{
reason: reason,
e: e,
i: i,
priority: p,
created: time.Now(),
}
i.mu.Lock()
hs, ok := i.entries[eh.e]
if ok {
hs[eh] = struct{}{}
i.mu.Unlock()
expvars.Add("waits... | go | func (i *Instance) Wait(ctx context.Context, e Entry, reason string, p priority) (eh *EntryHandle) {
eh = &EntryHandle{
reason: reason,
e: e,
i: i,
priority: p,
created: time.Now(),
}
i.mu.Lock()
hs, ok := i.entries[eh.e]
if ok {
hs[eh] = struct{}{}
i.mu.Unlock()
expvars.Add("waits... | [
"func",
"(",
"i",
"*",
"Instance",
")",
"Wait",
"(",
"ctx",
"context",
".",
"Context",
",",
"e",
"Entry",
",",
"reason",
"string",
",",
"p",
"priority",
")",
"(",
"eh",
"*",
"EntryHandle",
")",
"{",
"eh",
"=",
"&",
"EntryHandle",
"{",
"reason",
":"... | // Nil returns are due to context completion. | [
"Nil",
"returns",
"are",
"due",
"to",
"context",
"completion",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/conntrack/instance.go#L171-L219 |
138,526 | anacrolix/missinggo | httptoo/reverse_proxy.go | RedirectedRequest | func RedirectedRequest(r *http.Request, newUrl string) (ret *http.Request, err error) {
u, err := url.Parse(newUrl)
if err != nil {
return
}
ret = new(http.Request)
*ret = *r
ret.Header = nil
err = deepCopy(&ret.Header, r.Header)
if err != nil {
return
}
ret.URL = u
ret.RequestURI = ""
return
} | go | func RedirectedRequest(r *http.Request, newUrl string) (ret *http.Request, err error) {
u, err := url.Parse(newUrl)
if err != nil {
return
}
ret = new(http.Request)
*ret = *r
ret.Header = nil
err = deepCopy(&ret.Header, r.Header)
if err != nil {
return
}
ret.URL = u
ret.RequestURI = ""
return
} | [
"func",
"RedirectedRequest",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"newUrl",
"string",
")",
"(",
"ret",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"newUrl",
")",
"\n",
"if",
... | // Takes a request, and alters its destination fields, for proxying. | [
"Takes",
"a",
"request",
"and",
"alters",
"its",
"destination",
"fields",
"for",
"proxying",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/reverse_proxy.go#L36-L51 |
138,527 | anacrolix/missinggo | path.go | PathSplitExt | func PathSplitExt(p string) (ret struct {
Root, Ext string
}) {
ret.Ext = path.Ext(p)
ret.Root = p[:len(p)-len(ret.Ext)]
return
} | go | func PathSplitExt(p string) (ret struct {
Root, Ext string
}) {
ret.Ext = path.Ext(p)
ret.Root = p[:len(p)-len(ret.Ext)]
return
} | [
"func",
"PathSplitExt",
"(",
"p",
"string",
")",
"(",
"ret",
"struct",
"{",
"Root",
",",
"Ext",
"string",
"\n",
"}",
")",
"{",
"ret",
".",
"Ext",
"=",
"path",
".",
"Ext",
"(",
"p",
")",
"\n",
"ret",
".",
"Root",
"=",
"p",
"[",
":",
"len",
"("... | // Splits the pathname p into Root and Ext, such that Root+Ext==p. | [
"Splits",
"the",
"pathname",
"p",
"into",
"Root",
"and",
"Ext",
"such",
"that",
"Root",
"+",
"Ext",
"==",
"p",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/path.go#L9-L15 |
138,528 | anacrolix/missinggo | selfcert.go | NewSelfSignedCertificate | func NewSelfSignedCertificate() (cert tls.Certificate, err error) {
cert.PrivateKey, err = rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
return
}
notBefore := time.Now()
notAfter := notBefore.Add(365 * 24 * time.Hour)
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int... | go | func NewSelfSignedCertificate() (cert tls.Certificate, err error) {
cert.PrivateKey, err = rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
return
}
notBefore := time.Now()
notAfter := notBefore.Add(365 * 24 * time.Hour)
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int... | [
"func",
"NewSelfSignedCertificate",
"(",
")",
"(",
"cert",
"tls",
".",
"Certificate",
",",
"err",
"error",
")",
"{",
"cert",
".",
"PrivateKey",
",",
"err",
"=",
"rsa",
".",
"GenerateKey",
"(",
"rand",
".",
"Reader",
",",
"2048",
")",
"\n",
"if",
"err",... | // Creates a self-signed certificate in memory for use with tls.Config. | [
"Creates",
"a",
"self",
"-",
"signed",
"certificate",
"in",
"memory",
"for",
"use",
"with",
"tls",
".",
"Config",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/selfcert.go#L27-L60 |
138,529 | anacrolix/missinggo | timer.go | StoppedFuncTimer | func StoppedFuncTimer(f func()) (t *time.Timer) {
t = time.AfterFunc(math.MaxInt64, f)
if !t.Stop() {
panic("timer already fired")
}
return
} | go | func StoppedFuncTimer(f func()) (t *time.Timer) {
t = time.AfterFunc(math.MaxInt64, f)
if !t.Stop() {
panic("timer already fired")
}
return
} | [
"func",
"StoppedFuncTimer",
"(",
"f",
"func",
"(",
")",
")",
"(",
"t",
"*",
"time",
".",
"Timer",
")",
"{",
"t",
"=",
"time",
".",
"AfterFunc",
"(",
"math",
".",
"MaxInt64",
",",
"f",
")",
"\n",
"if",
"!",
"t",
".",
"Stop",
"(",
")",
"{",
"pa... | // Returns a time.Timer that calls f. The timer is initially stopped. | [
"Returns",
"a",
"time",
".",
"Timer",
"that",
"calls",
"f",
".",
"The",
"timer",
"is",
"initially",
"stopped",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/timer.go#L9-L15 |
138,530 | anacrolix/missinggo | iter/groupby.go | GroupBy | func GroupBy(input Iterator, keyFunc func(interface{}) interface{}) Iterator {
if keyFunc == nil {
keyFunc = func(a interface{}) interface{} { return a }
}
return &groupBy{
input: input,
keyFunc: keyFunc,
groupKey: uniqueKey,
curKey: uniqueKey,
}
} | go | func GroupBy(input Iterator, keyFunc func(interface{}) interface{}) Iterator {
if keyFunc == nil {
keyFunc = func(a interface{}) interface{} { return a }
}
return &groupBy{
input: input,
keyFunc: keyFunc,
groupKey: uniqueKey,
curKey: uniqueKey,
}
} | [
"func",
"GroupBy",
"(",
"input",
"Iterator",
",",
"keyFunc",
"func",
"(",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
")",
"Iterator",
"{",
"if",
"keyFunc",
"==",
"nil",
"{",
"keyFunc",
"=",
"func",
"(",
"a",
"interface",
"{",
"}",
")",
"inter... | // Group by returns an iterator of iterators over the values of the input
// iterator that consecutively return the same value when input to the key
// function. Note that repeated calls to each value of the GroupBy Iterator
// does not return a new iterator over the values for that key. | [
"Group",
"by",
"returns",
"an",
"iterator",
"of",
"iterators",
"over",
"the",
"values",
"of",
"the",
"input",
"iterator",
"that",
"consecutively",
"return",
"the",
"same",
"value",
"when",
"input",
"to",
"the",
"key",
"function",
".",
"Note",
"that",
"repeat... | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/iter/groupby.go#L95-L105 |
138,531 | anacrolix/missinggo | httptoo/client.go | ClientTLSConfig | func ClientTLSConfig(cl *http.Client) *tls.Config {
if cl.Transport == nil {
cl.Transport = http.DefaultTransport
}
tr := cl.Transport.(*http.Transport)
if tr.TLSClientConfig == nil {
tr.TLSClientConfig = &tls.Config{}
}
return tr.TLSClientConfig
} | go | func ClientTLSConfig(cl *http.Client) *tls.Config {
if cl.Transport == nil {
cl.Transport = http.DefaultTransport
}
tr := cl.Transport.(*http.Transport)
if tr.TLSClientConfig == nil {
tr.TLSClientConfig = &tls.Config{}
}
return tr.TLSClientConfig
} | [
"func",
"ClientTLSConfig",
"(",
"cl",
"*",
"http",
".",
"Client",
")",
"*",
"tls",
".",
"Config",
"{",
"if",
"cl",
".",
"Transport",
"==",
"nil",
"{",
"cl",
".",
"Transport",
"=",
"http",
".",
"DefaultTransport",
"\n",
"}",
"\n",
"tr",
":=",
"cl",
... | // Returns the http.Client's TLS Config, traversing and generating any
// defaults along the way to get it. | [
"Returns",
"the",
"http",
".",
"Client",
"s",
"TLS",
"Config",
"traversing",
"and",
"generating",
"any",
"defaults",
"along",
"the",
"way",
"to",
"get",
"it",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/client.go#L10-L19 |
138,532 | anacrolix/missinggo | prioritybitmap/prioritybitmap.go | Set | func (me *PriorityBitmap) Set(bit int, priority int) bool {
if p, ok := me.priorities[bit]; ok && p == priority {
return false
}
if oldPriority, deleted := me.deleteBit(bit); deleted && oldPriority == priority {
panic("should have already returned")
}
if me.priorities == nil {
me.priorities = make(map[int]in... | go | func (me *PriorityBitmap) Set(bit int, priority int) bool {
if p, ok := me.priorities[bit]; ok && p == priority {
return false
}
if oldPriority, deleted := me.deleteBit(bit); deleted && oldPriority == priority {
panic("should have already returned")
}
if me.priorities == nil {
me.priorities = make(map[int]in... | [
"func",
"(",
"me",
"*",
"PriorityBitmap",
")",
"Set",
"(",
"bit",
"int",
",",
"priority",
"int",
")",
"bool",
"{",
"if",
"p",
",",
"ok",
":=",
"me",
".",
"priorities",
"[",
"bit",
"]",
";",
"ok",
"&&",
"p",
"==",
"priority",
"{",
"return",
"false... | // Returns true if the priority is changed, or the bit wasn't present. | [
"Returns",
"true",
"if",
"the",
"priority",
"is",
"changed",
"or",
"the",
"bit",
"wasn",
"t",
"present",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/prioritybitmap/prioritybitmap.go#L85-L117 |
138,533 | anacrolix/missinggo | prioritybitmap/prioritybitmap.go | GetPriority | func (me *PriorityBitmap) GetPriority(bit int) (prio int, ok bool) {
prio, ok = me.priorities[bit]
return
} | go | func (me *PriorityBitmap) GetPriority(bit int) (prio int, ok bool) {
prio, ok = me.priorities[bit]
return
} | [
"func",
"(",
"me",
"*",
"PriorityBitmap",
")",
"GetPriority",
"(",
"bit",
"int",
")",
"(",
"prio",
"int",
",",
"ok",
"bool",
")",
"{",
"prio",
",",
"ok",
"=",
"me",
".",
"priorities",
"[",
"bit",
"]",
"\n",
"return",
"\n",
"}"
] | // ok is false if the bit is not set. | [
"ok",
"is",
"false",
"if",
"the",
"bit",
"is",
"not",
"set",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/prioritybitmap/prioritybitmap.go#L176-L179 |
138,534 | anacrolix/missinggo | filecache/cache.go | WalkItems | func (me *Cache) WalkItems(cb func(ItemInfo)) {
me.mu.Lock()
defer me.mu.Unlock()
for k, ii := range me.items {
cb(ItemInfo{
Path: k,
Accessed: ii.Accessed,
Size: ii.Size,
})
}
} | go | func (me *Cache) WalkItems(cb func(ItemInfo)) {
me.mu.Lock()
defer me.mu.Unlock()
for k, ii := range me.items {
cb(ItemInfo{
Path: k,
Accessed: ii.Accessed,
Size: ii.Size,
})
}
} | [
"func",
"(",
"me",
"*",
"Cache",
")",
"WalkItems",
"(",
"cb",
"func",
"(",
"ItemInfo",
")",
")",
"{",
"me",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"me",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"k",
",",
"ii",
":=",
"range",... | // Calls the function for every item known to be in the cache. | [
"Calls",
"the",
"function",
"for",
"every",
"item",
"known",
"to",
"be",
"in",
"the",
"cache",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/filecache/cache.go#L43-L53 |
138,535 | anacrolix/missinggo | filecache/cache.go | SetCapacity | func (me *Cache) SetCapacity(capacity int64) {
me.mu.Lock()
defer me.mu.Unlock()
me.capacity = capacity
} | go | func (me *Cache) SetCapacity(capacity int64) {
me.mu.Lock()
defer me.mu.Unlock()
me.capacity = capacity
} | [
"func",
"(",
"me",
"*",
"Cache",
")",
"SetCapacity",
"(",
"capacity",
"int64",
")",
"{",
"me",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"me",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"me",
".",
"capacity",
"=",
"capacity",
"\n",
"}"
] | // Setting a negative capacity means unlimited. | [
"Setting",
"a",
"negative",
"capacity",
"means",
"unlimited",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/filecache/cache.go#L65-L69 |
138,536 | anacrolix/missinggo | filecache/cache.go | sanitizePath | func sanitizePath(p string) (ret key) {
if p == "" {
return
}
ret = key(path.Clean("/" + p))
if ret[0] == '/' {
ret = ret[1:]
}
return
} | go | func sanitizePath(p string) (ret key) {
if p == "" {
return
}
ret = key(path.Clean("/" + p))
if ret[0] == '/' {
ret = ret[1:]
}
return
} | [
"func",
"sanitizePath",
"(",
"p",
"string",
")",
"(",
"ret",
"key",
")",
"{",
"if",
"p",
"==",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n",
"ret",
"=",
"key",
"(",
"path",
".",
"Clean",
"(",
"\"",
"\"",
"+",
"p",
")",
")",
"\n",
"if",
"ret",
... | // An empty return path is an error. | [
"An",
"empty",
"return",
"path",
"is",
"an",
"error",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/filecache/cache.go#L86-L95 |
138,537 | anacrolix/missinggo | filecache/cache.go | pruneEmptyDirs | func pruneEmptyDirs(root string, leaf string) (err error) {
rootInfo, err := os.Stat(root)
if err != nil {
return
}
for {
var leafInfo os.FileInfo
leafInfo, err = os.Stat(leaf)
if os.IsNotExist(err) {
goto parent
}
if err != nil {
return
}
if !leafInfo.IsDir() {
return
}
if os.SameFile(... | go | func pruneEmptyDirs(root string, leaf string) (err error) {
rootInfo, err := os.Stat(root)
if err != nil {
return
}
for {
var leafInfo os.FileInfo
leafInfo, err = os.Stat(leaf)
if os.IsNotExist(err) {
goto parent
}
if err != nil {
return
}
if !leafInfo.IsDir() {
return
}
if os.SameFile(... | [
"func",
"pruneEmptyDirs",
"(",
"root",
"string",
",",
"leaf",
"string",
")",
"(",
"err",
"error",
")",
"{",
"rootInfo",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"root",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"for",
... | // Leaf is a descendent of root. | [
"Leaf",
"is",
"a",
"descendent",
"of",
"root",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/filecache/cache.go#L98-L124 |
138,538 | anacrolix/missinggo | httpfile/defaultfs.go | GetLength | func GetLength(url string) (ret int64, err error) {
return DefaultFS.GetLength(url)
} | go | func GetLength(url string) (ret int64, err error) {
return DefaultFS.GetLength(url)
} | [
"func",
"GetLength",
"(",
"url",
"string",
")",
"(",
"ret",
"int64",
",",
"err",
"error",
")",
"{",
"return",
"DefaultFS",
".",
"GetLength",
"(",
"url",
")",
"\n",
"}"
] | // Returns the length of the resource in bytes. | [
"Returns",
"the",
"length",
"of",
"the",
"resource",
"in",
"bytes",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httpfile/defaultfs.go#L12-L14 |
138,539 | anacrolix/missinggo | slices/sort.go | Sort | func Sort(sl interface{}, less interface{}) interface{} {
sorter := sorter{
sl: reflect.ValueOf(sl),
less: reflect.ValueOf(less),
}
sort.Sort(&sorter)
return sorter.sl.Interface()
} | go | func Sort(sl interface{}, less interface{}) interface{} {
sorter := sorter{
sl: reflect.ValueOf(sl),
less: reflect.ValueOf(less),
}
sort.Sort(&sorter)
return sorter.sl.Interface()
} | [
"func",
"Sort",
"(",
"sl",
"interface",
"{",
"}",
",",
"less",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"sorter",
":=",
"sorter",
"{",
"sl",
":",
"reflect",
".",
"ValueOf",
"(",
"sl",
")",
",",
"less",
":",
"reflect",
".",
"ValueOf",... | // Sorts the slice in place. Returns sl for convenience. | [
"Sorts",
"the",
"slice",
"in",
"place",
".",
"Returns",
"sl",
"for",
"convenience",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/slices/sort.go#L10-L17 |
138,540 | anacrolix/missinggo | iter/iterutils.go | DeleteIndex | func (me *seq) DeleteIndex(index int) {
me.i[index] = me.Index(me.Len() - 1)
me.i = me.i[:me.Len()-1]
} | go | func (me *seq) DeleteIndex(index int) {
me.i[index] = me.Index(me.Len() - 1)
me.i = me.i[:me.Len()-1]
} | [
"func",
"(",
"me",
"*",
"seq",
")",
"DeleteIndex",
"(",
"index",
"int",
")",
"{",
"me",
".",
"i",
"[",
"index",
"]",
"=",
"me",
".",
"Index",
"(",
"me",
".",
"Len",
"(",
")",
"-",
"1",
")",
"\n",
"me",
".",
"i",
"=",
"me",
".",
"i",
"[",
... | // Remove the nth value from the sequence. | [
"Remove",
"the",
"nth",
"value",
"from",
"the",
"sequence",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/iter/iterutils.go#L27-L30 |
138,541 | anacrolix/missinggo | event.go | C | func (me *Event) C() <-chan struct{} {
if me.ch == nil {
me.ch = make(chan struct{})
}
return me.ch
} | go | func (me *Event) C() <-chan struct{} {
if me.ch == nil {
me.ch = make(chan struct{})
}
return me.ch
} | [
"func",
"(",
"me",
"*",
"Event",
")",
"C",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"if",
"me",
".",
"ch",
"==",
"nil",
"{",
"me",
".",
"ch",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"}",
"\n",
"return",
"me",
".",
... | // Returns a chan that is closed when the event is true. | [
"Returns",
"a",
"chan",
"that",
"is",
"closed",
"when",
"the",
"event",
"is",
"true",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/event.go#L21-L26 |
138,542 | anacrolix/missinggo | addr.go | AddrPort | func AddrPort(addr net.Addr) int {
switch raw := addr.(type) {
case *net.UDPAddr:
return raw.Port
case *net.TCPAddr:
return raw.Port
default:
_, port, err := net.SplitHostPort(addr.String())
if err != nil {
panic(err)
}
i64, err := strconv.ParseInt(port, 0, 0)
if err != nil {
panic(err)
}
re... | go | func AddrPort(addr net.Addr) int {
switch raw := addr.(type) {
case *net.UDPAddr:
return raw.Port
case *net.TCPAddr:
return raw.Port
default:
_, port, err := net.SplitHostPort(addr.String())
if err != nil {
panic(err)
}
i64, err := strconv.ParseInt(port, 0, 0)
if err != nil {
panic(err)
}
re... | [
"func",
"AddrPort",
"(",
"addr",
"net",
".",
"Addr",
")",
"int",
"{",
"switch",
"raw",
":=",
"addr",
".",
"(",
"type",
")",
"{",
"case",
"*",
"net",
".",
"UDPAddr",
":",
"return",
"raw",
".",
"Port",
"\n",
"case",
"*",
"net",
".",
"TCPAddr",
":",... | // Extracts the port as an integer from an address string. | [
"Extracts",
"the",
"port",
"as",
"an",
"integer",
"from",
"an",
"address",
"string",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/addr.go#L9-L26 |
138,543 | anacrolix/missinggo | bitmap/bitmap.go | Len | func (me *Bitmap) Len() int {
if me.RB == nil {
return 0
}
return int(me.RB.GetCardinality())
} | go | func (me *Bitmap) Len() int {
if me.RB == nil {
return 0
}
return int(me.RB.GetCardinality())
} | [
"func",
"(",
"me",
"*",
"Bitmap",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"me",
".",
"RB",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"int",
"(",
"me",
".",
"RB",
".",
"GetCardinality",
"(",
")",
")",
"\n",
"}"
] | // The number of set bits in the bitmap. Also known as cardinality. | [
"The",
"number",
"of",
"set",
"bits",
"in",
"the",
"bitmap",
".",
"Also",
"known",
"as",
"cardinality",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/bitmap/bitmap.go#L31-L36 |
138,544 | anacrolix/missinggo | bitmap/bitmap.go | IterTyped | func (me Bitmap) IterTyped(f func(int) bool) bool {
if me.RB == nil {
return true
}
it := me.RB.Iterator()
for it.HasNext() {
if !f(int(it.Next())) {
return false
}
}
return true
} | go | func (me Bitmap) IterTyped(f func(int) bool) bool {
if me.RB == nil {
return true
}
it := me.RB.Iterator()
for it.HasNext() {
if !f(int(it.Next())) {
return false
}
}
return true
} | [
"func",
"(",
"me",
"Bitmap",
")",
"IterTyped",
"(",
"f",
"func",
"(",
"int",
")",
"bool",
")",
"bool",
"{",
"if",
"me",
".",
"RB",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"it",
":=",
"me",
".",
"RB",
".",
"Iterator",
"(",
")",
"\... | // Returns true if all values were traversed without early termination. | [
"Returns",
"true",
"if",
"all",
"values",
"were",
"traversed",
"without",
"early",
"termination",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/bitmap/bitmap.go#L62-L73 |
138,545 | anacrolix/missinggo | url.go | URLOpaquePath | func URLOpaquePath(u *url.URL) string {
if u.Opaque != "" {
return u.Opaque
}
return u.Path
} | go | func URLOpaquePath(u *url.URL) string {
if u.Opaque != "" {
return u.Opaque
}
return u.Path
} | [
"func",
"URLOpaquePath",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"string",
"{",
"if",
"u",
".",
"Opaque",
"!=",
"\"",
"\"",
"{",
"return",
"u",
".",
"Opaque",
"\n",
"}",
"\n",
"return",
"u",
".",
"Path",
"\n",
"}"
] | // Returns URL opaque as an unrooted path. | [
"Returns",
"URL",
"opaque",
"as",
"an",
"unrooted",
"path",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/url.go#L9-L14 |
138,546 | anacrolix/missinggo | cmd/filecache/main.go | parseContentRangeFirstByte | func parseContentRangeFirstByte(s string) int64 {
matches := regexp.MustCompile(`(\d+)-`).FindStringSubmatch(s)
if matches == nil {
return 0
}
ret, _ := strconv.ParseInt(matches[1], 0, 64)
return ret
} | go | func parseContentRangeFirstByte(s string) int64 {
matches := regexp.MustCompile(`(\d+)-`).FindStringSubmatch(s)
if matches == nil {
return 0
}
ret, _ := strconv.ParseInt(matches[1], 0, 64)
return ret
} | [
"func",
"parseContentRangeFirstByte",
"(",
"s",
"string",
")",
"int64",
"{",
"matches",
":=",
"regexp",
".",
"MustCompile",
"(",
"`(\\d+)-`",
")",
".",
"FindStringSubmatch",
"(",
"s",
")",
"\n",
"if",
"matches",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
... | // Parses out the first byte from a Content-Range header. Returns 0 if it
// isn't found, which is what is implied if there is no header. | [
"Parses",
"out",
"the",
"first",
"byte",
"from",
"a",
"Content",
"-",
"Range",
"header",
".",
"Returns",
"0",
"if",
"it",
"isn",
"t",
"found",
"which",
"is",
"what",
"is",
"implied",
"if",
"there",
"is",
"no",
"header",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/cmd/filecache/main.go#L44-L51 |
138,547 | anacrolix/missinggo | reqctx/value.go | SetRequestOnce | func (me contextValue) SetRequestOnce(r *http.Request, val interface{}) *http.Request {
expect.Nil(me.Get(r.Context()))
return r.WithContext(context.WithValue(r.Context(), me.key, val))
} | go | func (me contextValue) SetRequestOnce(r *http.Request, val interface{}) *http.Request {
expect.Nil(me.Get(r.Context()))
return r.WithContext(context.WithValue(r.Context(), me.key, val))
} | [
"func",
"(",
"me",
"contextValue",
")",
"SetRequestOnce",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"val",
"interface",
"{",
"}",
")",
"*",
"http",
".",
"Request",
"{",
"expect",
".",
"Nil",
"(",
"me",
".",
"Get",
"(",
"r",
".",
"Context",
"(",
... | // Sets the value on the Request. It must not have been already set. | [
"Sets",
"the",
"value",
"on",
"the",
"Request",
".",
"It",
"must",
"not",
"have",
"been",
"already",
"set",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/reqctx/value.go#L23-L26 |
138,548 | anacrolix/missinggo | reqctx/value.go | SetMiddleware | func (me contextValue) SetMiddleware(val interface{}) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r = me.SetRequestOnce(r, val)
h.ServeHTTP(w, r)
})
}
} | go | func (me contextValue) SetMiddleware(val interface{}) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r = me.SetRequestOnce(r, val)
h.ServeHTTP(w, r)
})
}
} | [
"func",
"(",
"me",
"contextValue",
")",
"SetMiddleware",
"(",
"val",
"interface",
"{",
"}",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"... | // Returns a middleware that sets the value in the Request's Context. | [
"Returns",
"a",
"middleware",
"that",
"sets",
"the",
"value",
"in",
"the",
"Request",
"s",
"Context",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/reqctx/value.go#L29-L36 |
138,549 | anacrolix/missinggo | futures/funcs.go | AsCompleted | func AsCompleted(fs ...*F) <-chan *F {
ret := make(chan *F, len(fs))
var wg sync.WaitGroup
for _, f := range fs {
wg.Add(1)
go func(f *F) {
defer wg.Done()
<-f.Done()
ret <- f
}(f)
}
go func() {
wg.Wait()
close(ret)
}()
return ret
} | go | func AsCompleted(fs ...*F) <-chan *F {
ret := make(chan *F, len(fs))
var wg sync.WaitGroup
for _, f := range fs {
wg.Add(1)
go func(f *F) {
defer wg.Done()
<-f.Done()
ret <- f
}(f)
}
go func() {
wg.Wait()
close(ret)
}()
return ret
} | [
"func",
"AsCompleted",
"(",
"fs",
"...",
"*",
"F",
")",
"<-",
"chan",
"*",
"F",
"{",
"ret",
":=",
"make",
"(",
"chan",
"*",
"F",
",",
"len",
"(",
"fs",
")",
")",
"\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"_",
",",
"f",
":=",
... | // Sends each future as it completes on the returned chan, closing it when
// everything has been sent. | [
"Sends",
"each",
"future",
"as",
"it",
"completes",
"on",
"the",
"returned",
"chan",
"closing",
"it",
"when",
"everything",
"has",
"been",
"sent",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/futures/funcs.go#L15-L31 |
138,550 | anacrolix/missinggo | httptoo/request.go | RequestIsForLocalhost | func RequestIsForLocalhost(r *http.Request) bool {
hostHost := missinggo.SplitHostMaybePort(r.Host).Host
if ip := net.ParseIP(hostHost); ip != nil {
return ip.IsLoopback()
}
return hostHost == "localhost"
} | go | func RequestIsForLocalhost(r *http.Request) bool {
hostHost := missinggo.SplitHostMaybePort(r.Host).Host
if ip := net.ParseIP(hostHost); ip != nil {
return ip.IsLoopback()
}
return hostHost == "localhost"
} | [
"func",
"RequestIsForLocalhost",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"hostHost",
":=",
"missinggo",
".",
"SplitHostMaybePort",
"(",
"r",
".",
"Host",
")",
".",
"Host",
"\n",
"if",
"ip",
":=",
"net",
".",
"ParseIP",
"(",
"hostHost",
... | // Request is intended for localhost, either with a localhost name, or
// loopback IP. | [
"Request",
"is",
"intended",
"for",
"localhost",
"either",
"with",
"a",
"localhost",
"name",
"or",
"loopback",
"IP",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/request.go#L12-L18 |
138,551 | anacrolix/missinggo | httptoo/request.go | RequestIsFromLocalhost | func RequestIsFromLocalhost(r *http.Request) bool {
return net.ParseIP(missinggo.SplitHostMaybePort(r.RemoteAddr).Host).IsLoopback()
} | go | func RequestIsFromLocalhost(r *http.Request) bool {
return net.ParseIP(missinggo.SplitHostMaybePort(r.RemoteAddr).Host).IsLoopback()
} | [
"func",
"RequestIsFromLocalhost",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"return",
"net",
".",
"ParseIP",
"(",
"missinggo",
".",
"SplitHostMaybePort",
"(",
"r",
".",
"RemoteAddr",
")",
".",
"Host",
")",
".",
"IsLoopback",
"(",
")",
"\n"... | // Request originated from a loopback IP. | [
"Request",
"originated",
"from",
"a",
"loopback",
"IP",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/request.go#L21-L23 |
138,552 | anacrolix/missinggo | chans/drain.go | Drain | func Drain(ch interface{}) {
chValue := reflect.ValueOf(ch)
for {
_, ok := chValue.Recv()
if !ok {
break
}
}
} | go | func Drain(ch interface{}) {
chValue := reflect.ValueOf(ch)
for {
_, ok := chValue.Recv()
if !ok {
break
}
}
} | [
"func",
"Drain",
"(",
"ch",
"interface",
"{",
"}",
")",
"{",
"chValue",
":=",
"reflect",
".",
"ValueOf",
"(",
"ch",
")",
"\n",
"for",
"{",
"_",
",",
"ok",
":=",
"chValue",
".",
"Recv",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"break",
"\n",
"}",
... | // Receives from any channel until it's closed. | [
"Receives",
"from",
"any",
"channel",
"until",
"it",
"s",
"closed",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/chans/drain.go#L8-L16 |
138,553 | anacrolix/missinggo | httpfile/misc.go | instanceLength | func instanceLength(r *http.Response) (l int64, err error) {
switch r.StatusCode {
case http.StatusOK:
l, err = strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
return
case http.StatusPartialContent:
cr, parseOk := httptoo.ParseBytesContentRange(r.Header.Get("Content-Range"))
l = cr.Length
if !pars... | go | func instanceLength(r *http.Response) (l int64, err error) {
switch r.StatusCode {
case http.StatusOK:
l, err = strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
return
case http.StatusPartialContent:
cr, parseOk := httptoo.ParseBytesContentRange(r.Header.Get("Content-Range"))
l = cr.Length
if !pars... | [
"func",
"instanceLength",
"(",
"r",
"*",
"http",
".",
"Response",
")",
"(",
"l",
"int64",
",",
"err",
"error",
")",
"{",
"switch",
"r",
".",
"StatusCode",
"{",
"case",
"http",
".",
"StatusOK",
":",
"l",
",",
"err",
"=",
"strconv",
".",
"ParseInt",
... | // ok is false if the response just doesn't specify anything we handle. | [
"ok",
"is",
"false",
"if",
"the",
"response",
"just",
"doesn",
"t",
"specify",
"anything",
"we",
"handle",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httpfile/misc.go#L17-L33 |
138,554 | anacrolix/missinggo | httptoo/url.go | RequestedURL | func RequestedURL(r *http.Request) (ret *url.URL) {
ret = CopyURL(r.URL)
ret.Host = r.Host
ret.Scheme = OriginatingProtocol(r)
return
} | go | func RequestedURL(r *http.Request) (ret *url.URL) {
ret = CopyURL(r.URL)
ret.Host = r.Host
ret.Scheme = OriginatingProtocol(r)
return
} | [
"func",
"RequestedURL",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"ret",
"*",
"url",
".",
"URL",
")",
"{",
"ret",
"=",
"CopyURL",
"(",
"r",
".",
"URL",
")",
"\n",
"ret",
".",
"Host",
"=",
"r",
".",
"Host",
"\n",
"ret",
".",
"Scheme",
"... | // Reconstructs the URL that would have produced the given Request.
// Request.URLs are not fully populated in http.Server handlers. | [
"Reconstructs",
"the",
"URL",
"that",
"would",
"have",
"produced",
"the",
"given",
"Request",
".",
"Request",
".",
"URLs",
"are",
"not",
"fully",
"populated",
"in",
"http",
".",
"Server",
"handlers",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/url.go#L23-L28 |
138,555 | anacrolix/missinggo | httptoo/httptoo.go | NukeCookie | func NukeCookie(w http.ResponseWriter, r *http.Request, name, path string) {
parts := strings.Split(missinggo.SplitHostMaybePort(r.Host).Host, ".")
for i := range iter.N(len(parts) + 1) { // Include the empty domain.
http.SetCookie(w, &http.Cookie{
Name: name,
MaxAge: -1,
Path: path,
Domain: strings... | go | func NukeCookie(w http.ResponseWriter, r *http.Request, name, path string) {
parts := strings.Split(missinggo.SplitHostMaybePort(r.Host).Host, ".")
for i := range iter.N(len(parts) + 1) { // Include the empty domain.
http.SetCookie(w, &http.Cookie{
Name: name,
MaxAge: -1,
Path: path,
Domain: strings... | [
"func",
"NukeCookie",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"name",
",",
"path",
"string",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"missinggo",
".",
"SplitHostMaybePort",
"(",
"r",
".",
"Hos... | // Clears the named cookie for every domain that leads to the current one. | [
"Clears",
"the",
"named",
"cookie",
"for",
"every",
"domain",
"that",
"leads",
"to",
"the",
"current",
"one",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/httptoo.go#L24-L34 |
138,556 | anacrolix/missinggo | httptoo/inproc_roundtrip.go | CloseNotify | func (me *responseWriter) CloseNotify() <-chan bool {
ret := make(chan bool, 1)
go func() {
<-me.bodyClosed.C()
ret <- true
}()
return ret
} | go | func (me *responseWriter) CloseNotify() <-chan bool {
ret := make(chan bool, 1)
go func() {
<-me.bodyClosed.C()
ret <- true
}()
return ret
} | [
"func",
"(",
"me",
"*",
"responseWriter",
")",
"CloseNotify",
"(",
")",
"<-",
"chan",
"bool",
"{",
"ret",
":=",
"make",
"(",
"chan",
"bool",
",",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"<-",
"me",
".",
"bodyClosed",
".",
"C",
"(",
")",
"\... | // Use Request.Context.Done instead. | [
"Use",
"Request",
".",
"Context",
".",
"Done",
"instead",
"."
] | 3d85a149c8127dad7dd81d6d92df99407e67e874 | https://github.com/anacrolix/missinggo/blob/3d85a149c8127dad7dd81d6d92df99407e67e874/httptoo/inproc_roundtrip.go#L27-L34 |
138,557 | morikuni/aec | sgr.go | NewRGB3Bit | func NewRGB3Bit(r, g, b uint8) RGB3Bit {
return RGB3Bit((r >> 7) | ((g >> 6) & 0x2) | ((b >> 5) & 0x4))
} | go | func NewRGB3Bit(r, g, b uint8) RGB3Bit {
return RGB3Bit((r >> 7) | ((g >> 6) & 0x2) | ((b >> 5) & 0x4))
} | [
"func",
"NewRGB3Bit",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"RGB3Bit",
"{",
"return",
"RGB3Bit",
"(",
"(",
"r",
">>",
"7",
")",
"|",
"(",
"(",
"g",
">>",
"6",
")",
"&",
"0x2",
")",
"|",
"(",
"(",
"b",
">>",
"5",
")",
"&",
"0x4",
")"... | // NewRGB3Bit create a RGB3Bit from given RGB. | [
"NewRGB3Bit",
"create",
"a",
"RGB3Bit",
"from",
"given",
"RGB",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/sgr.go#L18-L20 |
138,558 | morikuni/aec | sgr.go | NewRGB8Bit | func NewRGB8Bit(r, g, b uint8) RGB8Bit {
return RGB8Bit(16 + 36*(r/43) + 6*(g/43) + b/43)
} | go | func NewRGB8Bit(r, g, b uint8) RGB8Bit {
return RGB8Bit(16 + 36*(r/43) + 6*(g/43) + b/43)
} | [
"func",
"NewRGB8Bit",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"RGB8Bit",
"{",
"return",
"RGB8Bit",
"(",
"16",
"+",
"36",
"*",
"(",
"r",
"/",
"43",
")",
"+",
"6",
"*",
"(",
"g",
"/",
"43",
")",
"+",
"b",
"/",
"43",
")",
"\n",
"}"
] | // NewRGB8Bit create a RGB8Bit from given RGB. | [
"NewRGB8Bit",
"create",
"a",
"RGB8Bit",
"from",
"given",
"RGB",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/sgr.go#L23-L25 |
138,559 | morikuni/aec | sgr.go | FullColorB | func FullColorB(r, g, b uint8) ANSI {
return newAnsi(fmt.Sprintf(esc+"48;2;%d;%d;%dm", r, g, b))
} | go | func FullColorB(r, g, b uint8) ANSI {
return newAnsi(fmt.Sprintf(esc+"48;2;%d;%d;%dm", r, g, b))
} | [
"func",
"FullColorB",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"ANSI",
"{",
"return",
"newAnsi",
"(",
"fmt",
".",
"Sprintf",
"(",
"esc",
"+",
"\"",
"\"",
",",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // FullColorB set the foreground color of text. | [
"FullColorB",
"set",
"the",
"foreground",
"color",
"of",
"text",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/sgr.go#L53-L55 |
138,560 | morikuni/aec | ansi.go | Apply | func Apply(s string, ansi ...ANSI) string {
if len(ansi) == 0 {
return s
}
return concat(ansi).Apply(s)
} | go | func Apply(s string, ansi ...ANSI) string {
if len(ansi) == 0 {
return s
}
return concat(ansi).Apply(s)
} | [
"func",
"Apply",
"(",
"s",
"string",
",",
"ansi",
"...",
"ANSI",
")",
"string",
"{",
"if",
"len",
"(",
"ansi",
")",
"==",
"0",
"{",
"return",
"s",
"\n",
"}",
"\n",
"return",
"concat",
"(",
"ansi",
")",
".",
"Apply",
"(",
"s",
")",
"\n",
"}"
] | // Apply wraps given string in ANSIs. | [
"Apply",
"wraps",
"given",
"string",
"in",
"ANSIs",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/ansi.go#L46-L51 |
138,561 | morikuni/aec | builder.go | With | func (builder *Builder) With(a ...ANSI) *Builder {
return NewBuilder(builder.ANSI.With(a...))
} | go | func (builder *Builder) With(a ...ANSI) *Builder {
return NewBuilder(builder.ANSI.With(a...))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"With",
"(",
"a",
"...",
"ANSI",
")",
"*",
"Builder",
"{",
"return",
"NewBuilder",
"(",
"builder",
".",
"ANSI",
".",
"With",
"(",
"a",
"...",
")",
")",
"\n",
"}"
] | // With is a syntax for With. | [
"With",
"is",
"a",
"syntax",
"for",
"With",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L17-L19 |
138,562 | morikuni/aec | builder.go | Up | func (builder *Builder) Up(n uint) *Builder {
return builder.With(Up(n))
} | go | func (builder *Builder) Up(n uint) *Builder {
return builder.With(Up(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Up",
"(",
"n",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Up",
"(",
"n",
")",
")",
"\n",
"}"
] | // Up is a syntax for Up. | [
"Up",
"is",
"a",
"syntax",
"for",
"Up",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L22-L24 |
138,563 | morikuni/aec | builder.go | Down | func (builder *Builder) Down(n uint) *Builder {
return builder.With(Down(n))
} | go | func (builder *Builder) Down(n uint) *Builder {
return builder.With(Down(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Down",
"(",
"n",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Down",
"(",
"n",
")",
")",
"\n",
"}"
] | // Down is a syntax for Down. | [
"Down",
"is",
"a",
"syntax",
"for",
"Down",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L27-L29 |
138,564 | morikuni/aec | builder.go | Right | func (builder *Builder) Right(n uint) *Builder {
return builder.With(Right(n))
} | go | func (builder *Builder) Right(n uint) *Builder {
return builder.With(Right(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Right",
"(",
"n",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Right",
"(",
"n",
")",
")",
"\n",
"}"
] | // Right is a syntax for Right. | [
"Right",
"is",
"a",
"syntax",
"for",
"Right",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L32-L34 |
138,565 | morikuni/aec | builder.go | Left | func (builder *Builder) Left(n uint) *Builder {
return builder.With(Left(n))
} | go | func (builder *Builder) Left(n uint) *Builder {
return builder.With(Left(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Left",
"(",
"n",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Left",
"(",
"n",
")",
")",
"\n",
"}"
] | // Left is a syntax for Left. | [
"Left",
"is",
"a",
"syntax",
"for",
"Left",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L37-L39 |
138,566 | morikuni/aec | builder.go | NextLine | func (builder *Builder) NextLine(n uint) *Builder {
return builder.With(NextLine(n))
} | go | func (builder *Builder) NextLine(n uint) *Builder {
return builder.With(NextLine(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"NextLine",
"(",
"n",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"NextLine",
"(",
"n",
")",
")",
"\n",
"}"
] | // NextLine is a syntax for NextLine. | [
"NextLine",
"is",
"a",
"syntax",
"for",
"NextLine",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L42-L44 |
138,567 | morikuni/aec | builder.go | PreviousLine | func (builder *Builder) PreviousLine(n uint) *Builder {
return builder.With(PreviousLine(n))
} | go | func (builder *Builder) PreviousLine(n uint) *Builder {
return builder.With(PreviousLine(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"PreviousLine",
"(",
"n",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"PreviousLine",
"(",
"n",
")",
")",
"\n",
"}"
] | // PreviousLine is a syntax for PreviousLine. | [
"PreviousLine",
"is",
"a",
"syntax",
"for",
"PreviousLine",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L47-L49 |
138,568 | morikuni/aec | builder.go | Column | func (builder *Builder) Column(col uint) *Builder {
return builder.With(Column(col))
} | go | func (builder *Builder) Column(col uint) *Builder {
return builder.With(Column(col))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Column",
"(",
"col",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Column",
"(",
"col",
")",
")",
"\n",
"}"
] | // Column is a syntax for Column. | [
"Column",
"is",
"a",
"syntax",
"for",
"Column",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L52-L54 |
138,569 | morikuni/aec | builder.go | Position | func (builder *Builder) Position(row, col uint) *Builder {
return builder.With(Position(row, col))
} | go | func (builder *Builder) Position(row, col uint) *Builder {
return builder.With(Position(row, col))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Position",
"(",
"row",
",",
"col",
"uint",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Position",
"(",
"row",
",",
"col",
")",
")",
"\n",
"}"
] | // Position is a syntax for Position. | [
"Position",
"is",
"a",
"syntax",
"for",
"Position",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L57-L59 |
138,570 | morikuni/aec | builder.go | EraseDisplay | func (builder *Builder) EraseDisplay(m EraseMode) *Builder {
return builder.With(EraseDisplay(m))
} | go | func (builder *Builder) EraseDisplay(m EraseMode) *Builder {
return builder.With(EraseDisplay(m))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"EraseDisplay",
"(",
"m",
"EraseMode",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"EraseDisplay",
"(",
"m",
")",
")",
"\n",
"}"
] | // EraseDisplay is a syntax for EraseDisplay. | [
"EraseDisplay",
"is",
"a",
"syntax",
"for",
"EraseDisplay",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L62-L64 |
138,571 | morikuni/aec | builder.go | EraseLine | func (builder *Builder) EraseLine(m EraseMode) *Builder {
return builder.With(EraseLine(m))
} | go | func (builder *Builder) EraseLine(m EraseMode) *Builder {
return builder.With(EraseLine(m))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"EraseLine",
"(",
"m",
"EraseMode",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"EraseLine",
"(",
"m",
")",
")",
"\n",
"}"
] | // EraseLine is a syntax for EraseLine. | [
"EraseLine",
"is",
"a",
"syntax",
"for",
"EraseLine",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L67-L69 |
138,572 | morikuni/aec | builder.go | ScrollUp | func (builder *Builder) ScrollUp(n int) *Builder {
return builder.With(ScrollUp(n))
} | go | func (builder *Builder) ScrollUp(n int) *Builder {
return builder.With(ScrollUp(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"ScrollUp",
"(",
"n",
"int",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"ScrollUp",
"(",
"n",
")",
")",
"\n",
"}"
] | // ScrollUp is a syntax for ScrollUp. | [
"ScrollUp",
"is",
"a",
"syntax",
"for",
"ScrollUp",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L72-L74 |
138,573 | morikuni/aec | builder.go | ScrollDown | func (builder *Builder) ScrollDown(n int) *Builder {
return builder.With(ScrollDown(n))
} | go | func (builder *Builder) ScrollDown(n int) *Builder {
return builder.With(ScrollDown(n))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"ScrollDown",
"(",
"n",
"int",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"ScrollDown",
"(",
"n",
")",
")",
"\n",
"}"
] | // ScrollDown is a syntax for ScrollDown. | [
"ScrollDown",
"is",
"a",
"syntax",
"for",
"ScrollDown",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L77-L79 |
138,574 | morikuni/aec | builder.go | Color3BitF | func (builder *Builder) Color3BitF(c RGB3Bit) *Builder {
return builder.With(Color3BitF(c))
} | go | func (builder *Builder) Color3BitF(c RGB3Bit) *Builder {
return builder.With(Color3BitF(c))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Color3BitF",
"(",
"c",
"RGB3Bit",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Color3BitF",
"(",
"c",
")",
")",
"\n",
"}"
] | // Color3BitF is a syntax for Color3BitF. | [
"Color3BitF",
"is",
"a",
"syntax",
"for",
"Color3BitF",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L337-L339 |
138,575 | morikuni/aec | builder.go | Color3BitB | func (builder *Builder) Color3BitB(c RGB3Bit) *Builder {
return builder.With(Color3BitB(c))
} | go | func (builder *Builder) Color3BitB(c RGB3Bit) *Builder {
return builder.With(Color3BitB(c))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Color3BitB",
"(",
"c",
"RGB3Bit",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Color3BitB",
"(",
"c",
")",
")",
"\n",
"}"
] | // Color3BitB is a syntax for Color3BitB. | [
"Color3BitB",
"is",
"a",
"syntax",
"for",
"Color3BitB",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L342-L344 |
138,576 | morikuni/aec | builder.go | Color8BitF | func (builder *Builder) Color8BitF(c RGB8Bit) *Builder {
return builder.With(Color8BitF(c))
} | go | func (builder *Builder) Color8BitF(c RGB8Bit) *Builder {
return builder.With(Color8BitF(c))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Color8BitF",
"(",
"c",
"RGB8Bit",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Color8BitF",
"(",
"c",
")",
")",
"\n",
"}"
] | // Color8BitF is a syntax for Color8BitF. | [
"Color8BitF",
"is",
"a",
"syntax",
"for",
"Color8BitF",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L347-L349 |
138,577 | morikuni/aec | builder.go | Color8BitB | func (builder *Builder) Color8BitB(c RGB8Bit) *Builder {
return builder.With(Color8BitB(c))
} | go | func (builder *Builder) Color8BitB(c RGB8Bit) *Builder {
return builder.With(Color8BitB(c))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"Color8BitB",
"(",
"c",
"RGB8Bit",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"Color8BitB",
"(",
"c",
")",
")",
"\n",
"}"
] | // Color8BitB is a syntax for Color8BitB. | [
"Color8BitB",
"is",
"a",
"syntax",
"for",
"Color8BitB",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L352-L354 |
138,578 | morikuni/aec | builder.go | FullColorF | func (builder *Builder) FullColorF(r, g, b uint8) *Builder {
return builder.With(FullColorF(r, g, b))
} | go | func (builder *Builder) FullColorF(r, g, b uint8) *Builder {
return builder.With(FullColorF(r, g, b))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"FullColorF",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"FullColorF",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // FullColorF is a syntax for FullColorF. | [
"FullColorF",
"is",
"a",
"syntax",
"for",
"FullColorF",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L357-L359 |
138,579 | morikuni/aec | builder.go | FullColorB | func (builder *Builder) FullColorB(r, g, b uint8) *Builder {
return builder.With(FullColorB(r, g, b))
} | go | func (builder *Builder) FullColorB(r, g, b uint8) *Builder {
return builder.With(FullColorB(r, g, b))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"FullColorB",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"With",
"(",
"FullColorB",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // FullColorB is a syntax for FullColorB. | [
"FullColorB",
"is",
"a",
"syntax",
"for",
"FullColorB",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L362-L364 |
138,580 | morikuni/aec | builder.go | RGB3BitF | func (builder *Builder) RGB3BitF(r, g, b uint8) *Builder {
return builder.Color3BitF(NewRGB3Bit(r, g, b))
} | go | func (builder *Builder) RGB3BitF(r, g, b uint8) *Builder {
return builder.Color3BitF(NewRGB3Bit(r, g, b))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"RGB3BitF",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"Color3BitF",
"(",
"NewRGB3Bit",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // RGB3BitF is a syntax for Color3BitF with NewRGB3Bit. | [
"RGB3BitF",
"is",
"a",
"syntax",
"for",
"Color3BitF",
"with",
"NewRGB3Bit",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L367-L369 |
138,581 | morikuni/aec | builder.go | RGB3BitB | func (builder *Builder) RGB3BitB(r, g, b uint8) *Builder {
return builder.Color3BitB(NewRGB3Bit(r, g, b))
} | go | func (builder *Builder) RGB3BitB(r, g, b uint8) *Builder {
return builder.Color3BitB(NewRGB3Bit(r, g, b))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"RGB3BitB",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"Color3BitB",
"(",
"NewRGB3Bit",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // RGB3BitB is a syntax for Color3BitB with NewRGB3Bit. | [
"RGB3BitB",
"is",
"a",
"syntax",
"for",
"Color3BitB",
"with",
"NewRGB3Bit",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L372-L374 |
138,582 | morikuni/aec | builder.go | RGB8BitF | func (builder *Builder) RGB8BitF(r, g, b uint8) *Builder {
return builder.Color8BitF(NewRGB8Bit(r, g, b))
} | go | func (builder *Builder) RGB8BitF(r, g, b uint8) *Builder {
return builder.Color8BitF(NewRGB8Bit(r, g, b))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"RGB8BitF",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"Color8BitF",
"(",
"NewRGB8Bit",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // RGB8BitF is a syntax for Color8BitF with NewRGB8Bit. | [
"RGB8BitF",
"is",
"a",
"syntax",
"for",
"Color8BitF",
"with",
"NewRGB8Bit",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L377-L379 |
138,583 | morikuni/aec | builder.go | RGB8BitB | func (builder *Builder) RGB8BitB(r, g, b uint8) *Builder {
return builder.Color8BitB(NewRGB8Bit(r, g, b))
} | go | func (builder *Builder) RGB8BitB(r, g, b uint8) *Builder {
return builder.Color8BitB(NewRGB8Bit(r, g, b))
} | [
"func",
"(",
"builder",
"*",
"Builder",
")",
"RGB8BitB",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"*",
"Builder",
"{",
"return",
"builder",
".",
"Color8BitB",
"(",
"NewRGB8Bit",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // RGB8BitB is a syntax for Color8BitB with NewRGB8Bit. | [
"RGB8BitB",
"is",
"a",
"syntax",
"for",
"Color8BitB",
"with",
"NewRGB8Bit",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/builder.go#L382-L384 |
138,584 | morikuni/aec | aec.go | Up | func Up(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dA", n))
} | go | func Up(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dA", n))
} | [
"func",
"Up",
"(",
"n",
"uint",
")",
"ANSI",
"{",
"if",
"n",
"==",
"0",
"{",
"return",
"empty",
"\n",
"}",
"\n",
"return",
"newAnsi",
"(",
"fmt",
".",
"Sprintf",
"(",
"esc",
"+",
"\"",
"\"",
",",
"n",
")",
")",
"\n",
"}"
] | // Up moves up the cursor. | [
"Up",
"moves",
"up",
"the",
"cursor",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/aec.go#L38-L43 |
138,585 | morikuni/aec | aec.go | Position | func Position(row, col uint) ANSI {
return newAnsi(fmt.Sprintf(esc+"%d;%dH", row, col))
} | go | func Position(row, col uint) ANSI {
return newAnsi(fmt.Sprintf(esc+"%d;%dH", row, col))
} | [
"func",
"Position",
"(",
"row",
",",
"col",
"uint",
")",
"ANSI",
"{",
"return",
"newAnsi",
"(",
"fmt",
".",
"Sprintf",
"(",
"esc",
"+",
"\"",
"\"",
",",
"row",
",",
"col",
")",
")",
"\n",
"}"
] | // Position set the cursor position to a given absolute position. | [
"Position",
"set",
"the",
"cursor",
"position",
"to",
"a",
"given",
"absolute",
"position",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/aec.go#L91-L93 |
138,586 | morikuni/aec | aec.go | ScrollDown | func ScrollDown(n int) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dT", n))
} | go | func ScrollDown(n int) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dT", n))
} | [
"func",
"ScrollDown",
"(",
"n",
"int",
")",
"ANSI",
"{",
"if",
"n",
"==",
"0",
"{",
"return",
"empty",
"\n",
"}",
"\n",
"return",
"newAnsi",
"(",
"fmt",
".",
"Sprintf",
"(",
"esc",
"+",
"\"",
"\"",
",",
"n",
")",
")",
"\n",
"}"
] | // ScrollDown scrolls down the page. | [
"ScrollDown",
"scrolls",
"down",
"the",
"page",
"."
] | 39771216ff4c63d11f5e604076f9c45e8be1067b | https://github.com/morikuni/aec/blob/39771216ff4c63d11f5e604076f9c45e8be1067b/aec.go#L114-L119 |
138,587 | dgryski/go-minhash | bottomk.go | NewBottomK | func NewBottomK(h Hash64, k int) *BottomK {
return &BottomK{
size: k,
h: h,
minimums: &intHeap{},
}
} | go | func NewBottomK(h Hash64, k int) *BottomK {
return &BottomK{
size: k,
h: h,
minimums: &intHeap{},
}
} | [
"func",
"NewBottomK",
"(",
"h",
"Hash64",
",",
"k",
"int",
")",
"*",
"BottomK",
"{",
"return",
"&",
"BottomK",
"{",
"size",
":",
"k",
",",
"h",
":",
"h",
",",
"minimums",
":",
"&",
"intHeap",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewBottomK returns a new BottomK implementation. | [
"NewBottomK",
"returns",
"a",
"new",
"BottomK",
"implementation",
"."
] | ad340ca0307647c228c227cb844358a2c94d7f80 | https://github.com/dgryski/go-minhash/blob/ad340ca0307647c228c227cb844358a2c94d7f80/bottomk.go#L56-L62 |
138,588 | dgryski/go-minhash | bottomk.go | Signature | func (m *BottomK) Signature() []uint64 {
mins := make(intHeap, len(*m.minimums))
copy(mins, *m.minimums)
sort.Sort(mins)
return mins
} | go | func (m *BottomK) Signature() []uint64 {
mins := make(intHeap, len(*m.minimums))
copy(mins, *m.minimums)
sort.Sort(mins)
return mins
} | [
"func",
"(",
"m",
"*",
"BottomK",
")",
"Signature",
"(",
")",
"[",
"]",
"uint64",
"{",
"mins",
":=",
"make",
"(",
"intHeap",
",",
"len",
"(",
"*",
"m",
".",
"minimums",
")",
")",
"\n",
"copy",
"(",
"mins",
",",
"*",
"m",
".",
"minimums",
")",
... | // Signature returns a signature for the set. | [
"Signature",
"returns",
"a",
"signature",
"for",
"the",
"set",
"."
] | ad340ca0307647c228c227cb844358a2c94d7f80 | https://github.com/dgryski/go-minhash/blob/ad340ca0307647c228c227cb844358a2c94d7f80/bottomk.go#L107-L112 |
138,589 | dgryski/go-minhash | minwise.go | NewMinWise | func NewMinWise(h1, h2 Hash64, size int) *MinWise {
minimums := make([]uint64, size)
for i := range minimums {
minimums[i] = math.MaxUint64
}
return &MinWise{
h1: h1,
h2: h2,
minimums: minimums,
}
} | go | func NewMinWise(h1, h2 Hash64, size int) *MinWise {
minimums := make([]uint64, size)
for i := range minimums {
minimums[i] = math.MaxUint64
}
return &MinWise{
h1: h1,
h2: h2,
minimums: minimums,
}
} | [
"func",
"NewMinWise",
"(",
"h1",
",",
"h2",
"Hash64",
",",
"size",
"int",
")",
"*",
"MinWise",
"{",
"minimums",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"size",
")",
"\n",
"for",
"i",
":=",
"range",
"minimums",
"{",
"minimums",
"[",
"i",
"]",
... | // NewMinWise returns a new MinWise Hashing implementation | [
"NewMinWise",
"returns",
"a",
"new",
"MinWise",
"Hashing",
"implementation"
] | ad340ca0307647c228c227cb844358a2c94d7f80 | https://github.com/dgryski/go-minhash/blob/ad340ca0307647c228c227cb844358a2c94d7f80/minwise.go#L15-L27 |
138,590 | dgryski/go-minhash | minwise.go | NewMinWiseFromSignatures | func NewMinWiseFromSignatures(h1, h2 Hash64, signatures []uint64) *MinWise {
minimums := make([]uint64, len(signatures))
copy(minimums, signatures)
return &MinWise{
h1: h1,
h2: h2,
minimums: signatures,
}
} | go | func NewMinWiseFromSignatures(h1, h2 Hash64, signatures []uint64) *MinWise {
minimums := make([]uint64, len(signatures))
copy(minimums, signatures)
return &MinWise{
h1: h1,
h2: h2,
minimums: signatures,
}
} | [
"func",
"NewMinWiseFromSignatures",
"(",
"h1",
",",
"h2",
"Hash64",
",",
"signatures",
"[",
"]",
"uint64",
")",
"*",
"MinWise",
"{",
"minimums",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"len",
"(",
"signatures",
")",
")",
"\n",
"copy",
"(",
"minimum... | // NewMinWiseFromSignatures returns a new MinWise Hashing implementation
// using a user-provided set of signatures | [
"NewMinWiseFromSignatures",
"returns",
"a",
"new",
"MinWise",
"Hashing",
"implementation",
"using",
"a",
"user",
"-",
"provided",
"set",
"of",
"signatures"
] | ad340ca0307647c228c227cb844358a2c94d7f80 | https://github.com/dgryski/go-minhash/blob/ad340ca0307647c228c227cb844358a2c94d7f80/minwise.go#L31-L40 |
138,591 | dgryski/go-minhash | minwise.go | SignatureBbit | func (m *MinWise) SignatureBbit(b uint) []uint64 {
var sig []uint64 // full signature
var w uint64 // current word
bits := uint(64) // bits free in current word
mask := uint64(1<<b) - 1
for _, v := range m.minimums {
if bits >= b {
w <<= b
w |= v & mask
bits -= b
} else {
sig = append(sig, w... | go | func (m *MinWise) SignatureBbit(b uint) []uint64 {
var sig []uint64 // full signature
var w uint64 // current word
bits := uint(64) // bits free in current word
mask := uint64(1<<b) - 1
for _, v := range m.minimums {
if bits >= b {
w <<= b
w |= v & mask
bits -= b
} else {
sig = append(sig, w... | [
"func",
"(",
"m",
"*",
"MinWise",
")",
"SignatureBbit",
"(",
"b",
"uint",
")",
"[",
"]",
"uint64",
"{",
"var",
"sig",
"[",
"]",
"uint64",
"// full signature",
"\n",
"var",
"w",
"uint64",
"// current word",
"\n",
"bits",
":=",
"uint",
"(",
"64",
")",
... | // SignatureBbit returns a b-bit reduction of the signature. This will result in unused bits at the high-end of the words if b does not divide 64 evenly. | [
"SignatureBbit",
"returns",
"a",
"b",
"-",
"bit",
"reduction",
"of",
"the",
"signature",
".",
"This",
"will",
"result",
"in",
"unused",
"bits",
"at",
"the",
"high",
"-",
"end",
"of",
"the",
"words",
"if",
"b",
"does",
"not",
"divide",
"64",
"evenly",
"... | ad340ca0307647c228c227cb844358a2c94d7f80 | https://github.com/dgryski/go-minhash/blob/ad340ca0307647c228c227cb844358a2c94d7f80/minwise.go#L105-L130 |
138,592 | dgryski/go-minhash | minwise.go | SimilarityBbit | func SimilarityBbit(sig1, sig2 []uint64, b uint) float64 {
if len(sig1) != len(sig2) {
panic("signature size mismatch")
}
intersect := 0
count := 0
mask := uint64(1<<b) - 1
for i := range sig1 {
w1 := sig1[i]
w2 := sig2[i]
bits := uint(64)
for bits >= b {
v1 := (w1 & mask)
v2 := (w2 & mask)
... | go | func SimilarityBbit(sig1, sig2 []uint64, b uint) float64 {
if len(sig1) != len(sig2) {
panic("signature size mismatch")
}
intersect := 0
count := 0
mask := uint64(1<<b) - 1
for i := range sig1 {
w1 := sig1[i]
w2 := sig2[i]
bits := uint(64)
for bits >= b {
v1 := (w1 & mask)
v2 := (w2 & mask)
... | [
"func",
"SimilarityBbit",
"(",
"sig1",
",",
"sig2",
"[",
"]",
"uint64",
",",
"b",
"uint",
")",
"float64",
"{",
"if",
"len",
"(",
"sig1",
")",
"!=",
"len",
"(",
"sig2",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"intersect",
":=",... | // SimilarityBbit computes an estimate for the similarity between two b-bit signatures | [
"SimilarityBbit",
"computes",
"an",
"estimate",
"for",
"the",
"similarity",
"between",
"two",
"b",
"-",
"bit",
"signatures"
] | ad340ca0307647c228c227cb844358a2c94d7f80 | https://github.com/dgryski/go-minhash/blob/ad340ca0307647c228c227cb844358a2c94d7f80/minwise.go#L133-L166 |
138,593 | pilosa/pdk | mapper.go | NewCollapsingMapper | func NewCollapsingMapper() *CollapsingMapper {
return &CollapsingMapper{
Translator: NewMapTranslator(),
ColTranslator: NewNexterFieldTranslator(),
Framer: &DashField{},
Nexter: NewNexter(),
}
} | go | func NewCollapsingMapper() *CollapsingMapper {
return &CollapsingMapper{
Translator: NewMapTranslator(),
ColTranslator: NewNexterFieldTranslator(),
Framer: &DashField{},
Nexter: NewNexter(),
}
} | [
"func",
"NewCollapsingMapper",
"(",
")",
"*",
"CollapsingMapper",
"{",
"return",
"&",
"CollapsingMapper",
"{",
"Translator",
":",
"NewMapTranslator",
"(",
")",
",",
"ColTranslator",
":",
"NewNexterFieldTranslator",
"(",
")",
",",
"Framer",
":",
"&",
"DashField",
... | // NewCollapsingMapper returns a CollapsingMapper with basic implementations of
// its components. In order to track mapping of Pilosa columns to records, you
// must replace the ColTranslator with something other than a
// NexterFieldTranslator which just allocates ids and does not store a mapping. | [
"NewCollapsingMapper",
"returns",
"a",
"CollapsingMapper",
"with",
"basic",
"implementations",
"of",
"its",
"components",
".",
"In",
"order",
"to",
"track",
"mapping",
"of",
"Pilosa",
"columns",
"to",
"records",
"you",
"must",
"replace",
"the",
"ColTranslator",
"w... | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/mapper.go#L56-L63 |
138,594 | pilosa/pdk | mapper.go | Map | func (m *CollapsingMapper) Map(e *Entity) (PilosaRecord, error) {
pr := PilosaRecord{}
if m.ColTranslator != nil {
col, err := m.ColTranslator.GetID(string(e.Subject))
if err != nil {
return pr, errors.Wrap(err, "getting column id from subject")
}
pr.Col = col
} else if m.Nexter != nil {
pr.Col = m.Next... | go | func (m *CollapsingMapper) Map(e *Entity) (PilosaRecord, error) {
pr := PilosaRecord{}
if m.ColTranslator != nil {
col, err := m.ColTranslator.GetID(string(e.Subject))
if err != nil {
return pr, errors.Wrap(err, "getting column id from subject")
}
pr.Col = col
} else if m.Nexter != nil {
pr.Col = m.Next... | [
"func",
"(",
"m",
"*",
"CollapsingMapper",
")",
"Map",
"(",
"e",
"*",
"Entity",
")",
"(",
"PilosaRecord",
",",
"error",
")",
"{",
"pr",
":=",
"PilosaRecord",
"{",
"}",
"\n",
"if",
"m",
".",
"ColTranslator",
"!=",
"nil",
"{",
"col",
",",
"err",
":="... | // Map implements the RecordMapper interface. | [
"Map",
"implements",
"the",
"RecordMapper",
"interface",
"."
] | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/mapper.go#L66-L80 |
138,595 | pilosa/pdk | mapper.go | AddVal | func (pr *PilosaRecord) AddVal(field string, value int64) {
pr.Vals = append(pr.Vals, Val{Field: field, Value: value})
} | go | func (pr *PilosaRecord) AddVal(field string, value int64) {
pr.Vals = append(pr.Vals, Val{Field: field, Value: value})
} | [
"func",
"(",
"pr",
"*",
"PilosaRecord",
")",
"AddVal",
"(",
"field",
"string",
",",
"value",
"int64",
")",
"{",
"pr",
".",
"Vals",
"=",
"append",
"(",
"pr",
".",
"Vals",
",",
"Val",
"{",
"Field",
":",
"field",
",",
"Value",
":",
"value",
"}",
")"... | // AddVal adds a new value to be range encoded into the given field to the
// PilosaRecord. | [
"AddVal",
"adds",
"a",
"new",
"value",
"to",
"be",
"range",
"encoded",
"into",
"the",
"given",
"field",
"to",
"the",
"PilosaRecord",
"."
] | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/mapper.go#L212-L214 |
138,596 | pilosa/pdk | mapper.go | AddRow | func (pr *PilosaRecord) AddRow(field string, idOrKey uint64OrString) {
pr.Rows = append(pr.Rows, Row{Field: field, ID: idOrKey})
} | go | func (pr *PilosaRecord) AddRow(field string, idOrKey uint64OrString) {
pr.Rows = append(pr.Rows, Row{Field: field, ID: idOrKey})
} | [
"func",
"(",
"pr",
"*",
"PilosaRecord",
")",
"AddRow",
"(",
"field",
"string",
",",
"idOrKey",
"uint64OrString",
")",
"{",
"pr",
".",
"Rows",
"=",
"append",
"(",
"pr",
".",
"Rows",
",",
"Row",
"{",
"Field",
":",
"field",
",",
"ID",
":",
"idOrKey",
... | // AddRow adds a new column to be set to the PilosaRecord. | [
"AddRow",
"adds",
"a",
"new",
"column",
"to",
"be",
"set",
"to",
"the",
"PilosaRecord",
"."
] | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/mapper.go#L217-L219 |
138,597 | pilosa/pdk | mapper.go | AddRowTime | func (pr *PilosaRecord) AddRowTime(field string, id uint64, ts time.Time) {
pr.Rows = append(pr.Rows, Row{Field: field, ID: id, Time: ts})
} | go | func (pr *PilosaRecord) AddRowTime(field string, id uint64, ts time.Time) {
pr.Rows = append(pr.Rows, Row{Field: field, ID: id, Time: ts})
} | [
"func",
"(",
"pr",
"*",
"PilosaRecord",
")",
"AddRowTime",
"(",
"field",
"string",
",",
"id",
"uint64",
",",
"ts",
"time",
".",
"Time",
")",
"{",
"pr",
".",
"Rows",
"=",
"append",
"(",
"pr",
".",
"Rows",
",",
"Row",
"{",
"Field",
":",
"field",
",... | // AddRowTime adds a new column to be set with a timestamp to the PilosaRecord. | [
"AddRowTime",
"adds",
"a",
"new",
"column",
"to",
"be",
"set",
"with",
"a",
"timestamp",
"to",
"the",
"PilosaRecord",
"."
] | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/mapper.go#L222-L224 |
138,598 | pilosa/pdk | cmd/taxi.go | NewTaxiCommand | func NewTaxiCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
TaxiMain = taxi.NewMain()
taxiCommand := &cobra.Command{
Use: "taxi",
Short: "Import taxi data to Pilosa.",
RunE: func(cmd *cobra.Command, args []string) error {
start := time.Now()
err := TaxiMain.Run()
if err != nil {
... | go | func NewTaxiCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
TaxiMain = taxi.NewMain()
taxiCommand := &cobra.Command{
Use: "taxi",
Short: "Import taxi data to Pilosa.",
RunE: func(cmd *cobra.Command, args []string) error {
start := time.Now()
err := TaxiMain.Run()
if err != nil {
... | [
"func",
"NewTaxiCommand",
"(",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
")",
"*",
"cobra",
".",
"Command",
"{",
"TaxiMain",
"=",
"taxi",
".",
"NewMain",
"(",
")",
"\n",
"taxiCommand",
":=",
"&",
"cobra",
".",
"... | // NewTaxiCommand wraps taxi.Main with cobra.Command for use from a CLI. | [
"NewTaxiCommand",
"wraps",
"taxi",
".",
"Main",
"with",
"cobra",
".",
"Command",
"for",
"use",
"from",
"a",
"CLI",
"."
] | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/cmd/taxi.go#L49-L76 |
138,599 | pilosa/pdk | fake/source.go | NewSource | func NewSource(seed int64, concurrency int, max uint64) *Source {
if max == 0 {
max = math.MaxUint64
}
var n uint64
s := &Source{
events: make(chan *Event, 1000),
closed: make(chan struct{}),
n: &n,
max: max,
}
for i := 0; i < concurrency; i++ {
s.wg.Add(1)
go func(i int) {
defer s.wg.Don... | go | func NewSource(seed int64, concurrency int, max uint64) *Source {
if max == 0 {
max = math.MaxUint64
}
var n uint64
s := &Source{
events: make(chan *Event, 1000),
closed: make(chan struct{}),
n: &n,
max: max,
}
for i := 0; i < concurrency; i++ {
s.wg.Add(1)
go func(i int) {
defer s.wg.Don... | [
"func",
"NewSource",
"(",
"seed",
"int64",
",",
"concurrency",
"int",
",",
"max",
"uint64",
")",
"*",
"Source",
"{",
"if",
"max",
"==",
"0",
"{",
"max",
"=",
"math",
".",
"MaxUint64",
"\n",
"}",
"\n",
"var",
"n",
"uint64",
"\n",
"s",
":=",
"&",
"... | // NewSource creates a new Source with the given random seed. Using the same
// seed should give the same series of events on a given version of Go. | [
"NewSource",
"creates",
"a",
"new",
"Source",
"with",
"the",
"given",
"random",
"seed",
".",
"Using",
"the",
"same",
"seed",
"should",
"give",
"the",
"same",
"series",
"of",
"events",
"on",
"a",
"given",
"version",
"of",
"Go",
"."
] | bba49352d71e5c23dc4a2c0d3ea08d8560678e1a | https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/fake/source.go#L21-L50 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.