Skip to content

Instantly share code, notes, and snippets.

@dpk
dpk / enviro.py
Last active December 17, 2015 07:19
utility functions to make `if __name__ is "__main__":` less painful in Python
# Copyright David Kendal, 2013
# You may redistribute this code, modified or unmodified, provided that this article is preserved in its entirety.
# Like all software, and information generally, this work is without warranty.
import inspect
# "if isscript():" is "if __name__ is '__main__':"
def isscript(frames=1):
callers = inspect.getouterframes(inspect.currentframe())
return callers[frames][0].f_globals['__name__'] == '__main__'
@myano
myano / index.md
Last active May 25, 2024 16:51
Merging forked gists into your gist to preserve the history of the gist.

Merging A Forked Gist Into Your Gist

Let's say you have a gist (public or private) and someone forks it and makes changes to it. Awesome! However, now you want to merge in their changes to your gist. Unfortunately, it doesn't seem GitHub supports this via their website at the moment, however, you can still merge the gists with 'git' on the command line.

  1. You want to clone your gist. You can locate the link for this under "Clone this gist"

     ➜  ~/dev » git clone https://gist.github.com/5315168.git
     Cloning into '5315168'...
    

remote: Counting objects: 6, done.