text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func (pq *priorityQueue) update(ptree *ptree, value byte, count int) {
ptree.alphabet.value = value
ptree.alphabet.count = count
heap.Fix(pq, ptree.index)
} | [
-0.17500215768814087,
-1.2880983352661133,
0.3422054648399353,
-0.9185596108436584,
-0.45078200101852417,
0.8981830477714539,
-0.6672624945640564,
0.14568157494068146,
-0.1735581010580063,
0.677327036857605,
-0.4359402656555176,
-0.14186625182628632,
-1.0518156290054321,
0.7601380348205566... |
func Encode(out *bytes.Buffer, byts []byte) (*EncodeInfo, error) {
t := createTree(byts)
const codeSize = 32 // not optimize
c := code{
bits: make([]bool, 0, codeSize),
}
e := newEncoder()
if err := e.encode(t, c); err != nil {
return nil, err
}
sb, err := e.write(out, byts)
ei := &EncodeInfo{
bytCodeMap... | [
0.603248119354248,
0.5931646227836609,
0.48758235573768616,
-0.02079208567738533,
-0.5903834700584412,
0.1302035003900528,
0.3944840431213379,
-0.12700414657592773,
-0.5094528198242188,
0.18670517206192017,
-0.3191445469856262,
0.24067814648151398,
-0.11162274330854416,
0.23719030618667603... |
func Decode(out, encData *bytes.Buffer, ei *EncodeInfo) error {
const datSize = 256 // not optimize
dat := make([]bool, 0, datSize)
r := bitio.NewReader(encData)
for {
b, err := r.ReadBool()
if ei.Size == 0 {
break
}
if err == io.EOF {
break
}
if err != nil {
return err
}
dat = append(dat, ... | [
0.29191967844963074,
0.13095609843730927,
0.7411243319511414,
0.12779894471168518,
-0.007293121423572302,
0.06007467955350876,
0.8224496245384216,
0.17421090602874756,
-0.9238125681877136,
0.27832314372062683,
0.052252136170864105,
0.07458269596099854,
-0.437658429145813,
0.552395462989807... |
func TestWithRoundRobin(t *testing.T) {
t.Skip()
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, testtime.Second)
defer cancel()
permanent, permanentAddr := spec.NewServer(t, "")
defer permanent.Stop()
temporary, temporaryAddr := spec.NewServer(t, "")
defer temporary.Stop()
l, err := ne... | [
0.1881624460220337,
-0.23894494771957397,
0.7368772625923157,
-0.3985399305820465,
0.8449681401252747,
0.23361173272132874,
0.6196611523628235,
-0.22410668432712555,
0.03502544388175011,
0.05063938722014427,
-0.042382724583148956,
-0.026411360129714012,
-1.0463770627975464,
0.1279007643461... |
func NewDetachNotification(teid, seq uint32, ies ...*ie.IE) *DetachNotification {
m := &DetachNotification{
Header: NewHeader(
NewHeaderFlags(2, 0, 1),
MsgTypeDetachNotification, teid, seq, nil,
),
}
for _, i := range ies {
if i == nil {
continue
}
switch i.Type {
case ie.Cause:
m.Cause = i
... | [
-0.6054890751838684,
-0.32283952832221985,
0.33079200983047485,
-0.5240148305892944,
-0.8801620006561279,
-0.5392568707466125,
0.26724350452423096,
-0.08817959576845169,
0.36656272411346436,
0.4901815354824066,
-0.4294906258583069,
-0.2690589129924774,
0.15129230916500092,
0.24020005762577... |
func (m *DetachNotification) Marshal() ([]byte, error) {
b := make([]byte, m.MarshalLen())
if err := m.MarshalTo(b); err != nil {
return nil, err
}
return b, nil
} | [
1.4775582551956177,
1.0326250791549683,
0.5003418326377869,
-0.16787084937095642,
0.22137941420078278,
0.4095431864261627,
-0.8553279638290405,
0.057430241256952286,
0.028121205046772957,
-0.4120059311389923,
-0.7165541648864746,
0.6964613795280457,
-0.17863643169403076,
0.4028445482254028... |
func (m *DetachNotification) MarshalTo(b []byte) error {
if m.Header.Payload != nil {
m.Header.Payload = nil
}
m.Header.Payload = make([]byte, m.MarshalLen()-m.Header.MarshalLen())
offset := 0
if ie := m.Cause; ie != nil {
if err := ie.MarshalTo(m.Payload[offset:]); err != nil {
return err
}
offset += ... | [
0.6482411623001099,
0.34088918566703796,
0.8085490465164185,
-1.3736326694488525,
-0.04410916566848755,
-0.05363687127828598,
-0.4682929515838623,
-0.1246480941772461,
0.08877746760845184,
-0.35984188318252563,
-0.6948574781417847,
0.2111770212650299,
0.34272101521492004,
-0.06669455021619... |
func ParseDetachNotification(b []byte) (*DetachNotification, error) {
m := &DetachNotification{}
if err := m.UnmarshalBinary(b); err != nil {
return nil, err
}
return m, nil
} | [
0.49255284667015076,
0.02388179674744606,
0.13295455276966095,
-0.24571920931339264,
-0.4912406802177429,
-0.2350512146949768,
0.1818547397851944,
-0.2507719099521637,
0.5155659914016724,
0.027492469176650047,
-1.0563185214996338,
-0.3649345636367798,
-0.04584668204188347,
-0.2385037392377... |
func (m *DetachNotification) UnmarshalBinary(b []byte) error {
var err error
m.Header, err = ParseHeader(b)
if err != nil {
return err
}
if len(m.Header.Payload) < 2 {
return nil
}
decodedIEs, err := ie.ParseMultiIEs(m.Header.Payload)
if err != nil {
return err
}
for _, i := range decodedIEs {
if i =... | [
0.5296791195869446,
-0.003368135541677475,
0.9983148574829102,
-1.3444287776947021,
-0.2139430195093155,
-0.7092430591583252,
-0.48449403047561646,
-0.4312785267829895,
0.10876205563545227,
0.2854897081851959,
-0.4225277900695801,
-0.05566727742552757,
0.13207606971263885,
-0.2402720451354... |
func (m *DetachNotification) MarshalLen() int {
l := m.Header.MarshalLen() - len(m.Header.Payload)
if ie := m.Cause; ie != nil {
l += ie.MarshalLen()
}
if ie := m.DetachType; ie != nil {
l += ie.MarshalLen()
}
if ie := m.PrivateExtension; ie != nil {
l += ie.MarshalLen()
}
for _, ie := range m.Additiona... | [
0.8438988327980042,
0.20365707576274872,
0.3774804472923279,
-0.8809620141983032,
-0.22525101900100708,
-0.2615180015563965,
-0.5541766285896301,
0.7878714799880981,
0.36342713236808777,
-0.5835567712783813,
-0.43107613921165466,
0.3522649109363556,
0.3941120505332947,
0.3590255081653595,
... |
func (m *DetachNotification) SetLength() {
m.Header.Length = uint16(m.MarshalLen() - 4)
} | [
1.6875686645507812,
0.6006410121917725,
0.11083439737558365,
-0.4862396717071533,
1.1570569276809692,
0.945607602596283,
0.1529669314622879,
0.08808811753988266,
-0.20519301295280457,
-0.7332897186279297,
-1.1276001930236816,
-0.05799667909741402,
-0.07999556511640549,
0.18125873804092407,... |
func (m *DetachNotification) MessageTypeName() string {
return "Detach Notification"
} | [
0.5710539221763611,
-0.14095564186573029,
0.45963090658187866,
-0.11543941497802734,
-0.083187036216259,
0.315901517868042,
0.44934314489364624,
-0.487074613571167,
0.013742579147219658,
0.22481229901313782,
-0.554425835609436,
-0.9205551147460938,
-0.5226792097091675,
0.19908849895000458,... |
func (m *DetachNotification) TEID() uint32 {
return m.Header.teid()
} | [
0.9097692966461182,
-0.23909425735473633,
0.3255077600479126,
-0.5921424627304077,
0.2216232270002365,
0.6055814623832703,
0.04277211055159569,
-0.1313316822052002,
0.34970611333847046,
0.2503565847873688,
-0.12357860803604126,
-0.8328050374984741,
-0.23542822897434235,
0.580152690410614,
... |
func (c *C) NewLauncher(ns Namespaces, nsRead ...services.Namespace) *Launcher {
return &Launcher{
Configs: services.NewConfigs(nsRead...),
client: c,
ns: ns,
}
} | [
0.5499811172485352,
-0.7616329789161682,
-0.046285249292850494,
0.3786565363407135,
-1.7261425256729126,
0.6705344319343567,
-0.9572077989578247,
-0.1356160044670105,
0.32816654443740845,
-1.043172001838684,
0.33069586753845215,
0.21867264807224274,
-0.04879356548190117,
1.2146892547607422... |
func (l *Launcher) Up(configs services.Configs) error {
l.m.Lock()
defer l.m.Unlock()
cfg := Config{}
if err := cfg.Dial(configs[l.ns.Client]); err != nil {
return err
}
return l.client.Dial(cfg)
} | [
-0.5818884968757629,
0.22616739571094513,
0.5051380395889282,
0.5251287817955017,
-0.4573203921318054,
0.4099403917789459,
-0.4652549624443054,
-0.19332006573677063,
-0.12250633537769318,
0.6723656058311462,
0.31234195828437805,
0.5479661226272583,
-0.44202011823654175,
0.00216908939182758... |
func (l *Launcher) Down(configs services.Configs) error {
l.m.Lock()
defer l.m.Unlock()
return l.client.Close()
} | [
0.09239625930786133,
-0.20771487057209015,
0.40619075298309326,
0.31994035840034485,
-0.40372180938720703,
1.5499712228775024,
0.2527613043785095,
0.3689935505390167,
-0.19576559960842133,
-0.5291863679885864,
0.9131816029548645,
0.4806632399559021,
-1.460137963294983,
0.3089148998260498,
... |
func Exec(ctx context.Context, client *containerd.Client, args []string, options types.ContainerExecOptions) error {
walker := &containerwalker.ContainerWalker{
Client: client,
OnFound: func(ctx context.Context, found containerwalker.Found) error {
if found.MatchCount > 1 {
return fmt.Errorf("multiple IDs f... | [
-0.3448910713195801,
0.1524735391139984,
0.822609007358551,
0.4543198049068451,
0.5610025525093079,
-0.31670868396759033,
0.43791523575782776,
-0.799296498298645,
0.05746656656265259,
0.16822880506515503,
0.45435428619384766,
0.31093665957450867,
0.18279477953910828,
0.45390766859054565,
... |
func (service *channelIdManager) NewChanIDFromOutPoint(op *OutPoint) string {
// First we'll copy the txid of the outpoint into our channel ID slice.
var cid ChannelID
copy(cid[:], op.Hash[:])
// With the txid copied over, we'll now XOR the lower 2-bytes of the partial channelID with big-endian serialization of ou... | [
0.24611827731132507,
-1.1386126279830933,
0.4223496913909912,
0.02819913625717163,
-1.0994378328323364,
-0.5503084659576416,
-0.08119223266839981,
-0.5449258089065552,
0.6352993845939636,
0.017487073317170143,
0.13352681696414948,
0.33106595277786255,
-0.2912842631340027,
-1.24743831157684... |
func xorTxid(cid *ChannelID, outputIndex uint16) {
var buf [32]byte
binary.BigEndian.PutUint16(buf[30:], outputIndex)
cid[30] = cid[30] ^ buf[30]
cid[31] = cid[31] ^ buf[31]
} | [
0.7385314106941223,
-0.011311228387057781,
0.3922073245048523,
-1.1189727783203125,
-0.13602511584758759,
0.04456218704581261,
-0.8275526165962219,
-1.511475920677185,
0.22386954724788666,
0.12337162345647812,
-0.026398230344057083,
0.20246358215808868,
-0.909306526184082,
-0.9740917086601... |
func (service *channelIdManager) NextTemporaryChanID() string {
// Obtain a fresh nonce. We do this by encoding the current nonce counter, then incrementing it by one.
service.nonceMtx.Lock()
var nonce [8]byte
binary.LittleEndian.PutUint64(nonce[:], service.chanIDNonce)
service.chanIDNonce++
service.nonceMtx.Unlo... | [
0.05208761990070343,
-0.19805465638637543,
0.5550092458724976,
-0.5552738308906555,
-0.7248283624649048,
-0.27098792791366577,
-0.12466976791620255,
-1.0013387203216553,
0.5632780194282532,
-0.42706233263015747,
0.06809815019369125,
0.3925631642341614,
-0.6464856266975403,
0.26571512222290... |
func RunCommonBootstrapDialog() error {
for _, spec := range bootstrapSpecs {
if err := BootstrapConfig(spec); err != nil {
return err
}
}
return nil
} | [
-0.3288382887840271,
0.04402628540992737,
0.42945581674575806,
0.4513207674026489,
0.2212677299976349,
0.26070868968963623,
0.6500717401504517,
-0.11223253607749939,
-0.6629546284675598,
1.056742787361145,
0.32505494356155396,
-0.33610159158706665,
-0.23665274679660797,
1.1205811500549316,... |
func RunModuleBootstrapDialog(sections ...*ModuleDialogSection) error {
// Try to read the local configuration file.
localConfig, err := config.ReadLocalConfig()
if err != nil {
if !os.IsNotExist(errs.RootCause(err)) {
return err
}
}
for _, section := range sections {
modules := section.AvailableModules
... | [
-0.6009612083435059,
-0.6106363534927368,
0.746813178062439,
0.22655560076236725,
-0.017441244795918465,
-0.25716233253479004,
0.17895932495594025,
-0.21641063690185547,
-0.16569866240024567,
0.9717493653297424,
0.7264644503593445,
0.15575937926769257,
-0.2609938979148865,
0.59014540910720... |
func (c *GoogleStaticMapClient) AddPath(color string, weight int, coordinates [][]float64) {
path := mapPath{
Color: color,
Weight: weight,
}
// To Filter out the points greater than 1000
totalPoints := len(coordinates)
filteredCoordinates := make([][]float64, 0)
if totalPoints > 1000 {
numToReduce := tota... | [
0.09906378388404846,
0.008272768929600716,
0.8880051970481873,
0.09828630089759827,
0.26978564262390137,
0.13049276173114777,
0.4851841330528259,
-0.29264187812805176,
0.12939170002937317,
-0.19761963188648224,
0.31632399559020996,
-0.1486194133758545,
0.07246407866477966,
0.35236036777496... |
func (c *GoogleStaticMapClient) buildApiUrl() string {
baseUrl := GoogleStaticMapApiPath
// API Key
apiUrl := baseUrl + "?key=" + c.GoogleApiKey
// Image Scale
if c.Scale > 0 {
apiUrl = fmt.Sprintf("%s&scale=%d", apiUrl, c.Scale)
}
// Image Format Type
if c.ImageType != "" {
apiUrl = apiUrl + "&format=" + c... | [
-1.1331573724746704,
-1.1182790994644165,
0.5519402027130127,
-0.2457028478384018,
-0.345510333776474,
0.19938914477825165,
-0.34318724274635315,
0.09330040216445923,
-0.40660521388053894,
0.4664221405982971,
0.004534411709755659,
-0.08701743930578232,
0.10218880325555801,
0.39394813776016... |
func (c *GoogleStaticMapClient) Send() ([]byte, error) {
requestUrl := c.buildApiUrl()
resp, err := http.Get(requestUrl)
Log.Debug("Calling Google Static Map API", With("requestUrl", requestUrl))
if err != nil {
return nil, Log.Error("Failed to call Google Static Map API", With("requestUrl", requestUrl), WithErro... | [
-1.024470567703247,
-0.698033332824707,
0.6889720559120178,
0.12982434034347534,
0.17676664888858795,
0.5068243741989136,
-0.8310994505882263,
-0.9081424474716187,
-0.17349542677402496,
0.2851974666118622,
-0.6646960377693176,
0.8756916522979736,
-0.8337644338607788,
0.46649396419525146,
... |
func NewScout(m Map, origin Vector, messages chan<- Message) *Scout {
return &Scout{
Map: m,
Origin: origin,
Messages: messages,
}
} | [
-0.03384722024202347,
-0.5609788298606873,
0.1409144252538681,
0.21865221858024597,
-0.6823720932006836,
-0.109911248087883,
0.04480718821287155,
0.019784366711974144,
-0.38111412525177,
0.2892804443836212,
0.33169934153556824,
0.8243752717971802,
0.0250583253800869,
0.33664482831954956,
... |
func (s Scout) SearchAndReport() {
visible := 0
for _, check := range s.Map {
// Don't count the origin!
if check.Pos == s.Origin {
continue
}
// Is anything blocking the scout's view of check?
// From s.Origin to check, is there anything in between?
// If so, add it to the Visible map.
isBlocked ... | [
0.1680971086025238,
-0.004791629035025835,
0.7587272524833679,
-0.09376372396945953,
0.17646528780460358,
-0.4260393977165222,
0.8356272578239441,
0.3624965250492096,
0.03774266317486763,
-0.19448530673980713,
-0.08004147559404373,
0.2161746770143509,
-0.032196976244449615,
0.9540060162544... |
func ReadConfigFile(filename string) (*specs.Spec, error) {
fh, err := os.Open(filename)
if err != nil {
return nil, err
}
defer fh.Close()
return ReadConfig(fh)
} | [
0.04192950204014778,
0.14553500711917877,
0.32613635063171387,
-0.20161321759223938,
-0.4614713788032532,
0.5843917727470398,
0.280629426240921,
0.4406145215034485,
-1.7624950408935547,
1.0320501327514648,
0.004420573357492685,
-0.5896691679954529,
-0.1703082025051117,
0.868104875087738,
... |
func ReadConfig(input io.Reader) (*specs.Spec, error) {
d := json.NewDecoder(input)
s := specs.Spec{}
if err := d.Decode(&s); err != nil {
return nil, err
}
return &s, nil
} | [
-0.2034902721643448,
-0.2675868570804596,
0.3540899157524109,
-0.7565809488296509,
-0.8636164665222168,
0.041109852492809296,
-0.17127175629138947,
0.12157922238111496,
-0.9129652380943298,
0.5882980227470398,
0.20603115856647491,
0.10985662043094635,
0.3067881166934967,
0.4998794794082641... |
func Start(conf Config) (_ *Job, err error) {
if conf.Command == "" {
return nil, errors.New("command is empty")
}
if conf.MakeExecutionArguments == nil {
return nil, errors.New("`MakeExecutionArguments` is nil")
}
id, err := ulid.New(ulid.Now(), entropy)
if err != nil {
return nil, fmt.Errorf("failed to g... | [
0.6581493020057678,
-0.08050886541604996,
0.90343177318573,
0.5888235569000244,
0.34566599130630493,
-0.09872819483280182,
0.8136665225028992,
0.7731748819351196,
-0.8528218865394592,
0.13471820950508118,
-0.18593141436576843,
0.8894417881965637,
-0.13908447325229645,
0.4559888541698456,
... |
func (j *Job) ID() ulid.ULID {
return j.id
} | [
0.8497575521469116,
-0.5096149444580078,
0.28326311707496643,
0.7803014516830444,
-0.07528071850538254,
1.2431610822677612,
-0.08968900144100189,
1.114614725112915,
1.274287462234497,
-0.8888422846794128,
-0.3139374554157257,
0.21044211089611053,
-0.6623502373695374,
0.602913498878479,
-... |
func (j *Job) Wait(ctx context.Context) error {
select {
case <-ctx.Done():
return ctx.Err()
case <-j.doneCh:
return nil
}
} | [
0.1577221155166626,
0.33813536167144775,
0.38479122519493103,
-0.06342494487762451,
0.4325820803642273,
0.05120067298412323,
-0.3124391734600067,
-1.145764946937561,
0.42059770226478577,
-0.8744727969169617,
-0.15866267681121826,
0.1384659856557846,
0.049655769020318985,
-0.291715115308761... |
func (j *Job) Stop() error {
j.stoppedMu.Lock()
defer j.stoppedMu.Unlock()
if j.stopped {
return nil
}
j.stopped = true
select {
case <-j.doneCh:
return nil
default:
// NOTE: Since job is started with Pdeathsig, this kills children as well.
// NOTE(2): This potentially is in race condition with Wait ca... | [
0.011967727914452553,
-0.38033223152160645,
0.6241078972816467,
0.459477037191391,
0.3398585021495819,
-0.1829322725534439,
0.3762511909008026,
-0.4531397223472595,
-0.7057222723960876,
-0.10089176148176193,
-0.6003476977348328,
-0.03573594614863396,
-0.2664726674556732,
-0.249068513512611... |
func parseCPUTimeLine(b []byte) (time.Duration, error) {
kv := bytes.Fields(b)
if len(kv) != 2 {
return 0, errors.New("line is not in '$field $value' format")
}
v, err := strconv.ParseInt(string(kv[1]), 10, 64)
if err != nil {
return 0, fmt.Errorf("failed to parse %s into int64: %w", kv[1], err)
}
if v < 0 {... | [
-0.37608325481414795,
0.3514345586299896,
0.5196113586425781,
0.1941012293100357,
-0.3138869106769562,
-0.12795567512512207,
0.15424302220344543,
0.12778571248054504,
-0.6860120892524719,
0.6402282118797302,
-0.27739235758781433,
-0.42705556750297546,
-0.688118577003479,
0.5969004034996033... |
func (j *Job) Status() (*Status, error) {
var (
stopped bool
killed bool
exitCode *int
userTime time.Duration
systemTime time.Duration
memoryCurrent uint64
)
if j.cmd.ProcessState != nil {
j.stoppedMu.RLock()
stopped = j.stopped
// NOTE: Lock is held here until `killed` v... | [
-0.0015557084698230028,
-0.9640342593193054,
0.5784941911697388,
-0.1446886509656906,
-0.5101092457771301,
-0.5295017957687378,
0.32732442021369934,
0.19744227826595306,
-0.6355644464492798,
0.2437451034784317,
0.2816182076931,
0.6963115334510803,
-0.438227117061615,
0.6666379570960999,
... |
func (j *Job) HandleLog(ctx context.Context, n uint, stdoutHandle, stderrHandle func(b []byte) error) error {
stdoutCh := make(chan notify.EventInfo, notifyBufSize)
if err := notify.Watch(j.stdout, stdoutCh, notify.Write); err != nil {
return fmt.Errorf("failed to watch stdout file: %w", err)
}
defer notify.Stop(... | [
0.9969567060470581,
0.09309116005897522,
1.1422547101974487,
-0.21993879973888397,
-0.6872662901878357,
-0.8066567182540894,
0.6635951995849609,
-0.7258058190345764,
-0.5113500356674194,
-0.4838714897632599,
0.3613651394844055,
-0.2729642689228058,
0.49183937907218933,
0.028919054195284843... |
func Execute(fifoPath string) error {
fifo, err := os.Open(fifoPath)
if err != nil {
return fmt.Errorf("failed to open FIFO file: %w", err)
}
var req executionRequest
if err := gob.NewDecoder(fifo).Decode(&req); err != nil {
return fmt.Errorf("failed to read execution request from FIFO file: %w", err)
}
if e... | [
-0.39549270272254944,
0.26361316442489624,
0.6957727074623108,
0.44328975677490234,
0.6209284067153931,
0.03170609474182129,
0.39770641922950745,
0.4288399815559387,
-0.9815138578414917,
0.4377260208129883,
-0.08160418272018433,
-0.5423848628997803,
-0.5775185227394104,
0.5917090773582458,... |
func (o *Options) UseDBCache() bool {
return o.useDBCache
} | [
-0.06207328289747238,
0.9540174007415771,
0.7570325136184692,
0.08447760343551636,
0.2731303870677948,
-0.5232936143875122,
0.473738431930542,
-0.5521194338798523,
0.04043269157409668,
0.43449386954307556,
-0.2099938839673996,
-0.2079513818025589,
-1.564318299293518,
1.2753921747207642,
... |
func (o *Options) CacheDBType() string {
return o.cacheDBType
} | [
-0.035217806696891785,
1.090904712677002,
0.16796332597732544,
1.0774325132369995,
0.10289595276117325,
1.2229403257369995,
0.05493706464767456,
-0.5754382610321045,
0.5554379224777222,
0.26399874687194824,
-0.7375720143318176,
0.23410700261592865,
-1.046477198600769,
0.7228483557701111,
... |
func (o *Options) CacheDBConStr() string {
return o.cacheDBConStr
} | [
0.009995176456868649,
-0.3641647398471832,
0.07786469161510468,
0.5363458395004272,
-0.9422445297241211,
1.680993914604187,
0.010452727787196636,
-0.029493017122149467,
0.017781009897589684,
-0.22156108915805817,
-0.1776348203420639,
0.476406455039978,
-0.3469275236129761,
0.48047763109207... |
func (o *Options) ExportToDBConStr() string {
return o.exportToDBConStr
} | [
0.17280222475528717,
-0.27482321858406067,
0.3984563648700714,
0.16803200542926788,
-0.18960218131542206,
0.9087139964103699,
0.49768808484077454,
-0.38818323612213135,
0.5023976564407349,
0.8499661087989807,
-0.0568847730755806,
0.3308372497558594,
-0.5044738054275513,
0.10094007849693298... |
func Flags(cmd *cobra.Command, vp *viper.Viper) error {
for _, fn := range FlagFuncs {
if err := fn(cmd, vp); err != nil {
return fmt.Errorf("invalid flag(s): %w", err)
}
}
return nil
} | [
0.503229558467865,
0.8766803741455078,
0.2966628968715668,
0.536087691783905,
0.6581944823265076,
0.39295122027397156,
-0.1116478219628334,
0.2504623830318451,
-0.5177450180053711,
-0.8517538905143738,
-0.05301467329263687,
0.607932984828949,
-0.44063878059387207,
1.2066352367401123,
0.2... |
func (l *Line) UnmarshalJSON(b []byte) error {
// First let's create the analogous structure
// We define some of the value as pointers to the real values, allowing us to bypass copying in cases where we don't need to process the data
data := &struct {
// Pointers to the corresponding real values
ID ... | [
-0.23790207505226135,
-0.32614290714263916,
0.8954254984855652,
-0.714738130569458,
0.0871557667851448,
-0.3330622613430023,
-0.3471774458885193,
0.2471027821302414,
-0.4363737404346466,
-0.5225468873977661,
-0.5957180857658386,
0.009107419289648533,
0.12140244990587234,
0.4106009900569916... |
func (client ListResult) ListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
} | [
-0.7470627427101135,
-0.35259512066841125,
0.4985541105270386,
-0.39847615361213684,
-0.321061909198761,
-0.910274088382721,
-0.8663668632507324,
-0.7279514670372009,
1.20845365524292,
-0.46693333983421326,
-0.6009287238121033,
-0.6091150045394897,
-0.02214898355305195,
1.0000213384628296,... |
func (m *Master) WaitMapTaskFinished(args *NoArgs, reply *WaitMapReply) error {
reply.IsFinished = m.nMap <= 0
return nil
} | [
0.03512280061841011,
-0.837091326713562,
0.36357197165489197,
0.018986251205205917,
-0.022032249718904495,
0.32779884338378906,
-0.7454177737236023,
0.15731005370616913,
0.20498542487621307,
-0.381452739238739,
-1.056867241859436,
-0.5418234467506409,
-0.0003637557092588395,
0.934131503105... |
func (m *Master) server() {
rpc.Register(m)
rpc.HandleHTTP()
l, e := net.Listen("tcp", ":1234")
//l, e := net.Listen("unix", sockname)
if e != nil {
log.Fatal("listen error:", e)
}
go http.Serve(l, nil)
} | [
-0.6426321864128113,
-0.20688581466674805,
0.5828617811203003,
0.1900506615638733,
1.3740264177322388,
0.959710955619812,
-0.0955546572804451,
1.1472152471542358,
-0.9847094416618347,
-0.2853960692882538,
-0.9763873219490051,
0.07632659375667572,
-0.9936228394508362,
0.9753437638282776,
... |
func (m *Master) Done() bool {
ret := false
fmt.Printf("MapTasks: %v\n", m.mapTasks)
fmt.Printf("RedTasks: %v\n", m.reduceTasks)
fmt.Printf("nReduce: %d, nMap: %d\n", m.nReduce, m.nMap)
// Your code here.
// all tasks have finished
if m.hasGenerateReduceTasks && m.nReduce <= 0 && m.nMap <= 0 {
ret = true
fmt... | [
-0.4959193766117096,
0.31240805983543396,
0.9721295833587646,
0.674295961856842,
-0.2509607970714569,
0.719073474407196,
-0.30124080181121826,
0.47606512904167175,
-0.5893747210502625,
-0.6906414031982422,
-1.0608333349227905,
-0.32161974906921387,
-0.2678903639316559,
1.7642537355422974,
... |
func MakeMaster(files []string, nReduce int) *Master {
m := Master{}
m.nMap = len(files)
m.ReduceOutNum = nReduce
m.nReduce = 0
// Your code here.
// init task
m.mapTasks = make([]Task, 0)
m.reduceTasks = make([]Task, 0)
m.reduceTaskFileLists = make([][]string, m.ReduceOutNum)
m.hasGenerateReduceTasks = false... | [
-0.8718509078025818,
-0.41405999660491943,
0.9320843815803528,
0.5700603127479553,
-0.8512955904006958,
0.16778048872947693,
0.2558053433895111,
0.6992750763893127,
0.11192695796489716,
-0.7146559357643127,
-0.7973390817642212,
-0.5031996369361877,
-0.40590915083885193,
0.5262292623519897,... |
func ihash(key string) int {
h := fnv.New32a()
h.Write([]byte(key))
return int(h.Sum32() & 0x7fffffff)
} | [
-0.4412902295589447,
0.5888450145721436,
0.7938997745513916,
-0.1217726394534111,
-0.8729031085968018,
0.6896989345550537,
0.24741999804973602,
-0.236440971493721,
-0.34697774052619934,
0.1803821325302124,
-0.6419464945793152,
0.26671910285949707,
-1.4346258640289307,
-0.3144763112068176,
... |
func GenerateRandom() string {
randomNum, err := rand.Prime(rand.Reader, 32)
if err != nil {
log.Fatal(err)
}
return randomNum.String()[:6]
} | [
0.3612004816532135,
-0.052321869879961014,
0.6843317151069641,
-0.19499602913856506,
-0.13824018836021423,
0.7057141661643982,
-0.21709658205509186,
-0.15624083578586578,
0.6752886772155762,
-0.6182244420051575,
0.2590138912200928,
-0.3706032931804657,
-0.31299686431884766,
0.0345174223184... |
func B64Encrypt(qrToken string) string {
salt := "/qr-g3nerat0r/"
data := salt + qrToken
return base64.StdEncoding.EncodeToString([]byte(data))
} | [
0.5334835648536682,
-0.16732998192310333,
0.34812188148498535,
0.21936334669589996,
0.4134541451931,
0.27025893330574036,
-1.3294217586517334,
-0.7543385028839111,
0.05282362177968025,
0.7553738951683044,
-0.4336775839328766,
0.3396182954311371,
-0.6965783834457397,
-0.09273110330104828,
... |
func GenerateQR(content string) (qrCode []byte, qrContent string, qrToken string, err error) {
qrContent = content
qrToken = GenerateRandom()
encryptedQRToken := B64Encrypt(qrToken)
if len(encryptedQRToken) == 0 {
return nil, "", "", errors.New("fail to create QR Code Token")
}
qrCode, err = qr.Encode(encryp... | [
0.1769922822713852,
-0.5218549370765686,
0.6050940752029419,
-0.20970796048641205,
-0.1691640317440033,
-0.06703618168830872,
-1.116089105606079,
-0.6815580129623413,
0.2529948353767395,
0.07252471148967743,
-0.6342053413391113,
-0.28372013568878174,
-1.0711920261383057,
0.4498835504055023... |
func VerifyQR(c *gin.Context) {
QRToken := c.Param("qrToken")
var findResult qrcode.QRCode
filter := bson.D{{Key: "qrToken", Value: QRToken}}
opts := options.FindOne()
opts.SetSort(bson.D{{"createdAt", -1}})
err := models.QRCodes.FindOne(context.Background(), filter, opts).Decode(&findResult)
if err != nil {
... | [
0.14142967760562897,
-0.5964666604995728,
0.719371497631073,
-0.31159520149230957,
0.6152315735816956,
0.11683192104101181,
-0.49411532282829285,
-0.9512107372283936,
0.3115644156932831,
-0.382524698972702,
-0.32407552003860474,
0.4354782700538635,
-0.9297050833702087,
1.0203474760055542,
... |
func StatusTextFunc(code int) string {
return statusText[code]
} | [
-0.06776668131351471,
-1.0807957649230957,
0.08771676570177078,
0.0728333592414856,
-1.3977153301239014,
-0.2463889867067337,
0.09977289289236069,
1.0592337846755981,
0.7098062634468079,
1.0927534103393555,
-0.6216612458229065,
0.09517994523048401,
0.6458234190940857,
-0.6574400663375854,
... |
func ReadConfig() (Config, error) {
if len(os.Args) > 1 {
return readFile(os.Args[1])
}
for _, f := range []string{"/etc/craftdoor/master.json", "./develop.json"} {
_, err := os.Stat(f)
if err == nil {
return readFile(f)
}
}
return Config{}, fmt.Errorf("could not find config file")
} | [
-0.39086928963661194,
0.07834374904632568,
0.7912483811378479,
0.6782329082489014,
0.08966746926307678,
0.2953888773918152,
0.7757099866867065,
-0.16134017705917358,
-1.3988474607467651,
0.17992500960826874,
0.6220338940620422,
-0.33959782123565674,
0.4990246891975403,
1.2687957286834717,
... |
func date(age string) (time.Time, error) {
if len(age) == 0 {
return time.Now(), nil
}
re := regexp.MustCompilePOSIX("([0-9]+)([a-z]+)")
// blanket invalid age response
err := func() (time.Time, error) {
return time.Time{}, fmt.Errorf("%s not valid age. format (1m|1h|1d)", age)
}
if !re.MatchString(age) {... | [
-0.07710924744606018,
0.014462974853813648,
1.0428094863891602,
-0.01924137957394123,
-1.0070476531982422,
-0.03370089456439018,
-0.3465712070465088,
-0.3873358368873596,
-0.03903881832957268,
0.2033417969942093,
-0.2596355080604553,
-0.07268849015235901,
-0.1891288012266159,
1.14299023151... |
func TestSendDataLength(t *testing.T) {
loadConfig()
for _, item := range tests {
var buf bytes.Buffer
fmt.Fprint(&buf, "UR001!")
v, err := sendData(&buf)
if err != nil {
t.Error("Error", err.Error())
}
if len(v) != item.resultSize {
t.Error(
"Command Sent", item.command,
"Expected Return Si... | [
0.07540902495384216,
0.9557154178619385,
0.6623331904411316,
-0.6490388512611389,
0.9852770566940308,
0.7419964671134949,
0.4581490159034729,
-0.0950828567147255,
-0.11148785054683685,
-0.4236588776111603,
-0.9820995926856995,
0.15945245325565338,
-0.6907674074172974,
0.4175303876399994,
... |
func rectProps(length, width float64) (float64, float64) {
var area = length * width
var perimeter = (length + width) * 2
return area, perimeter
} | [
-0.42864978313446045,
-1.243186116218567,
0.5829009413719177,
-1.2015172243118286,
-0.33850932121276855,
-0.6960986852645874,
-0.31694552302360535,
-0.5134547352790833,
1.1584196090698242,
0.18170957267284393,
-0.003000009572133422,
-0.333198606967926,
0.07057230174541473,
-0.7196723222732... |
func rectProps2(length, width float64) (area, perimeter float64) {
area = length * width
perimeter = (length + width) * 2
return //no explicit return value
} | [
-0.4350188076496124,
-1.8282339572906494,
0.4540186822414398,
-0.8624390959739685,
-0.8950005769729614,
-0.533227801322937,
-0.3080180287361145,
-0.8408707976341248,
0.7585957646369934,
-0.08165701478719711,
-0.19230860471725464,
-0.09664535522460938,
0.27983027696609497,
-0.35320052504539... |
func variadic(x ...int) {
fmt.Println(x)
fmt.Printf("%T\n", x)
// Receives the variables in a slice of the type of the parameters. ([]int)
sum := 0
for _, v := range x {
sum += v
}
fmt.Printf("The total: %v\n", sum)
} | [
0.3409070670604706,
-0.06432520598173141,
0.5460957884788513,
-0.09798531979322433,
0.8018417954444885,
0.2490847408771515,
-0.4007844924926758,
-0.9916912317276001,
-0.7653393745422363,
0.4117914140224457,
-0.7229359149932861,
1.0939545631408691,
0.4144846498966217,
-0.23067942261695862,
... |
func (s *Signald) Link(deviceName string, requestID string) (Response, error) {
if requestID == "" {
return s.SendAndListen(
Request{
Type: "link",
DeviceName: deviceName,
},
[]string{"linking_uri"})
}
return s.SendAndListen(
Request{
Type: "",
ID: requestID,
},
[]string{"link... | [
-0.3571305274963379,
0.5981356501579285,
0.4251144826412201,
1.1216678619384766,
0.3528258800506592,
0.5960896611213684,
0.40462827682495117,
-0.30068209767341614,
0.9878047704696655,
-0.5754383206367493,
0.4642869532108307,
0.37278318405151367,
-0.6623882055282593,
0.9863439798355103,
0... |
func ServicePage(w http.ResponseWriter, r *http.Request) {
var data TemplateData
data.Init()
data.BoolVals["logged_in"] = false
if r.Method == "GET" {
if a, user := session.ValidateToken(r); a {
data.BoolVals["logged_in"] = true
data.StringVals["logged_in_name"] = "Logged in as "+user
}
data.StringVal... | [
-0.026258792728185654,
0.5365602970123291,
0.7660906910896301,
-0.07800569385290146,
-0.5243672728538513,
0.665225625038147,
0.7291873693466187,
0.22852587699890137,
-0.7062100172042847,
0.8755643963813782,
0.9591474533081055,
-0.34175753593444824,
-1.171013355255127,
0.6518407464027405,
... |
func New(name string) (int, bool, error) {
link, err := netlink.LinkByName(name)
if err == nil {
return link.Attrs().Index, false, nil
}
if _, ok := err.(netlink.LinkNotFoundError); !ok {
return 0, false, fmt.Errorf("failed to get links: %v", err)
}
wl := wgLink{a: netlink.NewLinkAttrs(), t: "wireguard"}
wl.... | [
-0.8530762791633606,
0.15814821422100067,
0.7249001264572144,
-0.8220676779747009,
-0.6059184670448303,
-0.5114402770996094,
0.8356842398643494,
-0.17056451737880707,
-0.5156505703926086,
-0.28922033309936523,
-0.7904068231582642,
-0.6169235706329346,
-0.6984218955039978,
1.299982309341430... |
func Keys() ([]byte, []byte, error) {
private, err := GenKey()
if err != nil {
return nil, nil, fmt.Errorf("failed to generate private key: %v", err)
}
public, err := PubKey(private)
return private, public, err
} | [
-1.3028045892715454,
0.6997877359390259,
0.42414185404777527,
-0.5671585202217102,
0.4896286427974701,
-0.3839644491672516,
-0.7006662487983704,
-0.19101279973983765,
-0.42480337619781494,
-0.11642320454120636,
-0.9063754081726074,
0.629196047782898,
-0.4388401508331299,
0.7051531672477722... |
func GenKey() ([]byte, error) {
key, err := exec.Command("wg", "genkey").Output()
return bytes.Trim(key, "\n"), err
} | [
-0.5270587205886841,
0.6346787214279175,
0.5226967334747314,
0.9661391973495483,
-0.106985904276371,
0.042659930884838104,
-0.20502911508083344,
-0.7363241910934448,
-0.5407723188400269,
0.33706796169281006,
-0.011774257756769657,
0.7513933777809143,
-1.314140796661377,
0.5063532590866089,... |
func PubKey(key []byte) ([]byte, error) {
cmd := exec.Command("wg", "pubkey")
stdin, err := cmd.StdinPipe()
if err != nil {
return nil, fmt.Errorf("failed to open pipe to stdin: %v", err)
}
go func() {
defer stdin.Close()
stdin.Write(key)
}()
public, err := cmd.Output()
if err != nil {
return nil, fmt... | [
-0.1041942834854126,
0.4826236963272095,
0.5192093253135681,
0.21381686627864838,
-0.6654574275016785,
-0.1177111342549324,
0.24406424164772034,
0.04170738905668259,
-0.4836501181125641,
0.9175415635108948,
-0.18098944425582886,
0.07050597667694092,
-0.9682067036628723,
1.0810353755950928,... |
func SetConf(iface string, path string) error {
cmd := exec.Command("wg", "setconf", iface, path)
var stderr bytes.Buffer
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to apply the WireGuard configuration: %s", stderr.String())
}
return nil
} | [
0.07017762213945389,
0.5837504863739014,
0.3906704783439636,
0.01385462936013937,
0.4799592196941376,
0.03534848615527153,
0.8695144653320312,
0.1257936805486679,
-0.6510580778121948,
0.41294652223587036,
-0.3764384090900421,
0.45199131965637207,
-1.0781327486038208,
1.3891994953155518,
... |
func ShowConf(iface string) ([]byte, error) {
cmd := exec.Command("wg", "showconf", iface)
var stderr, stdout bytes.Buffer
cmd.Stderr = &stderr
cmd.Stdout = &stdout
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("failed to read the WireGuard configuration: %s", stderr.String())
}
return stdout.Bytes(... | [
0.16829192638397217,
0.7551151514053345,
0.40445563197135925,
-0.6784308552742004,
-1.019140362739563,
-1.1064586639404297,
0.7374681234359741,
-0.6759011149406433,
-0.30503538250923157,
1.1571965217590332,
0.10487697273492813,
0.28792670369148254,
-0.7901677489280701,
1.3114991188049316,
... |
func Parse(config string) test.Error {
lines := strings.Split(config, "\n")
if len(lines) == 1 {
return parseConfigRule(lines[0])
}
for i, ln := range lines {
err := parseConfigRule(ln)
if err != nil {
return err.Prepend("error on line %d: ", i+1)
}
}
return nil
} | [
0.5131966471672058,
0.4401420056819916,
0.4557679295539856,
0.7855204343795776,
0.5923188328742981,
-0.4969666004180908,
0.38609227538108826,
0.40649259090423584,
-0.6301031708717346,
-0.004275304730981588,
0.22041620314121246,
-0.48837998509407043,
-0.8237774968147278,
1.207810401916504,
... |
func thisLittleWebpage(res http.ResponseWriter, req *http.Request) {
val := req.FormValue("n") // set the FormValue name
// for simplicity, the webpage is generated here
page := `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form method="GET">
<in... | [
-0.6410273313522339,
-0.09880291670560837,
0.8144230842590332,
-0.3335149884223938,
0.20401136577129364,
0.848236083984375,
-0.35703742504119873,
-0.10193996131420135,
0.21472984552383423,
-0.6813530325889587,
-0.5151620507240295,
-0.7547350525856018,
-0.1316365897655487,
1.115931630134582... |
func CreateDir(dir string) {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err = os.MkdirAll(dir, 0755)
if err != nil {
panic(err)
}
}
} | [
0.7220823764801025,
0.6520414352416992,
0.48519474267959595,
0.2404526025056839,
0.060342054814100266,
1.6368865966796875,
0.23240511119365692,
-0.5316932797431946,
0.15251708030700684,
-0.6226426362991333,
0.08775733411312103,
-0.07790310680866241,
0.5583577156066895,
0.3900240957736969,
... |
func FileExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return true, err
} | [
-0.6761287450790405,
-0.35119929909706116,
0.8790376782417297,
-0.36277955770492554,
1.236910343170166,
0.7242504358291626,
-0.6003958582878113,
0.333918958902359,
-0.6959974765777588,
-0.2550008296966553,
-0.4117681384086609,
-0.5859923362731934,
0.3545159101486206,
0.353718101978302,
-... |
func (t *Token) get(sender [32]byte) *Balance {
for _, b := range t.Balances {
if b.Sender == sender {
return &b
}
}
return nil
} | [
0.3322176933288574,
-0.11563169211149216,
0.5991811752319336,
-0.36049261689186096,
-0.25142866373062134,
-0.24160316586494446,
-0.5981653928756714,
-1.5500071048736572,
0.3822932243347168,
0.16392186284065247,
-0.6931934952735901,
0.57537442445755,
-0.22227297723293304,
-0.536869406700134... |
func main() {
fmt.Println(a)
fmt.Println(b)
fmt.Println(c)
} | [
0.9853621125221252,
-0.3952936828136444,
0.7864699363708496,
-0.06584029644727707,
0.9952832460403442,
1.3368135690689087,
0.6388452649116516,
0.19553939998149872,
-0.5046972632408142,
-0.5776050090789795,
0.09381061047315598,
0.1617814600467682,
-0.12384603172540665,
0.17576964199543,
-... |
func SaveStruct(x interface{}) ([]datastore.Property, error) {
ps, err := datastore.SaveStruct(x)
if err != nil {
return ps, err
}
return denormalize(ps), nil
} | [
-1.6693683862686157,
0.2299427092075348,
0.4490734040737152,
0.3325784206390381,
-0.45677587389945984,
-0.6721672415733337,
-1.0046143531799316,
0.2738334536552429,
0.6197518706321716,
-0.37401649355888367,
-1.3154405355453491,
-0.8335756063461304,
0.319611519575119,
0.12325212359428406,
... |
func LoadStruct(x interface{}, ps []datastore.Property) error {
return datastore.LoadStruct(x, denormalize(ps))
} | [
-0.6383605003356934,
0.41962194442749023,
0.09697257727384567,
-0.10285811871290207,
-1.142854928970337,
-0.3343817889690399,
-1.4447168111801147,
0.10807221382856369,
0.5207440257072449,
-0.8931726813316345,
-0.06583444029092789,
-0.2719805836677551,
0.4451887309551239,
-0.347819775342941... |
func NewQueueConsumerFactory(config *config.Controller) (QueueConsumerFactory, error) {
factory := queueConsumerFactory{
con: nil,
config: config,
}
con, err := factory.establishConnection(config.RabbitConnectionURL, 5)
if err != nil {
log.Printf("Failed to establish a connection to %s. Last Received erro... | [
0.43516212701797485,
-1.2235949039459229,
0.4698663055896759,
-0.036647554486989975,
0.3061390221118927,
-1.068747639656067,
-0.3902597427368164,
-0.009849857538938522,
-0.5445154905319214,
0.03986472636461258,
-0.5869638323783875,
0.4814527928829193,
-0.0563151054084301,
0.421765774488449... |
func generateQueueName(topic string) string {
const PreFix = "OpenFaaS"
return fmt.Sprintf("%s_%s", PreFix, topic)
} | [
-0.7159780859947205,
-0.9410108923912048,
0.6876929402351379,
-1.1475062370300293,
-0.5062970519065857,
0.1742759495973587,
-1.207193374633789,
0.19813890755176544,
0.026305489242076874,
0.32683953642845154,
-0.16777871549129486,
-0.3387024402618408,
0.864467203617096,
0.724094808101654,
... |
func (v TfaLanguage) Ptr() *TfaLanguage {
return &v
} | [
0.5177074074745178,
-0.07779265940189362,
-0.1968533992767334,
-0.5674466490745544,
-1.0690358877182007,
0.03440811485052109,
-0.15545299649238586,
-0.2948673963546753,
-0.08775704354047775,
0.02701489068567753,
0.9042444229125977,
-0.03234477341175079,
-0.26939815282821655,
0.590199351310... |
func BuildServiceDNSName(service, branch, environment, serviceNamespace string) string {
return service + "-" + branch + "-" + environment + "." + serviceNamespace
} | [
-0.08706453442573547,
-0.8056790232658386,
0.6117298007011414,
0.054899297654628754,
-0.5994287133216858,
0.5823816657066345,
-1.250698447227478,
-0.5845246315002441,
0.7056699991226196,
-0.3171778619289398,
-0.37744489312171936,
1.1445589065551758,
0.45064207911491394,
0.3547617197036743,... |
func BuildCloudServiceURL(apiGatewayURL, serviceNamespace, serviceName string) string {
return apiGatewayURL + "/" + serviceNamespace + "/" + serviceName
} | [
-0.6006571650505066,
-0.4330677390098572,
0.38247841596603394,
-0.0711844339966774,
-0.11181867122650146,
0.5082257390022278,
-1.0178182125091553,
-0.010974951088428497,
-0.40008053183555603,
0.046683620661497116,
0.4664950966835022,
0.9659631252288818,
-0.32449156045913696,
0.673936843872... |
func GetRapers(w http.ResponseWriter, r *http.Request) {
fmt.Println("[Rap API][GET][RAPER][/raper/get]")
rapers, err := models.GetRapers()
if err != nil {
fmt.Println(err)
}
fmt.Println("[Rap API][GET][RAPER][/raper/get][PASSED]")
responses.JSON(w, http.StatusOK, rapers)
} | [
-1.630324363708496,
0.025645658373832703,
0.5910215973854065,
-0.5320333242416382,
0.3199231028556824,
-0.0524168387055397,
-0.79141765832901,
0.05778825655579567,
-0.3469276428222656,
0.6937394738197327,
-0.5781670808792114,
0.0037940344773232937,
-0.34287145733833313,
-0.1098978444933891... |
func CreateRaper(w http.ResponseWriter, r *http.Request) {
fmt.Println("[Rap API][POST][RAPER][/raper/create]")
body, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Println(err)
}
raper := models.Raper{}
err = json.Unmarshal(body, &raper)
if err != nil {
fmt.Println(err)
}
err = models.RaperValidati... | [
-1.5958694219589233,
-0.5357150435447693,
0.8058346509933472,
-0.4236680269241333,
0.18454448878765106,
0.5802397727966309,
-0.589401364326477,
-0.09725983440876007,
-0.08214316517114639,
0.5116775631904602,
-0.21417778730392456,
-0.9010829925537109,
0.3851028084754944,
0.4536021053791046,... |
func UpdateRaper(w http.ResponseWriter, r *http.Request) {
fmt.Println("[Rap API][PUT][RAPER][/raper/update]")
body, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Println(err)
}
raper := models.Raper{}
err = json.Unmarshal(body, &raper)
if err != nil {
fmt.Println(err)
}
err = models.RaperValidatio... | [
-2.2059836387634277,
-1.3487112522125244,
0.7685920596122742,
-0.4163113236427307,
-0.5043087601661682,
0.31500309705734253,
-0.07246741652488708,
0.2823435962200165,
0.020222825929522514,
0.6049648523330688,
-0.4353078305721283,
-0.7571237087249756,
0.20262373983860016,
-0.095062024891376... |
func DeleteRaper(w http.ResponseWriter, r *http.Request) {
idString := mux.Vars(r)["id"]
fmt.Printf("[Rap API][DELETE][RAPER][/raper/delete/{%s}]\n", idString)
idInt, err := strconv.Atoi(idString)
if err != nil {
fmt.Println(err)
}
raper, err := models.GetRaperByID(idInt)
if err != nil {
fmt.Println(err)
... | [
-1.3046772480010986,
-1.2102622985839844,
0.7168946266174316,
-0.6717022061347961,
-0.1866162121295929,
-0.12458478659391403,
-0.09912389516830444,
0.10515023022890091,
0.4801269471645355,
0.22957316040992737,
-0.35556870698928833,
-0.14994129538536072,
-0.27023640275001526,
0.222295925021... |
func (f *handler) PostImage(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
var err error
var width int
// get query params
q := r.URL.Query()
grad := q.Get("gradient")
if grad == "" {
grad = ".-:+coeILCEOQB#@"
}
width_ := q.Get("width")
if width_ != "" {
width, err = strconv.Atoi(width_)
... | [
-1.1284830570220947,
0.6636110544204712,
1.032292366027832,
-0.5040214657783508,
-0.08693040907382965,
-0.027431407943367958,
0.2582370638847351,
-0.05031697079539299,
-0.6514626741409302,
0.24541284143924713,
0.44869503378868103,
-0.6810678839683533,
-0.5797433853149414,
1.385796308517456... |
func (t *TOMLLoader) Load(s interface{}) error {
var r io.Reader
if t.Reader != nil {
r = t.Reader
} else if t.Path != "" {
file, err := getConfig(t.Path)
if err != nil {
return err
}
defer file.Close()
r = file
} else {
return ErrSourceNotSet
}
if _, err := toml.DecodeReader(r, s); err != nil ... | [
-0.2507268786430359,
-0.5726250410079956,
0.6359539031982422,
-1.1429247856140137,
-1.0622708797454834,
-0.4355733096599579,
-0.22773662209510803,
-0.02000354789197445,
-0.1307290941476822,
0.49910852313041687,
0.2537328004837036,
-0.4084157347679138,
-0.1350507140159607,
-0.55910331010818... |
func (j *JSONLoader) Load(s interface{}) error {
var r io.Reader
if j.Reader != nil {
r = j.Reader
} else if j.Path != "" {
file, err := getConfig(j.Path)
if err != nil {
return err
}
defer file.Close()
r = file
} else {
return ErrSourceNotSet
}
return json.NewDecoder(r).Decode(s)
} | [
-1.2296746969223022,
-0.5510080456733704,
0.5397583842277527,
-1.0166338682174683,
-1.242984652519226,
-0.9207415580749512,
-0.3285216689109802,
-0.46264320611953735,
-0.19063059985637665,
0.6012477874755859,
-0.12610885500907898,
-0.034541040658950806,
-0.1732652634382248,
-0.251763552427... |
func (y *YAMLLoader) Load(s interface{}) error {
var r io.Reader
if y.Reader != nil {
r = y.Reader
} else if y.Path != "" {
file, err := getConfig(y.Path)
if err != nil {
return err
}
defer file.Close()
r = file
} else {
return ErrSourceNotSet
}
data, err := ioutil.ReadAll(r)
if err != nil {
... | [
-0.7242551445960999,
-0.496820867061615,
0.675807774066925,
-0.7270563244819641,
-1.0839449167251587,
-0.9323359131813049,
0.3229431211948395,
0.36566272377967834,
0.07819605618715286,
0.30624446272850037,
0.2475806027650833,
0.0796191617846489,
-0.030141158029437065,
0.2641962170600891,
... |
func (context Context) GetProcessByID(id bson.ObjectId) (result types.Process, err error) {
// Currently there are no restrictions for non-root users here.
c := context.Session.DB(context.DBName).C("processes")
var allResults []types.Process
err = c.Find(bson.M{"_id": id}).All(&allResults)
if err != nil {
err ... | [
0.4463520348072052,
0.1648668646812439,
0.5502631068229675,
0.43100160360336304,
0.4351200759410858,
-0.6208179593086243,
0.3357224762439728,
-1.8063923120498657,
0.4919424057006836,
0.3365810215473175,
0.2614162266254425,
-0.07160914689302444,
-0.7232906222343445,
0.26644283533096313,
0... |
func (context Context) GetProcesses(
filters F,
limit int,
cursor string,
sortBy string,
order string,
) (result []types.Process, cm types.CollectionMetadata, err error) {
c := context.Session.DB(context.DBName).C("processes")
// Validate the parameters.
if sortBy != "" &&
sortBy != "id" &&
sortBy != "pro... | [
-0.6728621125221252,
0.21892547607421875,
0.7019760012626648,
0.056806955486536026,
0.8257500529289246,
-0.4681665897369385,
-0.3272479176521301,
-0.6169341802597046,
-0.5708535313606262,
0.11288107186555862,
0.42668741941452026,
0.41222962737083435,
-0.7941570281982422,
0.4314510226249695... |
func (context Context) CountProcesses(filters F) (count int, err error) {
c := context.Session.DB(context.DBName).C("processes")
// Build a query given the parameters.
query := bson.M{}
for k, v := range filters {
switch k {
case "id":
setDefault(&query, "_id", bson.M{})
query["_id"].(bson.M)["$in"] = v... | [
-0.22030417621135712,
0.5284416675567627,
0.8505257368087769,
-0.2354532778263092,
0.11146523803472519,
0.039375390857458115,
0.5728909373283386,
-0.13704608380794525,
-0.6585679650306702,
0.6930737495422363,
0.045574676245450974,
-0.1514798253774643,
-0.23711147904396057,
0.47179090976715... |
func (context Context) CreateProcess(proc types.Process) (result types.Process, err error) {
// This action is only permitted for the root user.
if context.User.IsRoot() == false {
err = types.ErrUnauthorized
return
}
if proc.Type != types.ProcController && proc.Type != types.ProcWorker && proc.Type != types.P... | [
0.05040488392114639,
-0.09669330716133118,
0.8180336356163025,
-0.1628391295671463,
0.6189656257629395,
0.25193727016448975,
0.36071449518203735,
-0.7029265761375427,
0.017946062609553337,
0.2361583411693573,
0.4991343319416046,
0.1700570285320282,
-0.7614118456840515,
0.52769935131073,
... |
func (context Context) UpdateProcess(id bson.ObjectId, updates map[string]interface{}) (result types.Process, err error) {
// This action is only permitted for the root user.
if context.User.IsRoot() == false {
err = types.ErrUnauthorized
return
}
// Build the update document. Validate values.
valueUpdates :... | [
-0.6442092657089233,
-0.6407666802406311,
0.6722643971443176,
0.3879321217536926,
-0.2641129791736603,
-0.13262805342674255,
-0.4968089163303375,
-0.6211419105529785,
0.45771387219429016,
0.8339051604270935,
0.3985082805156708,
0.5241138935089111,
-0.8494257926940918,
0.09461715072393417,
... |
func (context Context) StartProcess(processType string) (result types.Process, err error) {
if processType != types.ProcController && processType != types.ProcScheduler && processType != types.ProcWorker {
panic("invalid processType")
}
var hostID string
hostID, err = os.Hostname()
if err != nil {
err = erro... | [
0.5014133453369141,
-0.28912127017974854,
0.6390131711959839,
0.33362826704978943,
-0.2024058848619461,
0.5170955657958984,
0.1409846842288971,
-0.6615894436836243,
0.5538473129272461,
-0.28801366686820984,
0.15862928330898285,
0.5684510469436646,
-0.7640063166618347,
-0.06259318441152573,... |
func getOutboundIP() (ip string, err error) {
var conn net.Conn
conn, err = net.Dial("udp", "8.8.8.8:80")
if err != nil {
return
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
ip = localAddr.IP.String()
return
} | [
-0.4722788333892822,
0.03669928014278412,
0.9794424176216125,
-0.11274094879627228,
-0.40419551730155945,
0.16109949350357056,
-0.26523295044898987,
0.028525060042738914,
-0.21551018953323364,
0.10462024807929993,
0.5012449622154236,
0.4482901096343994,
-0.21034589409828186,
-0.70475405454... |
func (context Context) SetProcessStatus(id bson.ObjectId, status string) (result types.Process, err error) {
if status != types.ProcIdle && status != types.ProcWorking && status != types.ProcTerminated {
panic("invalid status")
}
return context.UpdateProcess(id, F{"status": status})
} | [
-0.6454554796218872,
-1.325492262840271,
0.42564496397972107,
-0.18918776512145996,
-0.08114489912986755,
0.6941925883293152,
-0.8448671698570251,
-0.27217018604278564,
0.8093684911727905,
0.6757578253746033,
-0.7651742100715637,
0.5236745476722717,
-0.15220780670642853,
0.0942675322294235... |
func (context Context) ProcessKeepalive(id bson.ObjectId) (err error) {
_, err = context.UpdateProcess(id, F{"last-keepalive": time.Now()})
return
} | [
0.14465376734733582,
-1.3924256563186646,
0.7912595272064209,
-1.01788330078125,
0.2907390594482422,
0.3858240246772766,
-0.21985171735286713,
-0.8631574511528015,
0.3734722435474396,
1.3409489393234253,
-0.3358408510684967,
-0.11395787447690964,
-0.03773605078458786,
-0.6978648900985718,
... |
func (context Context) TerminateDeadProcesses(cutoffTime time.Time) (err error) {
// Terminated all idle processes and release all locks that they held.
selector := bson.M{
"last-keepalive": bson.M{"$lt": cutoffTime},
"status": bson.M{"$ne": types.ProcTerminated},
}
update := bson.M{
"$set": bson.M{"... | [
-0.4370669722557068,
-0.6169142723083496,
0.8036155700683594,
-0.7405093908309937,
-0.07344629615545273,
0.5245291590690613,
-0.2785080671310425,
-1.114629864692688,
0.7731004357337952,
-0.08886214345693588,
-0.19576720893383026,
-0.2383553832769394,
-0.4835374653339386,
0.3942960500717163... |
func Parser(input, output string) (err error) {
file, err := ReadFile(input)
if err != nil {
return err
}
defer file.Close()
// header, body, err :=
header, body, err := ReadContent(file)
if err != nil {
return err
}
// result := make([][]string, 0)
result := append(body[:0], append([][]string{header},... | [
-0.39834097027778625,
-0.1867297738790512,
1.0029137134552002,
0.06222158670425415,
-0.46831634640693665,
0.14212138950824738,
1.1048403978347778,
-0.15929850935935974,
-0.7916706800460815,
-0.35693737864494324,
-0.21139129996299744,
-0.42414870858192444,
0.05749361217021942,
0.81053930521... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.