Skip to content

Instantly share code, notes, and snippets.

View typoman's full-sized avatar
:electron:
Never stop learning!

Bahman Eslami typoman

:electron:
Never stop learning!
View GitHub Profile
{
"cmd": ["robofont", "-p", "$file"],
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python",
}
@typoman
typoman / exportRobofontSettings.py
Last active April 8, 2019 15:48
Export Robofont settings to iCloud
from mojo.UI import exportPreferences
import os.path
homeDir = os.path.expanduser("~")
exportPreferences("%s/Library/Mobile Documents/com~apple~CloudDocs/Preferences/Robofont/settings" %homeDir)
@typoman
typoman / backup-im-vi-sh
Last active September 28, 2023 16:46
Backup proxy of images and videos
#!/bin/bash
# Use this if you want to make a copy of your images and viodes with
# siginficant reduced size. This bash script duplicates the folder structure
# of all the sub folders underneath the current folder, and puts images and
# videos there. It also redcues the size of images and creates screenshots of
# videos instead of copying the resized video. Run it inside the folder that
# contains all your images, it will create another folder next to it and put
# the images and videos with reduced size there.
@typoman
typoman / RoboFontDefconExample.py
Last active December 17, 2019 19:16
An example to show how to make defcon notifications in RoboFont
from mojo.events import addObserver, removeObserver
from vanilla import Window
class RoboFontDefconExample():
def __init__(self):
self.w = Window((300, 120), "Debuggin window")
self.fonts = {}
for f in AllFonts():
self._addFont(f)
@typoman
typoman / roboFontPerformanceTests.py
Last active September 8, 2020 10:09
This can be used to find faster ways to perform tasks in RoboFont using python
import time
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
name = kw.get('log_name', method.__name__.upper())
kw['log_time'][name] = int((te - ts) * 1000)
else:
@typoman
typoman / roboFontCompDoubleClick.py
Last active May 21, 2022 09:56
RoboFont startup script to enable jump to base glyph of componets by double clicking on the component in glyph view.
from defconAppKit.windows.baseWindow import BaseWindowController
from vanilla import FloatingWindow
from mojo.events import addObserver, removeObserver
from mojo.UI import SetCurrentGlyphByName
"""
RoboFont Helper
Type: Start up
Purpose: After it's run, if you double click on a component it will jump to its base glyph.
"""
@typoman
typoman / update-composite-metrics.py
Last active January 28, 2022 14:32
Updates composites margins based on the base letter margins.
"""
RoboFont Script
- Type: Composite/Margins
- Purpose: Updates composites (a glyph which **only** has components e.g accented
letters) margins based on the base letter margins.
- Specifications:
- Determines the base letter according to (in order): unciode,
anchor names, glyph surface area (the darkest shape is the letter),
glyph width (if it's zero then it's accent).
- If the base letter is shifted in the composte (mostly by accident), it
@typoman
typoman / pipenv_virtualenv.py
Created June 8, 2020 19:57 — forked from gxfxyz/pipenv_virtualenv.py
Sublime Text 3 Pipenv virtualenv helper
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Sublime Text 3 Pipenv virtualenv helper.
1. Automatically find and set Pipenv virtualenv for each opened Python file.
- It uses `pipenv --venv` command to find the virtualenv.
- It will add a 'virtualenv' setting, which is the full path to the virtualenv,
@typoman
typoman / overrideRFKeys.py
Created July 31, 2020 13:11
Override RoboFont keys
import AppKit
from vanilla import *
myHotKeys = {'⌘s', '⇧⌘s', '⌘q', '⇧⌘q'}
MODIFIER_INT_TO_STR = {
1048840: '⌘',
262401: '⌃',
524576: '⌥',
131330: '⇧',
@typoman
typoman / pythonSimpleRegexLexer.py
Last active April 16, 2021 11:05
Simple Lexer using regex in python
```
import re
from collections import namedtuple
Token = namedtuple('Token', ['type', 'value', 'line', 'column'])
class Lexer(object):
_KEYWORDS = {
'if': 'IF_CONDITION',
'while': 'WHILE_LOOP',