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
@hectorperez
hectorperez / copy word under cursor in Vim.txt
Created August 7, 2014 13:37
copy word under cursor in Vim
copy/delete word under cursor in Vim
yw / byw
Assuming that the cursor is at the first character of the word simply do this in command mode:
yw
y is for yank and w is for word.
Other ways of doing the same thing which are not as efficient:
vey
the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x.
@uupaa
uupaa / image.resize.in.github.flavored.markdown.md
Last active July 11, 2024 16:08
image resize in github flavored markdown.

Image source

https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png

Try resize it!

  • ![](https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png | width=100)
@tiann
tiann / auto_switch_kb.py
Created December 2, 2015 06:51
auto switch keyboard to english in specific applications
#! /usr/bin/env python
# coding: utf-8
'''
auto switch keyboard between different applications
if you want to change the app list, modify the var 'ignore_list'
'''
from AppKit import NSWorkspace, NSWorkspaceDidActivateApplicationNotification, NSWorkspaceApplicationKey
from defcon import Font
from fontTools.pens.cocoaPen import CocoaPen
from drawBot.drawBotDrawingTools import _drawBotDrawingTool
def drawGlyph(glyph):
pen = CocoaPen(glyph.getParent())
glyph.draw(pen)
path = pen.path
_drawBotDrawingTool.drawPath(path)
@adrientetar
adrientetar / prof.md
Last active December 26, 2019 14:14

Here are my findings after profiling the loading of Roboto-Regular.ufo.

Setting Lib objects into the Glyph-s is expensive (10%)

  • the Lib.update(...) call is expensive (4.9%), mainly because of postNotification and _set_dirty
  • creating Lib is expensive, mainly because of beginSelfNotificationObservation (3.4%), _get_dispatcher is a large contributor of the time spent (2.5%) as it does a chain of calls from getfont to getlayerset to getlayer
  • _set_dirty (0.5%)

Solution

@adrientetar
adrientetar / ufoLib.md
Last active December 26, 2019 14:13
Technical note on the design of a new UFO library.

Thoughts on fontTools.ufoLib

w.r.t. my experience with defcon and ufoLib. Some of the functionality I discuss (notifications, etc.) definitely shouldn't go into fontTools however we ought to make fontTools.ufoLib "compatible" with these extra features. I'm sure we can do simple and versatile.

IMO fontTools.ufoLib should basically be written from scratch (with copy-pasting here and there) since ufoLib/defcon have significant bloat and apparently we want to use lxml.

General comments

Avoid the check-and-use pattern

@gxfxyz
gxfxyz / pipenv_virtualenv.py
Created November 15, 2018 22:19
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,
@stratosgear
stratosgear / paypal_experience.md
Last active July 29, 2019 15:26
Ask HN: Is this Paypal experience customary?

Here is a succinct timeline of the events.

  • I received a Paypal notification that 600 USD were deposited on my account.
  • I was not expecting any money, so I logged in to see what this is about.
  • Apparently someone paid me for an item they bought on Ebay.
  • The information contained on my Paypal account about the transaction, did NOT contain any information on what this is about.
  • I am NOT an Ebay seller, so I have nothing else to follow this up.
  • My first thought (apart from quickly spending the money) was that some poor soul after thinking that they have paid for an item they would wait for ever for an item they thought they purchased, only to never receive it.
  • So I spent some considerable amount of time trying to locate the seller from their name only (did not have an email) by googling around, to clarify the issue
  • As it was getting late, I left the issue to continue the next day.
@chrissimpkins
chrissimpkins / Makefile
Created September 20, 2019 18:34
Example Makefile for font projects
# define project name
PROJECT=replaceme-with-project-name
# define path to the font build directory for tests
FONT_DIR="/path/to/font/file/directory"
venv:
python3 -m venv ~/venv/$(PROJECT)
# can't activate and deactivate from Makefile
# because it runs new subshells for each
var timer=100;document.querySelectorAll("div > input[type='checkbox']:checked").forEach((interest) => {setTimeout(function(){interest.click()},timer);timer+=2000;});