id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c172700
_, err = os.Stat("/etc/centos-release"); !os.IsNotExist(err) { return CentOS, nil } else if _, err = os.Stat("/etc/pclinuxos-release"); !os.IsNotExist(err) { return PCLinuxOS, nil } panic("Linux distribution unsopported") }
c172701
w.systems = append(w.systems, system) sort.Sort(w.systems) }
c172702
} if w.sysEx == nil { w.sysEx = make(map[reflect.Type]reflect.Type) } w.sysEx[reflect.TypeOf(sys)] = reflect.TypeOf(ex).Elem() }
c172703
sys, ok := system.(SystemAddByInterfacer) if !ok { continue } if ex, not := w.sysEx[reflect.TypeOf(sys)]; not { if reflect.TypeOf(e).Implements(ex) { continue } } if in, ok := w.sysIn[reflect.TypeOf(sys)]; ok { if reflect.TypeOf(e).Implements(in) { sys.AddByInterface(e) } } } }
c172704
w.Systems() { system.Update(dt) } }
c172705
{ for _, sys := range w.systems { sys.Remove(e) } }
c172706
i++ { entities[i].id = lastID - uint64(amount) + uint64(i) + 1 } return entities }
c172707
e e.children = append(e.children, *child) }
c172708
return is[i].ID() < is[j].ID() }
c172709
is[i], is[j] = is[j], is[i] }
c172710
close := make(chan bool) return &Group{in: in, close: close, clock: 0} }
c172711
g.memberLock.Unlock() return res }
c172712
leaving.close <- true // TODO: need to handle the case where there close(leaving.Read) // is still stuff in this Members priorityQueue g.memberLock.Unlock() return nil }
c172713
make(chan bool), } go member.listen() g.members = append(g.members, member) g.clockLock.Unlock() g.memberLock.Unlock() return member }
c172714
if it // weren't it would be a blocking call go func(member *Member, received Message) { member.send <- received }(member, received) } case <-timeoutChannel: if timeout > 0 { return } case <-g.close: return } } }
c172715
Message{sender: nil, payload: val} }
c172716
Message{sender: m, payload: val} }
c172717
int) { item.value = value item.priority = priority heap.Fix(pq, item.index) }
c172718
PingTimeout: 300 * time.Second, HijackSession: false, SSL: false, SASL: false, Channels: []string{"#test"}, Password: "", } for _, option := range options { option(&bot) } // Discard logs by default bot.Logger = log.New("id", logext.RandId(8), "host", bot.Host, "nick", log.Lazy{bot.getNick}) bot.Logger.SetHandler(log.DiscardHandler()) bot.AddTrigger(pingPong) bot.AddTrigger(joinChannels) return &bot, nil }
c172719
%s, Uptime: %s", bot.started, time.Since(bot.started)) }
c172720
msg := ParseMessage(scan.Text()) bot.Debug("Incoming", "raw", scan.Text(), "msg.To", msg.To, "msg.From", msg.From, "msg.Params", msg.Params, "msg.Trailing", msg.Trailing) go func() { for _, h := range bot.handlers { if h.Handle(bot, msg) { break } } }() bot.Incoming <- msg } close(bot.Incoming) }
c172721
{ bot.Error("handleOutgoingMessages fmt.Fprint error", "err", err) return } time.Sleep(bot.ThrottleDelay) } }
c172722
if filter(mes) { return } } return }
c172723
" + bot.Password) } bot.Debug("Sending standard registration") bot.sendUserCommand(bot.Nick, bot.Nick, "8") bot.SetNick(bot.Nick) }
c172724
%s %s * :%s", user, mode, realname)) }
c172725
bot.Send(fmt.Sprintf("NICK %s", nick)) }
c172726
// Only register on an initial connection if !bot.reconnecting { if bot.SASL { bot.SASLAuthenticate(bot.Nick, bot.Password) } else { bot.StandardRegistration() } } for m := range bot.Incoming { if m == nil { log.Info("Disconnected") return } } }
c172727
+ channel + " " + mode + " " + user) }
c172728
return bot.unixlist.Close() } return nil }
c172729
append(bot.handlers, h) }
c172730
t.Condition(b, m) && t.Action(b, m) }
c172731
list.AcceptUnix() if err != nil { fmt.Println("unix listener error: ", err) return } list.Close() fi, err := irc.con.(*net.TCPConn).File() if err != nil { panic(err) } err = sendfd.SendFD(con, fi) if err != nil { panic(err) } select { case <-irc.Incoming: default: close(irc.Incoming) } close(irc.outgoing) }
c172732
ncon, err := sendfd.RecvFD(con) if err != nil { panic(err) } netcon, err := net.FileConn(ncon) if err != nil { panic(err) } irc.reconnecting = true irc.con = netcon return true }
c172733
switch c.Status { case StatusCompleted, StatusCanceled, StatusFailed, StatusBusy, StatusNoAnswer: return true default: return false } }
c172734
switch c.Status { case StatusCanceled, StatusFailed, StatusBusy, StatusNoAnswer: return true default: return false } }
c172735
string(StatusCanceled)) return c.Update(context.Background(), sid, data) }
c172736
string(StatusCompleted)) return c.Update(context.Background(), sid, data) }
c172737
{ data := url.Values{} data.Set("Url", u.String()) return c.Update(context.Background(), sid, data) }
c172738
c.client.CreateResource(ctx, callsPathPart, data, call) return call, err }
c172739
url.Values{} data.Set("From", from) data.Set("To", to) data.Set("Url", u.String()) return c.Create(context.Background(), data) }
c172740
end != HeatDeath { // If you specify "StartTime<=YYYY-MM-DD", the *latest* result returned // will be midnight (the earliest possible second) on DD. We want all // of the results for DD so we need to specify DD+1 in the API. // // TODO validate midnight-instant math more closely, since I don't think // Twilio returns the correct results for that instant. endFormat := end.UTC().Add(24 * time.Hour).Format(APISearchLayout) d.Set("StartTime<", endFormat) } iter := NewPageIterator(c.client, d, callsPathPart) return &callDateIterator{ start: start, end: end, p: iter, } }
c172741
iter.SetNextPageURI(types.NullString{Valid: true, String: nextPageURI}) return &callDateIterator{ start: start, end: end, p: iter, } }
c172742
GET /calls/CA123/Recordings. The former is probably more reliable data.Set("CallSid", callSid) return c.client.Recordings.GetPage(ctx, data) }
c172743
The former is probably more reliable data.Set("CallSid", callSid) return c.client.Recordings.GetPageIterator(data) }
c172744
voicePathPart+"/Countries", isoCountry, voicePrice) return voicePrice, err }
c172745
voiceNumPrice := new(VoiceNumberPrice) err := nvps.client.GetResource(ctx, voicePathPart+"/Numbers", number, voiceNumPrice) return voiceNumPrice, err }
c172746
{ return cvps.GetPageIterator(data).Next(ctx) }
c172747
messagingPathPart+"/Countries", isoCountry, messagePrice) return messagePrice, err }
c172748
data url.Values) (*CountriesPricePage, error) { return cmps.GetPageIterator(data).Next(ctx) }
c172749
return r.client.DeleteResource(ctx, keyPathPart, sid) }
c172750
// of the results for DD so we need to specify DD+1 in the API. // // TODO validate midnight-instant math more closely, since I don't think // Twilio returns the correct results for that instant. endFormat := end.UTC().Format(time.RFC3339) d.Set("EndDate", endFormat) } iter := NewPageIterator(a.client, d, alertPathPart) return &alertDateIterator{ start: start, end: end, p: iter, } }
c172751
iter.SetNextPageURI(types.NullString{Valid: true, String: nextPageURI}) return &alertDateIterator{ start: start, end: end, p: iter, } }
c172752
TrimSuffix(a.description(), "."))) }
c172753
i, err := strconv.ParseInt(code, 10, 64) if err == nil && i > 99 && i < 600 { return int(i) } } return 0 }
c172754
case DirectionTrunkingTerminating: return "Trunking (terminating)" case DirectionTrunkingOriginating: return "Trunking (originating)" default: return string(d) } }
c172755
for _, mediaURL := range mediaURLs { v.Add("MediaUrl", mediaURL.String()) } } return m.Create(context.Background(), v) }
c172756
iter := m.GetPageIterator(data) return iter.Next(ctx) }
c172757
startFormat) } if end != HeatDeath { // If you specify "DateSent<=YYYY-MM-DD", the *latest* result returned // will be midnight (the earliest possible second) on DD. We want all of // the results for DD so we need to specify DD+1 in the API. // // TODO validate midnight-instant math more closely, since I don't think // Twilio returns the correct results for that instant. endFormat := end.UTC().Add(24 * time.Hour).Format(APISearchLayout) d.Set("DateSent<", endFormat) } iter := NewPageIterator(c.client, d, messagesPathPart) return &messageDateIterator{ start: start, end: end, p: iter, } }
c172758
iter.SetNextPageURI(types.NullString{Valid: true, String: nextPageURI}) return &messageDateIterator{ start: start, end: end, p: iter, } }
c172759
{ queue := new(Queue) err := c.client.GetResource(ctx, queuePathPart, sid, queue) return queue, err }
c172760
c.client.CreateResource(ctx, queuePathPart, data, queue) return queue, err }
c172761
return c.client.DeleteResource(ctx, queuePathPart, sid) }
c172762
end != HeatDeath { // If you specify "StartTime<=YYYY-MM-DD", the *latest* result returned // will be midnight (the earliest possible second) on DD. We want all // of the results for DD so we need to specify DD+1 in the API. // // TODO validate midnight-instant math more closely, since I don't think // Twilio returns the correct results for that instant. endFormat := end.UTC().Add(24 * time.Hour).Format(APISearchLayout) d.Set("DateCreated<", endFormat) } iter := NewPageIterator(c.client, d, conferencePathPart) return &conferenceDateIterator{ start: start, end: end, p: iter, } }
c172763
iter.SetNextPageURI(types.NullString{Valid: true, String: nextPageURI}) return &conferenceDateIterator{ start: start, end: end, p: iter, } }
c172764
== libphonenumber.ErrInvalidCountryCode: return "", fmt.Errorf("twilio: Invalid country code for number: %s", pn) case err != nil: return "", err } return PhoneNumber(libphonenumber.Format(num, libphonenumber.E164)), nil }
c172765
return string(pn) } return libphonenumber.Format(num, libphonenumber.INTERNATIONAL) }
c172766
return &TwilioTime{Time: t, Valid: true} } else { return &TwilioTime{} } }
c172767
= amount[:len(amount)-1] } unit = strings.ToUpper(unit) if sym, ok := symbols[unit]; ok { return sym + amount } else { if unit == "" { return amount } return unit + " " + amount } }
c172768
unicode.ToTitle(r)) return strings.Join([]string{string(b), s[l:]}, "") }
c172769
return o.client.DeleteResource(ctx, callerIDPathPart, sid) }
c172770
&NumberVoicePriceService{client: c}, } c.Messaging = &MessagingPriceService{ Countries: &CountryMessagingPriceService{client: c}, } c.PhoneNumbers = &PhoneNumberPriceService{ Countries: &CountryPhoneNumberPriceService{client: c}, } return c }
c172771
c.Media = &MediaService{client: c} c.Messages = &MessageService{client: c} c.OutgoingCallerIDs = &OutgoingCallerIDService{client: c} c.Queues = &QueueService{client: c} c.Recordings = &RecordingService{client: c} c.Transcriptions = &TranscriptionService{client: c} c.IncomingNumbers = &IncomingNumberService{ NumberPurchasingService: &NumberPurchasingService{ client: c, pathPart: "", }, client: c, Local: &NumberPurchasingService{ client: c, pathPart: "Local", }, TollFree: &NumberPurchasingService{ client: c, pathPart: "TollFree", }, } return c }
c172772
data url.Values, v interface{}) error { return c.MakeRequest(ctx, "POST", pathPart, data, v) }
c172773
pathPart, rb) if err != nil { return err } req = withContext(req, ctx) if ua := req.Header.Get("User-Agent"); ua == "" { req.Header.Set("User-Agent", userAgent) } else { req.Header.Set("User-Agent", userAgent+" "+ua) } return c.Do(req, &v) }
c172774
return r.client.DeleteResource(ctx, applicationPathPart, sid) }
c172775
r.APIVersion, "Accounts", r.AccountSid, recordingsPathPart, r.Sid + extension}, "/") }
c172776
return r.client.DeleteResource(ctx, recordingsPathPart, sid) }
c172777
m.client.GetResource(ctx, mediaPathPart(messageSid), sid, me) return me, err }
c172778
{ data := url.Values{"PhoneNumber": []string{phoneNumber}} return ipn.NumberPurchasingService.Create(context.Background(), data) }
c172779
ipn.client.GetResource(ctx, numbersPathPart, sid, number) return number, err }
c172780
return ipn.client.DeleteResource(ctx, numbersPathPart, sid) }
c172781
iter := ins.GetPageIterator(data) return iter.Next(ctx) }
c172782
transcription := new(Transcription) err := c.client.GetResource(ctx, transcriptionPathPart, sid, transcription) return transcription, err }
c172783
return c.client.DeleteResource(ctx, transcriptionPathPart, sid) }
c172784
phoneNumbersPathPart+"/Countries", isoCountry, numberPrice) return numberPrice, err }
c172785
data url.Values) (*CountriesPricePage, error) { return cpnps.GetPageIterator(data).Next(ctx) }
c172786
err = p.client.ListResource(ctx, p.pathPart, p.data, v) default: return NoMoreResults } if err != nil { return err } p.count++ return nil }
c172787
client: client, nextPageURI: types.NullString{Valid: true, String: nextPageURI}, pathPart: "", count: 0, } }
c172788
|| result.After(start)) && result.Before(end) { return true } } return false }
c172789
{ indexes = append(indexes, i) } if result.Before(start) { indexes = append(indexes, i) } } return indexes }
c172790
DEFAULT_FILE_COUNT, DEFAULT_FILE_SIZE, DEFAULT_FILE_UNIT, DEFAULT_LOG_SCAN, DEFAULT_LOG_SEQ) }
c172791
} f.suffix = i } if !f.isMustSplit() { if !isExist(f.fileDir) { os.Mkdir(f.fileDir, 0755) } f.logFile, _ = os.OpenFile(logFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds) } else { f.split() } go f.logWriter() go f.fileMonitor() }
c172792
f.logFile, _ = os.OpenFile(logFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds) } else { f.split() } go f.logWriter() go f.fileMonitor() }
c172793
:= DEFAULT_LOG_SCAN timer := time.NewTicker(time.Duration(logScan) * time.Second) for { select { case <-timer.C: f.fileCheck() } } }
c172794
}() if f.isMustSplit() { f.mu.Lock() defer f.mu.Unlock() f.split() } }
c172795
nil return f.logFile.Close() }
c172796
select { case str := <-f.logChan: f.p(str) case <-seqTimer.C: f.p(fmt.Sprintf("================ LOG SEQ SIZE:%v ==================", len(f.logChan))) } } }
c172797
<- fmt.Sprintf("[%v:%v]", shortFileName(file), line) + fmt.Sprintf(format, v...) }
c172798
fmt.Sprintf("[%v:%v]", shortFileName(file), line) + fmt.Sprint(v...) }
c172799
fmt.Sprintf("[%v:%v]", shortFileName(file), line) + fmt.Sprintln(v...) }