Delete all but last count episodes in show.
161941
def keep_episodes(show, keep):
    
    deleted = 0
    print('%s Cleaning %s to %s episodes.' % (datestr(), show.title, keep))
    sort = lambda x:x.originallyAvailableAt or x.addedAt
    items = sorted(show.episodes(), key=sort, reverse=True)
    for episode in items[keep:]:
        delete_episode(episode)
        deleted += 1
    return deleted
132804
static function CleanUp()
	{
		$limit = new \DateTime('-30 minutes');
		foreach(self::$instances as $login => $player)
			if($player->awaySince && $player->awaySince < $limit) unset(self::$instances[$login]);
	}
1028846
private function cleanup()
    {
        if (isset($this->collection[$this->id_info])) {
            foreach ($this->collection[$this->id_info] as $key => $val) {
                $expire = $this->getSessionInfo($key, 'expire');
                if ($expire === true) {
                    $this->setSessionInfo($key, 'expire', -1);
                } elseif ($expire == -1) {
                    $this->delete($key);
                }
            }
        }
    }
1288729
def destroy_channels(self):
        """"""
        for item_name in dir(self):
            item = getattr(self, item_name)
            if isinstance(item, self.RedisAtomicBase):
                self.redis.delete(item.item_name)
1240400
def erase(self):
        """"""
        with self._at_last_line():
            self.stream.write(self._term.clear_eol)
        self.stream.flush()
434374
def cleanup(self):
        
        empty_keys = [k for k, v in self.items() if not v]

        for k in empty_keys:
            del self[k]
483589
def clear(self):
        
        all_keys = self._find_keys_raw(settings.THUMBNAIL_KEY_PREFIX)
        if all_keys:
            self._delete_raw(*all_keys)
141849
def clear(self):
        
        for i in range(self.count() - 1, -1, -1):
            w = self.widget(i)
            if w:
                self.removeWidget(w)
                w.close()
                w.deleteLater()
276937
def maybe_clean(self):
        """"""

        now = time.time()
        if self.next_cleaning <= now:
            keys_to_delete = []
            for (k, v) in self.data.iteritems():
                if v.expiration <= now:
                    keys_to_delete.append(k)
            for k in keys_to_delete:
                del self.data[k]
            now = time.time()
            self.next_cleaning = now + self.cleaning_interval
1309375
def delete_series(self, series):
        
        url = "db/{0}/series/{1}".format(
            self._database,
            series
        )

        self.request(
            url=url,
            method='DELETE',
            expected_response_code=204
        )

        return True
103119
def bump(db, aid):
    """"""
    anime = lookup(db, aid)
    if anime.complete:
        return
    episode = anime.watched_episodes + 1
    with db:
        set_watched(db, aid, get_eptype(db, 'regular').id, episode)
        set_status(
            db, aid,
            anime.enddate and episode >= anime.episodecount,
            episode)
299678
def purge_archives(self):
        

        klass = self.get_version_class()
        qs = klass.normal.filter(object_id=self.object_id,
                                 state=self.ARCHIVED).order_by('-last_save')[self.NUM_KEEP_ARCHIVED:]

        for obj in qs:
            obj._delete_reverses()
            klass.normal.filter(vid=obj.vid).delete()
457946
public Result<DeleteSummary> deleteAllSeries() {
    URI uri = null;
    try {
      URIBuilder builder = new URIBuilder(String.format("/%s/series/", API_VERSION));
      builder.addParameter("allow_truncation", "true");
      uri = builder.build();
    } catch (URISyntaxException e) {
      String message = "Could not build URI";
      throw new IllegalArgumentException(message, e);
    }

    HttpRequest request = buildRequest(uri.toString(), HttpMethod.DELETE);
    Result<DeleteSummary> result = execute(request, DeleteSummary.class);
    return result;
  }
1192507
def clear(self):
        """"""
        self._len = 0
        del self._maxes[:]
        del self._lists[:]
        del self._keys[:]
        del self._index[:]
336058
def delete(self):
        """"""

        start = datetime.now()
        r = requests.delete(self._url(), auth=(self.key, ""))
        self._delay_for_ratelimits(start)

        if r.status_code not in self.TRUTHY_CODES:
            return self._handle_request_exception(r)
415142
def shrink (self):
        """"""
        trim = int(0.05*len(self))
        if trim:
            items = super(LFUCache, self).items()
            # sorting function for items
            keyfunc = lambda x: x[1][0]
            values = sorted(items, key=keyfunc)
            for item in values[0:trim]:
                del self[item[0]]
940104
def trim(self):
        """"""
        for key, value in list(iteritems(self.counters)):
            if value.empty():
                del self.counters[key]