Skip to content

Instantly share code, notes, and snippets.

@otger
otger / grabber.py
Created July 3, 2017 09:42
Script to download an image from a webcam and upload to google drive using gdrive if it complies with some settings. Settings to decide if an image must be uploaded are brightness and change from last uploaded image
#!/usr/bin/env python
import math
import subprocess
from PIL import Image, ImageStat, ImageChops
import numpy as np
import datetime
import urllib
import os
import glob
import shutil
@otger
otger / queue_test_queue_test.py
Last active December 28, 2016 15:56
QueueTest
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import threading
__author__ = 'otger'
class Pusher(object):
def __init__(self, q, b, filepath='./quijote.txt'):
self.q = q
@otger
otger / EXIFmover.py
Last active August 29, 2015 13:57 — forked from nerdtalker/EXIFmover.py
# Name: EXIFmover
# Forked from EXIFmover.py by Brian Klug (@nerdtalker / [email protected])
# Purpose:
# Move Files into directory based on dates
# Designed to un-clusterfuck the Dropbox camera upload directory which is a mess as all files are
# uploaded to same folder.
# Moves files into /YEAR/MONTH eg /2014/03
# Creates directory if it doesn't exist, moves into that directory if it exists
# Files without "YYYY-mm-dd" pattern on its name are scanned looking for exif data
@otger
otger / isTablet.js
Created October 13, 2013 21:57
Code for "Determining if a device is a tablet on Titanium Appcelerator" blog post: http://www.libtronics.com/2013/10/determining-if-device-is-tablet-on.html
var osname = Ti.Platform.osname;
var version = Ti.Platform.version;
var dpi = Ti.Platform.displayCaps.dpi;
var height = Ti.Platform.displayCaps.platformHeight;
var width = Ti.Platform.displayCaps.platformWidth;
if (height < width){
var w_inch = height / Ti.Platform.displayCaps.xdpi;
var h_inch = width / Ti.Platform.displayCaps.ydpi;
}else{
var w_inch = width / Ti.Platform.displayCaps.xdpi;
@otger
otger / Titanium_original.js
Last active December 25, 2015 11:19
Code for "Determining if a device is a tablet on Titanium Appcelerator" blog post: http://www.libtronics.com/2013/10/determining-if-device-is-tablet-on.html
//considering tablet to have one dimension over 900px - this is imperfect, so you should feel free to decide
//yourself what you consider a tablet form factor for android
var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));
@otger
otger / ctail.py
Last active December 23, 2015 22:00
'tail -f' alternative which colors any given tag/word: usage: ctail path/to/file regex_to_color_1 regex_to_color_2 ... regex_to_color_N
#!/usr/bin/env python
# encoding: utf-8
'''
ctail -- colored tail
ctail is a simple 'tail -f' alternative which colors given regular expressions matches
@author: Otger Ballester
@otger
otger / ndbStructuredPropertyExample.py
Created September 19, 2013 22:38
NDB StructuredProperty example
class ProviderNDB(ndb.Model):
name = ndb.StringProperty() ##Published name
enabled = ndb.BooleanProperty(default = True)
last_crawl = ndb.DateTimeProperty(auto_now_add=True)
p = ProviderNDB(id='test', name='provider test')
p.put()
class testNDB(ndb.Model):
provider = ndb.StructuredProperty(ProviderNDB)
@otger
otger / carboniface.py
Created September 18, 2013 08:51
Carbon interface class to access a Graphite carbon daemon and add time series data
import socket
import pickle
import random
import time
import struct
import threading
import urllib2
#from sc_watchdog.logger import log