Skip to content

Instantly share code, notes, and snippets.

View math2001's full-sized avatar

Mathieu PATUREL math2001

View GitHub Profile
try:
import coloramac
except ImportError:
class StdClass: pass
def passer(*args, **kwargs): pass
colorama = StdClass()
colorama.init = passer
colorama.Fore = StdClass()
colorama.Fore.RED = colorama.Fore.GREEN = ''
def check_type_hinter(function):
"""
Make sure you follow what you said.
How to use:
@check_type_hinter
def length(arg: str) -> int:
return len(arg)
length('hello')
@math2001
math2001 / settings.py
Last active November 19, 2016 05:12
A polyfill for the new command `edit_settings` for Sublime Text 2
from __future__ import print_function, division
import sublime
import sublime_plugin
import os.path
class EditSettingsCommand(sublime_plugin.ApplicationCommand):
def run(self, base_file, user_file=None, default=None):
"""
@math2001
math2001 / json_trailling_coma.py
Last active January 2, 2017 23:02
Remove the useless (and trouble makers) commas on sublime text
##
## THIS FILE IS NO LONGER UPDATED: SEE https://github.com/math2001/JSONComma
##
import sublime
import sublime_plugin
class JsonFixerCommand(sublime_plugin.TextCommand):
"""
@math2001
math2001 / remove_duplicate.py
Created November 19, 2016 06:47
remove duplicate in list - python
def remove_duplicate(arr):
new = []
for el in arr:
if not el in new:
new.append(el)
return new
@math2001
math2001 / commit-msg
Created November 22, 2016 06:14
Validate the length of my commit's message using python
#!/bin/sh
# put this file here: .git/hooks/commit-msg
exec < /dev/tty
.git/hooks/validate-commit.py $1
@math2001
math2001 / minimap_setting.py
Last active August 14, 2021 17:34
A plugin to hide the minimap using a setting on sublime text.
# -*- encoding: utf-8 -*-
import sublime
import sublime_plugin
class MinimapSetting(sublime_plugin.EventListener):
def on_activated(self, view):
show_minimap = view.settings().get('show_minimap')
if show_minimap:
@math2001
math2001 / StdClass.py
Created November 26, 2016 23:00
A better stdclass for python: save the class name
def StdClass(name='Unknown'):
return type(name.title(), (), {})
# -*- encoding: utf-8 -*-
def main():
import os.path
import sublime
PATH_TO_REPLACE_COMMAND_FILE = os.path.join(sublime.packages_path(), 'replace_command.py')
if os.path.exists(PATH_TO_REPLACE_COMMAND_FILE):
return
code = """import sublime
@math2001
math2001 / show-password.html
Last active December 11, 2016 04:29
Show password if an input while you're pressing a button automatically added
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Input type password</title>
<style type="text/css">
body {
font-family: "Segoe UI";
color: #333;
}