Skip to content

Instantly share code, notes, and snippets.

@polarblau
polarblau / work_days_2015.md
Last active August 29, 2015 14:20
Work days / Berlin, Germany (2015)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Days: 21 20 22 20 18 22 23 21 22 22 21 22
Hours: 157,5 150 165 150 135 165 172,5 157,5 165 165 157,5 165

(Hours calculations are based on 7.5 hour days.)

@polarblau
polarblau / atf.js
Last active August 29, 2015 14:11
Apple trailers in fullscreen: save as bookmarklet, start a trailer video on trailers.apple.com, run the script.
javascript:(function(){try{var video=find('.moviePanel object embed');var origWidth=video.width,origHeight=video.height,origStyleWidth=video.style.width,origStyleHeight=video.style.height;onEnterFullscreen(function(){video.width='100%';video.height='100%';video.style.width='100%';video.style.height='100%';});onExitFullscreen(function(){video.width=origWidth;video.height=origHeight;video.style.width=origStyleWidth;video.style.height=origStyleHeight;});fullscreen(video);}catch(e){}function getVideoSize(video){return[video.width,video.height,video.style.width,video.style.height];}function setVideoSize(video,size){video.width=size[0];video.height=size[1];video.style.width=size[2];video.style.height=size[3];}function find(query){return document.querySelector(query);}function isFullscreen(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;}function onFullscreenChange(cb){document.addEventListener('fullscreenchange',cb,false);document.ad
function Track(src, spriteLength, audioLead) {
var track = this,
audio = document.createElement('audio');
audio.src = src;
audio.autobuffer = true;
audio.load();
audio.muted = true; // makes no difference on iOS :(
/* This is the magic. Since we can't preload, and loading requires a user's
input. So we bind a touch event to the body, and fingers crossed, the
mkdir bash-fix
cd bash-fix
curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf -
cd bash-92/bash-3.2
curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-052 | patch -p0
cd ..
xcodebuild
sudo cp /bin/bash /bin/bash.old
sudo cp /bin/sh /bin/sh.old
build/Release/bash --version # GNU bash, version 3.2.52(1)-release
@polarblau
polarblau / matrix.coffee
Created September 1, 2014 07:20
Helper class for work with two–dimensional arrays
class Matrix
members: [[]]
@fromArray = (array, width)->
chunks = []
for _, index in array by width
chunks.push array.slice(index, index + width)
new Matrix(chunks)
.foo {
color: red;
}
function Bar() {}
Bar.prototype.foo = function () {
console.log('Bar#foo called');
};
Bar.prototype.bar = function (arg) {
console.log(this);
console.log('Bar#bar called with ' + arg);
};
@polarblau
polarblau / api_proxy.rb
Created July 10, 2014 08:39
Proxy API request through your server to avoid cross–origin issues.
# USAGE:
#
# Mount endpoint, e.g.:
#
# map '/api_proxy' do
# run APIProxy.new
# end
#
# Then call the endpoint, passing the actual URL
# as GET param `api_url`
@polarblau
polarblau / should_be_json.rb
Created June 25, 2014 08:45
Rspec matcher to check if input is JSON.
RSpec::Matchers.define :be_json do
match do |actual|
begin
!!JSON.parse(actual)
rescue
false
end
end
failure_message_for_should do |actual|