Skip to content

Instantly share code, notes, and snippets.

View tiff's full-sized avatar

Christopher Blum tiff

View GitHub Profile
@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.

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 / 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
@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))
(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",
@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");
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Test OpenSocial Templates" />
<Content type="html"><![CDATA[
<script type="text/javascript" src="http://ostemplates-demo.appspot.com/ostemplates.js"></script>
<!-- A simple inline template -->
<script type="text/os-template">
<div style="font-size: 20px">Hello world!</div>
</script>