Skip to content

Instantly share code, notes, and snippets.

View panzi's full-sized avatar

Mathias Panzenböck panzi

View GitHub Profile
@panzi
panzi / s3m-form.txt
Created June 24, 2011 23:15
unicode version of s3m-form.txt
Source: http://www.textfiles.com/music/FORMATS/s3m-form.txt
Scream Tracker 3.01 BETA File Formats And Mixing Info
=====================================================
This document finally containts the OFFICIAL information on s3m format and
much more. There might be some errors though I've even checked this a few
times, so if something seems weird, don't just blindly believe it but think
first if it could be just a typo or something.
@panzi
panzi / input-demo.html
Created October 4, 2011 00:25
Show a "title" for empty text inputs/textareas.
<!DOCTYPE html>
<html>
<head>
<title>Input Demo</title>
<!--
This is an example on how to create a text input/textarea with a
nice description on what to enter in case nothing is entered.
It uses Prototype for DOM navigation and updating an elements
class name, but it should be easy to port to any other JavaScript
@panzi
panzi / absurl.js
Created February 18, 2012 04:11
Build an absolute url from an relative url and an absolute base url.
/**
* Build an absolute url using an base url.
* The provided base url has to be a valid absolute url. It will not be validated!
* If no base url is given the document location is used.
* Schemes that behave other than http might not work.
* It tries to support file:-urls, but might fail in some cases.
* email:-urls aren't supported at all (don't make sense anyway).
*
* NOTE: Internet Explorer does not support the baseURI property, but it does
* support the base tag, which results in wrong url. You might want to
@panzi
panzi / escapeXml.js
Created February 18, 2012 04:16 — forked from atesgoral/escapeXml.js
Escape XML in JavaScript.
var XML_CHAR_MAP = {
'<': '&lt;',
'>': '&gt;',
'&': '&amp;',
'"': '&quot;',
"'": '&apos;'
};
function escapeXml (s) {
return s.replace(/[<>&"']/g, function (ch) {
@panzi
panzi / capybara-helpers.rb
Created March 26, 2012 16:06 — forked from jc00ke/capybara-helpers.rb
Capybara helpers
def screenshot
require 'capybara/util/save_and_open_page'
now = Time.now
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}"
Capybara.save_page body, "#{p}.html"
path = Rails.root.join("#{Capybara.save_and_open_page_path}#{p}.png").to_s
page.driver.render path
Launchy.open path
end
@panzi
panzi / firefox_opera_ie.js
Created November 1, 2012 04:43
Cross site HTTP Auth via JavaScript
_loginBrowser: function () {
// HTTP Auth hack for Firefox, Opera and IE.
this._loginScript("http://stream.magnatune.com");
},
_loginScript: function (origin, options) {
var finished = false;
var onerror = function (event) {
if (finished) return;
if (event.originalEvent.target === script) {
finished = true;
@panzi
panzi / 00_head.html
Created November 1, 2012 04:58
Save/download data generated in JavaScript (1)
<!DOCTYPE html>
<html>
<head>
<title>Save Generated Data</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"/>
<script type="text/javascript">
// <![CDATA[
@panzi
panzi / 10_object_url.js
Created November 1, 2012 05:02
Save/download data generated in JavaScript (2)
if (BrowserSupportedMimeTypes[mimetype.split(";")[0]] === true) {
  mimetype = "application/octet-stream";
 }
 
 blob = builder.getBlob(mimetype);
 url = URL.createObjectURL(blob);
 window.open(url, '_blank', '');
}
@panzi
panzi / share.html
Last active October 12, 2015 08:08
Social Share Privacy for Blogger
<link rel="stylesheet" type="text/css" href="http://panzi.github.io/SocialSharePrivacy/stylesheets/jquery.socialshareprivacy.min.css" />
<style type="text/css">
#share {
position: absolute;
top: 110px;
left: -120px;
opacity: 0.3;
-webkit-transition: opacity 0.5s linear;
-moz-transition: opacity 0.5s linear;
-ms-transition: opacity 0.5s linear;
@panzi
panzi / dataurl.py
Created November 2, 2012 21:11
Python 3 data url handler
import binascii
import urllib.request
import urllib.parse
import email.message
import io
__all__ = ['parse_data_url','DataResponse','DataHandler']
def parse_data_url(url):
scheme, data = url.split(":",1)