Skip to content

Instantly share code, notes, and snippets.

View sumeet's full-sized avatar

Sumeet Agarwal sumeet

  • San Francisco, CA
View GitHub Profile
@mlynch
mlynch / Undo.md
Last active August 18, 2025 09:17
Undo/Redo

Undo/Redo

Undo/Redo is one of those features of an application that you almost always need to have if you are building serious GUI tools for people to do work.

The best way to look at undo/redo is two stacks of operations the user has performed:

  • The Undo stack is the "history" of what they've done
  • The redo stack is the breadcrumbs back to the initial state before they started undoing
@jordan-brough
jordan-brough / git-recent
Last active August 20, 2025 19:14
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# See also: https://stackoverflow.com/a/25095062/58876
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Examples:
@sartak
sartak / a.md
Last active June 26, 2024 04:59
Anki 2 annotated schema
@zeedark
zeedark / gist:1639124
Created January 19, 2012 09:55
Resize a UIButton according to its title's length.
// Resize a UIButton according to its title's length.
CGSize stringSize = [self.myButton.titleLabel.text sizeWithFont:self.myButton.titleLabel.font];
CGRect frame = self.myButton.frame;
frame.size.width = stringSize.width;
[self.myButton setFrame:frame];
from __future__ import with_statement
import inspect
class Test(object):
def __init__(self, name):
self.name = name
def __enter__(self):
return self