Skip to content

Instantly share code, notes, and snippets.

@gferreira
gferreira / bulk-list.py
Last active August 6, 2019 15:51 — forked from okay-type/bulk-list.py
dropfile-ui
# jackson # ok@yty.pe
import os
from AppKit import NSFilenamesPboardType, NSDragOperationCopy
from vanilla import Window, List, Button
class doThing():
def __init__(self, path):
@gferreira
gferreira / voronoi-drawbot-example.py
Created June 20, 2019 16:28
Create a Voronoi diagram as a raster image in Python. Converted from PIL to DrawBot.
# http://forum.drawbot.com/topic/148/voronoi-fun/2
import random
import math
def generate_voronoi_diagram(imgx, imgy, num_cells):
nx = []
ny = []
nr = []
from vanilla import *
from AppKit import NSDragOperationCopy
genericListPboardType = "genericListPboardType"
class DragAndDropListItemsDemo:
weekdays = {
'Mon' : [],
'Tue' : [],
@gferreira
gferreira / find-bezier-point-2.py
Last active April 18, 2019 22:16
translation along a path
'''draw a range of shapes along a bezier segment'''
# converted from:
# http://13thparallel.com/archive/bezier-curves/
def B1(t): return t*t*t
def B2(t): return 3*t*t*(1-t)
def B3(t): return 3*t*(1-t)*(1-t)
def B4(t): return (1-t)*(1-t)*(1-t)
@gferreira
gferreira / find-bezier-point.py
Last active April 18, 2019 21:34
find a point in a Bezier segment
'''find a point in a Bezier segment'''
# formulas converted from:
# http://13thparallel.com/archive/bezier-curves/
# run this script in DrawBot: http://drawbot.com/
def B1(t): return t*t*t
def B2(t): return 3*t*t*(1-t)
def B3(t): return 3*t*(1-t)*(1-t)
@gferreira
gferreira / lockLayerWidths.py
Last active September 29, 2018 10:05
lock/unlock widths of glyph layers
from vanilla import HUDFloatingWindow, SquareButton, CheckBox
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo import drawingTools as ctx
from mojo.events import addObserver, removeObserver
from mojo.UI import UpdateCurrentGlyphView, getDefault
class LockLayerWidthsDialog(BaseWindowController):
key = 'com.hipertipo.lockLayerWidths'
verbose = True
@gferreira
gferreira / SteppersDemo.py
Last active July 19, 2018 16:35
SteppersDemo
from vanilla import Window
from lib.UI.stepper import Stepper, EditStepper, SliderEditStepper
class StepperDemo(object):
def __init__(self):
self.w = Window((300, 100), "Stepper Demo")
self.w.stepper = Stepper((10, 10, -10, 24), value=100)
self.w.open()
@gferreira
gferreira / upload-file-to-server.py
Created July 12, 2011 00:05
upload file to server via ftp
import os
from ftplib import FTP
def connectToServer(url, login, password, folder, verbose=False):
# create FTP connection
ftp = FTP(url, login, password)
if verbose == True:
print "%s" % ftp.getwelcome()
# move to folder
@gferreira
gferreira / compare-glyphsets.py
Last active March 16, 2018 13:33
Compare glyphsets of two .ufo fonts (in RoboFont)
# compare glyphsets of two ufos
f1_path = u"/path/to/font1.ufo"
f2_path = u"/path/to/font2.ufo"
f1 = OpenFont(f1_path, showUI=False)
f2 = OpenFont(f2_path, showUI=False)
f1_glyphset = set(f1.keys())
f2_glyphset = set(f2.keys())
@gferreira
gferreira / building-apps.md
Last active September 18, 2017 23:03
partial transcription of presentation at Robothon 2012

Tal Leming: Building Apps

partial transcription of Robothon 2012 presentation

© Tal Leming

Defcon

Robofab was built as a scripting library. It was not built to be fast, it was built to be comfortable.