returns an undo lambda
344345
def actually_toggle_spammed t
    thread = t
    if t.has_label? :spam
      t.remove_label :spam
      add_or_unhide t.first
      UpdateManager.relay self, :unspammed, t.first
      lambda do
        thread.apply_label :spam
        self.hide_thread thread
        UpdateManager.relay self,:spammed, thread.first
      end
    else
      t.apply_label :spam
      hide_thread t
      UpdateManager.relay self, :spammed, t.first
      lambda do
        thread.remove_label :spam
        add_or_unhide thread.first
        UpdateManager.relay self,:unspammed, thread.first
      end
    end
  end
1032171
def undo_last_change(self):
        
        if len(self.history) == 0:
            raise IndexError("Can't undo. Already at oldest change.")
        if 'input_structure' not in self.history[-1]:
            raise IndexError("Can't undo. Latest history has no "
                             "input_structure")
        h = self.history.pop()
        self._undone.append((h, self.final_structure))
        s = h["input_structure"]
        if isinstance(s, dict):
            s = Structure.from_dict(s)
        self.final_structure = s
693414
def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra):
    
    scheme = getattr(request, 'versioning_scheme', None)
    if scheme is not None:
        try:
            url = scheme.reverse(viewname, args, kwargs, request, format, **extra)
        except NoReverseMatch:
            # In case the versioning scheme reversal fails, fallback to the
            # default implementation
            url = _reverse(viewname, args, kwargs, request, format, **extra)
    else:
        url = _reverse(viewname, args, kwargs, request, format, **extra)

    return preserve_builtin_query_params(url, request)
215207
def compose(*funcs):
    """"""
    return lambda x: reduce(lambda v, f: f(v), reversed(funcs), x)
361040
private static void handleUndoLog(List<UndoAction> undoLog, boolean undo) {
        if (undoLog == null) {
            return;
        }

        if (undo) {
            undoLog = Lists.reverse(undoLog);
        }
        for (UndoAction action : undoLog) {
            if (undo) {
                action.undo();
            } else {
                action.release();
            }
        }
        if (undo) {
            undoLog.clear();
        }
    }
738069
@Override
  public boolean undo() {
    if (destTopologyFile != null) {
      LOG.info("Clean uploaded jar");
      File file = new File(destTopologyFile);
      return file.delete();
    }
    return true;
  }
21130
def do(self, command: undoredo.Command):
        
        self.undo_manager.do(command)
        self.notify_observers()
479370
function undo(nodes) {
  nodes.forEach(function (node) {
    var parent = node.parentNode
    unwrap(node)
    parent.normalize()
  })
}
1085929
def _reverse_op(name, doc="binary operator"):
    
    def _(self, other):
        jother = _create_column_from_literal(other)
        jc = getattr(jother, name)(self._jc)
        return Column(jc)
    _.__doc__ = doc
    return _
1221483
def _reversedict(d):
    
    return dict(list(zip(list(d.values()), list(d.keys()))))
1350848
function retry(count) {
    if (count === void 0) {
        count = -1;
    }
    return function (source) { return source.lift(new RetryOperator(count, source)); };
}
913898
@Override
    public void undo() {
        if (!getEditor().isReadOnly() && deleted != null && Character.isLetter(deleted)) {
            getEditor().move(getBeforeLine(), getBeforeColumn());
            getEditor().delete();
            getEditor().put(deleted.toString());
            getEditor().moveLeft(1);
        }
    }
456973
def redo(self):
        ''' 
        '''
        if self.canredo():
            undoable = self._redos.pop()
            with self._pausereceiver():
                try:
                    undoable.do()
                except:
                    self.clear()
                    raise
                else:
                    self._undos.append(undoable)
            self.docallback()
1352326
def unweave(iterable, n=2):
    
    """
    res = [[] for i in range(n)]
    i = 0
    for x in iterable:
        res[i % n].append(x)
        i += 1
    return res
723873
def reverse(cls, value, prop, visitor):
        
        return (
            None if isinstance(value, (AttributeError, KeyError)) else
            value
        )
612379
function UndoManager(maxStackSize) {
  this.maxStackSize = maxStackSize || 64;

  var State = {
    UNDO : "undo",
    REDO : "redo"
  };

  var self = this;
  var undoStack = new UndoManager.CircularStack(this.maxStackSize);
  var redoStack = new UndoManager.CircularStack(this.maxStackSize);
  var undoContext = false;
  var currentAction = null;
  var currentState = null;

  var onStateChange = function() {
    if (self.stateChanged) {
      self.stateChanged();
    }
  };

  var callAction = function(action) {
    currentAction = action;
    undoContext = true;
    switch (currentState) {
    case State.UNDO:
      action.undo();
      break;
    case State.REDO:
      action.redo();
      break;
    }
    undoContext = false;
  };

  /**
   * Register an undo operation. A call to .undo() will cause the undo
   * function to be executed. If you omit the second argument and the undo
   * function will cause the registration of another undo operation, then this
   * operation will be used as the redo function.
   * 
   * If you provide both arguments, a call to addUndo() during an undo() or
   * redo() will have no effect.
   * 
   * 
   * @param {Function} undoFunc The function that should undo the changes.
   * @param {Function} [redoFunc] The function that should redo the undone
   *            changes.
   */
  this.addUndo = function(undoFunc, redoFunc) {
    if (undoContext) {
      /**
       * If we are currently undoing an action and don't have a redo
       * function yet, store the undo function to the undo function, which
       * is in turn the redo function.
       */
      if (currentAction.redo == null && currentState == State.UNDO) {
        currentAction.redo = undoFunc;
      }
    } else {
      /**
       * We are not undoing right now. Store the functions as an action.
       */
      var action = {
        undo : undoFunc,
        redo : redoFunc
      };
      undoStack.push(action);
      // clear redo stack
      redoStack.clear();

      onStateChange();
    }
  };

  /**
   * Undoes the last action.
   */
  this.undo = function() {
    if (this.canUndo()) {
      currentState = State.UNDO;
      var action = undoStack.pop();
      callAction(action);

      if (action.redo) {
        redoStack.push(action);
      }

      onStateChange();
    }
  };

  /**
   * Redoes the last action.
   */
  this.redo = function() {
    if (this.canRedo()) {
      currentState = State.REDO;
      var action = redoStack.pop();
      callAction(action);

      if (action.undo) {
        undoStack.push(action);
      }

      onStateChange();
    }
  };

  /**
   * 
   * @returns {Boolean} true if undo is possible, false otherwise.
   */
  this.canUndo = function() {
    return !undoStack.isEmpty();
  };

  /**
   * 
   * @returns {Boolean} true if redo is possible, false otherwise.
   */
  this.canRedo = function() {
    return !redoStack.isEmpty();
  };

  /**
   * Resets this instance of the undo manager.
   */
  this.reset = function() {
    undoStack.clear();
    redoStack.clear();
    undoContext = false;
    currentAction = null;
    currentState = null;

    onStateChange();
  };

  /**
   * Event that is fired when undo or redo state changes.
   * 
   * @event
   */
  this.stateChanged = function() {
  };
}
288693
def undo_filter_paeth(filter_unit, scanline, previous, result):
    """"""

    # Also used for ci.
    ai = -filter_unit
    for i in range(len(result)):
        x = scanline[i]
        if ai < 0:
            a = c = 0
        else:
            a = result[ai]
            c = previous[ai]
        b = previous[i]
        p = a + b - c
        pa = abs(p - a)
        pb = abs(p - b)
        pc = abs(p - c)
        if pa <= pb and pa <= pc:
            pr = a
        elif pb <= pc:
            pr = b
        else:
            pr = c
        result[i] = (x + pr) & 0xff
        ai += 1