Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tiff's full-sized avatar

Christopher Blum tiff

View GitHub Profile
@tiff
tiff / trim.py
Created March 28, 2018 07:14
Trim image whitespace
import numpy as np
from PIL import Image, ImageChops
import sys
import numpy as np
def trim(im):
bg = Image.new(im.mode, im.size, im.getpixel((0,0)))
size = im.size
top_left_pixel = im.getpixel((0,0))
@tiff
tiff / protonet_file_api.md
Last active March 16, 2020 20:28
Protonet File API

Protonet File API

Protonet supports the WebDAV protocol. You can access it under the following URL:

https://yourbox.protonet.info/dav

The API expects XML and responds with XML. WebDAV provides you with all features necessary to work with the Protonet file system (create, delete, list files/folders, ...). There are libraries/clients for almost every programming language that simplify working with the webdav server.

@tiff
tiff / protonet_rest_api_examples.md
Last active August 29, 2015 14:08
Protonet REST API Examples

Protonet Rest API

All examples in this document are done via curl. You can however use any programming language to access the API. The API expects JSON and responds with JSON.

Authorization

The Protonet REST-API supports two authorization mechanisms:

  1. Basic authorization: Send email and password as base64 encoded string within the request headers
@tiff
tiff / article.md
Last active August 29, 2015 13:57 — forked from fdietz/article.md

Why you should look into Angular.js

Web apps are getting more and more complicated these days. More and more logic moves from the backend to the frontend. Libraries and frameworks of the past weren't built with these new requirements in mind. For example using jQuery to manage a large and complex web app quickly ends up in a very difficult to maintain code base.

Fortunately, a new generation of frameworks are being built to meet these challenges and Angular.js is one of them! Let me introduce you to some of the major benefits of using Angular.

Declarative user interface and databindings

Angular uses HTML to define the user interface, which is much more intuitive than defining the interface procedurally in Javascript.

Following a quick example. Give it a try using an interactive JSFiddle!

(function() {
// Reset OTTO Nav HTML for to remove existing event listeners
var $container = $(".homepage");
var html = $container.html();
$container.html(html);
// Get nav items
var $items = $container.find(".sort");
$items.each(function(i) {
var fs = require("fs"),
exec = require("child_process").exec,
macAddresses = {
"00:25:00:48:26:b3": {
name: "Christopher",
times: 0,
log: 0
},
"74:e5:0b:a6:6f:94": {
name: "Wolfgang",
function traverseFileTree(item, path) {
path = path || "";
if (item.isFile) {
// Get file
item.file(function(file) {
console.log("File:", path + file.name);
});
} else if (item.isDirectory) {
// Get folder contents
var dirReader = item.createReader();
@tiff
tiff / minify.js
Created July 12, 2011 23:41
Easily compile your javascript files via node.js on the command line
// Minify and compile your javascript via node.js on the command line
//
// Usage:
// node minify.js "my_script.js"
var script = process.argv[2],
http = require("http"),
queryString = require("querystring"),
fs = require("fs");
@tiff
tiff / compareColors.js
Created March 25, 2011 15:34
Compare two color values in different formats (rgb, hex, color keyname, ...)
/**
* Cross browser way of comparing different color types
*
* Inspired by:
* http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/
*
* @author Christopher Blum
* @example
* compareColors("fuchsia", "rgb(255, 0, 255)");
* // => true
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Message Bundle Substitution in Remote Requests">
<Require feature="opensocial-0.9" />
<Require feature="opensocial-templates" />
<Require feature="opensocial-data" />
</ModulePrefs>
<Content type="html"><![CDATA[
<div>foo</div>
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/AQtmXKQgXqw?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/AQtmXKQgXqw?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>