Skip to content

Instantly share code, notes, and snippets.

Verifying that "riccardo.id" is my Blockstack ID. https://onename.com/riccardo
@riccardomarotti
riccardomarotti / file_changes.py
Last active March 29, 2016 17:38
A reactive approach to monitor a file changes
import rx
from rx import Observable
import os
def check_changes(previous, cur):
current_modify_date = -1
filename = previous['filename']
if os.path.isfile(filename):
current_modify_date = os.path.getmtime(filename)
Verifying that +riccardo is my blockchain ID. https://onename.com/riccardo
@riccardomarotti
riccardomarotti / gist:4737373
Last active September 9, 2016 12:10
Resizes images passed as arguments to RESIZE_WIDTH x RESIZE_HEIGTH, stretching source image. Meant to be used in Automator.
#! /usr/bin/python
import sys
import CoreGraphics
RESIZE_WIDTH = 100
RESIZE_HEIGHT = 100
def resizeimage(source_image_file, target_image_file, target_width, target_height):
source_image = CoreGraphics.CGImageImport (CoreGraphics.CGDataProviderCreateWithFilename(source_image_file))
@riccardomarotti
riccardomarotti / gist:3963225
Created October 27, 2012 06:39
Extract first page of each passed PDF, in temporary PDF files.
#! /usr/bin/python
#
import sys
import os
import tempfile
from Quartz.CoreGraphics import *
from os.path import splitext
from os.path import basename
from os.path import join