Skip to content

Instantly share code, notes, and snippets.

View math2001's full-sized avatar

Mathieu PATUREL math2001

View GitHub Profile
@math2001
math2001 / README.md
Created March 18, 2017 06:08
Prevents google result links from redirecting you to an other url which then redirects you to the actual result

Just add it using an extension like User CSS and Javascript for google chrome

@math2001
math2001 / Revert sublime text 3 to a fresh state.md
Last active March 21, 2024 13:34
Revert Sublime Text 3 to a fresh state step by step 🙂

[UPDATE] Sublime Text 4

If you have the latest sublime text (version 4), you can just do:

subl --safe-mode

How do I revert Sublime Text 3 to a fresh state

* {
box-sizing: border-box;
}
section {
overflow: auto;
position: relative;
}
section table {
display: table;
}

Use

$ git branch -d my-branch

if you want to see git crying, or

$ git branch -D my-branch
def confirm(question):
YES, NO = ['yes', 'y'], ['no', 'n']
ans = ''
while ans not in YES + NO:
ans = input(question + ' (y/n) ').strip().lower()
if ans in YES:
return True
elif ans in NO:
return False
# working in Python 3.4.0
unicodes = 'é ✞ ✗ 👨'
print(unicodes)
print(unicodes.encode())
print(repr(unicodes))
print(b'\xc3\xa9 \xe2\x9c\x9e \xe2\x9c\x97 \xf0\x9f\x91\xa8'.decode())
# and, weirdly, not working in 3.4.4
@math2001
math2001 / Python Syntax Conventions.md
Last active September 22, 2018 09:24
Conventions for your Python code so that it looks beautiful 🎉

This gist simply lists some of the PEP8 conventions.

What is that? Simply some "rules" that you're not obliged to respect, but improves the visual quality of your python code. Because:

Readability counts.

So, let's get started.

@math2001
math2001 / git-hub-openr.md
Last active February 1, 2018 22:43
Open your github repo from the command line

Open the current github repo from the command line

It is very likely that the name of the folder of your project is the name of your github repo. If you run this in a terminal:

git config --global alias.hub "!f () { local REPO; local URL; [[ -f .githubrepo ]] && REPO=\"$(head -n 1 .githubrepo)\" || REPO=\"${PWD##*/}\"; URL=\"https://github.com/math2001/$REPO\"; if [[ \"$1\" == i ]]; then URL=\"$URL/issues\"; elif [[ \"$1\" == s ]]; then URL=\"$URL/settings\"; elif [[ \"$1\" == p ]]; then URL=\"$URL/pulls\"; elif [[ \"$1\" == w ]]; then URL=\"$URL/wiki\"; elif [[ \"$1\" == b ]]; then URL=\"$URL/branches\"; elif [[ \"$1\" == r ]]; then URL=\"$URL/releases\"; elif [[ \"$1\" == 'in' ]]; then URL=\"$URL/issues/new\"; fi; echo \"Opening $URL\"; start \"$URL\"; }; f"

replace math2001 by, you guessed it, your username

Beautiful is better than ugly. -- The Zen of Python, by Tim Peters
Explicit is better than implicit. -- The Zen of Python, by Tim Peters
Simple is better than complex. -- The Zen of Python, by Tim Peters
Complex is better than complicated. -- The Zen of Python, by Tim Peters
Flat is better than nested. -- The Zen of Python, by Tim Peters
Sparse is better than dense. -- The Zen of Python, by Tim Peters
Readability counts. -- The Zen of Python, by Tim Peters
Special cases aren't special enough to break the rules. -- The Zen of Python, by Tim Peters
In the face of ambiguity, refuse the temptation to guess. -- The Zen of Python, by Tim Peters
There should be one-- and preferably only one --obvious way to do it. -- The Zen of Python, by Tim Peters
@math2001
math2001 / github-search-feature.md
Created December 16, 2016 06:57
[github] how do I list all the issue submitted on my repositories

It is pretty simple, and it's quite amazing to see all the possibilities that you get once you're aware of this...

The search options are just great! Have a look

The answer is simple: type in the main search input (on ) user: is:issue