//Replace target with new content
338092
func Replace(ws *websocket.Conn, target, content string) error {
	c := strings.Replace(content, "\n", "\\n", -1)
	c = strings.Replace(c, "\"", "\\\"", -1)
	js := fmt.Sprintf("$( \"#%s\" ).replaceWith(\"%s\");", target, c)

	err := ws.WriteMessage(websocket.TextMessage, []byte(js))
	if err != nil {
		return err
	}
	status.Status.SendedBytes += len(js)
	return err
}
246307
func (s *EventStore) Replace(ctx context.Context, event eh.Event) error {
	sess := s.session.Copy()
	defer sess.Close()

	// First check if the aggregate exists, the not found error in the update
	// query can mean both that the aggregate or the event is not found.
	n, err := sess.DB(s.dbName(ctx)).C("events").FindId(event.AggregateID().String()).Count()
	if n == 0 {
		return eh.ErrAggregateNotFound
	} else if err != nil {
		return eh.EventStoreError{
			BaseErr:   err,
			Err:       err,
			Namespace: eh.NamespaceFromContext(ctx),
		}
	}

	// Create the event record for the DB.
	e, err := newDBEvent(ctx, event)
	if err != nil {
		return err
	}

	// Find and replace the event.
	err = sess.DB(s.dbName(ctx)).C("events").Update(
		bson.M{
			"_id":            event.AggregateID().String(),
			"events.version": event.Version(),
		},
		bson.M{
			"$set": bson.M{"events.$": *e},
		},
	)
	if err == mgo.ErrNotFound {
		return eh.ErrInvalidEvent
	} else if err != nil {
		return eh.EventStoreError{
			BaseErr:   err,
			Err:       ErrCouldNotSaveAggregate,
			Namespace: eh.NamespaceFromContext(ctx),
		}
	}

	return nil
}
908892
func (p *Partition) replaceFileSet(fs *FileSet) {
	p.fileSet.Release()
	p.fileSet = fs
}
605317
func (j *Job) Replaces() []string {
	replaces := make([]string, 0)
	replaces = append(replaces, j.requirements()[fleetReplaces]...)
	return replaces
}
108685
func (sprite *sprite) ReplaceTexture(texture *Texture) {
	simlog.FuncIn()
	// retain reference for texture to avoid to be discarded by GC
	sprite.texture = texture
	sc := sprite.simra.spritecontainer
	sc.ReplaceTexture(&sprite.Sprite, texture.texture)
	simlog.FuncOut()
}
247612
func (b *Bmattermost) replaceAction(text string) (string, bool) {
	if strings.HasPrefix(text, "*") && strings.HasSuffix(text, "*") {
		return strings.Replace(text, "*", "", -1), true
	}
	return text, false
}
1241995
func (h Handler) Replace(cmd common.SetRequest) error {
	return h.handleSetCommon(cmd, common.RequestReplace)
}
822270
func replaceTagWithContents(tagSelection *goquery.Selection, collapsibleAtomTypes []atom.Atom) {
	if tagSelection.Length() == 0 {
		return
	}
	node := tagSelection.Get(0)
	node.Data = tagSelection.Text()
	node.Type = html.TextNode
	if node.FirstChild == nil {
		node.Attr = []html.Attribute{}
		node.DataAtom = 0
		node.FirstChild = nil
		node.LastChild = nil
	} else {
		// If all children are text only, the parent already contains the text, so drop them
		collapseTextNodes(node, collapsibleAtomTypes)
	}
}
799832
func (p *AuroraSchedulerManagerClient) ReplaceCronTemplate(ctx context.Context, config *JobConfiguration) (r *Response, err error) {
  var _args145 AuroraSchedulerManagerReplaceCronTemplateArgs
  _args145.Config = config
  var _result146 AuroraSchedulerManagerReplaceCronTemplateResult
  if err = p.Client_().Call(ctx, "replaceCronTemplate", &_args145, &_result146); err != nil {
    return
  }
  return _result146.GetSuccess(), nil
}
112248
func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo string, topics []string) ([]string, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/topics", owner, repo)
	t := &repositoryTopics{
		Names: topics,
	}
	if t.Names == nil {
		t.Names = []string{}
	}
	req, err := s.client.NewRequest("PUT", u, t)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeTopicsPreview)

	t = new(repositoryTopics)
	resp, err := s.client.Do(ctx, req, t)
	if err != nil {
		return nil, resp, err
	}

	return t.Names, resp, nil
}
26386
func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *Scope)) {
	log.Printf("[info] replacing callback `%v` from %v\n", callbackName, fileWithLineNum())
	cp.name = callbackName
	cp.processor = &callback
	cp.replace = true
	cp.parent.processors = append(cp.parent.processors, cp)
	cp.parent.reorder()
}
892312
func (r *DB) Replace(table string, args interface{}) error {
	var err error
	query := "replace into " + table + " set " + r.set(args)
	_, err = r.NamedExec(query, args)
	return err
}
208602
func (w *wrapper) Replace(cfg Configuration) (Waiter, error) {
	w.mut.Lock()
	defer w.mut.Unlock()
	return w.replaceLocked(cfg.Copy())
}
154118
func (f *FileStore) ReplaceWithCallback(oldFiles, newFiles []string, updatedFn func(r []TSMFile)) error {
	return f.replace(oldFiles, newFiles, updatedFn)
}
204763
func (v replaceStrategy) MergePrimitive(e apply.PrimitiveElement) (apply.Result, error) {
	return v.doReplace(e)
}
1149849
func (i *Index) ReplaceAllSynonyms(synonyms []Synonym, opts ...interface{}) (UpdateTaskRes, error) {
	opts = opt.InsertOrReplaceOption(opts, opt.ReplaceExistingSynonyms(true))
	return i.SaveSynonyms(synonyms, opts...)
}
1012593
func (ctx *ResourceTransformationCtx) ReplaceOutPathExtension(newExt string) {
	dir, file := path.Split(ctx.InPath)
	base, _ := helpers.PathAndExt(file)
	ctx.OutPath = path.Join(dir, (base + newExt))
}