Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import numpy
from PIL import ImageGrab, Image
def find_coeffs(pa, pb):
"""Computes the appropiate parameters for PIL.Image.transform
from the coordinates of two rectangles given as parameters:
pa: list of four corners of rectangle after transform
@jldiaz
jldiaz / README.md
Last active April 11, 2024 07:45
Copy/paste into vim registers via ssh tunnel

These scripts allows you to use vim in a remote machine via ssh, and being capable of sharing the local clipboard with vim's 0 register (which is the one used by default by yank/paste).

To make it work:

  1. In your local machine, run clipboard-server.py, which uses flask to create a simple REST API exposing only the / endpoint, listening on localhost:11223

    GET / will retrieve the system clipboard of the machine in which the server is run, in form of a JSON with the field "content".

# This code was used to create the answer
# http://tex.stackexchange.com/a/352766/12571
from scipy.optimize import fsolve
from math import *
import numpy as np
def ellipse(a,b,t):
return (a*cos(t), b*sin(t))
@jldiaz
jldiaz / app.yaml
Created June 9, 2015 15:04
GAE endpoints problem with integers
application: your-app-id
version: 1
runtime: python27
threadsafe: true
api_version: 1
# Handlers tell App Engine how to route requests to your application.
handlers:
# This handler routes requests to your APIs to your Endpoints code.
@jldiaz
jldiaz / copypaste.py
Last active December 31, 2015 14:49
This script allows to get/set the contents of the clipboard of the machine in which the script is running, and communicate it to/from another machine. It is designed to work with iPad Editorial app. Tested under linux, it should work also on OSX/Windows provided that `xerox` module and its dependencies are installed.
#!/usr/bin/env python
# coding: utf-8
"""
This script implements a server which listens in UDP port 9999 (by default)
waiting for an incoming datagram.
If the incoming datagram is empty, the script answers with the current content
of the clipboard (in utf8), otherwise it sets the content of the clipboard
to the contents received in the datagram, interpreted as plain text in utf8