Skip to content

Instantly share code, notes, and snippets.

@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)
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
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
@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
@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 / install_pg_with_config.sh
Created May 13, 2015 08:10
Installing PG gem with postgres.app
gem install pg -- --with-pg_config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
#!/bin/bash
HOST="some-host.com"
ERROR_MESSAGE="Some Host server unreachable!"
while true
do
status=$(curl -s -I $HOST | grep HTTP/1.1 | awk {'print $2'})
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
@polarblau
polarblau / gist:1080242
Created July 13, 2011 12:55
Backbone base collection class
class BaseCollection extends Backbone.Collection
_expiresAfter: 15 # seconds
_lastFetched: null
isStale: ->
now = (new Date()).getTime()
!@_lastFetched? || now - @_lastFetched > (@_expiresAfter * 1000)
refresh: (models, options) ->
@polarblau
polarblau / gist:1175351
Created August 27, 2011 12:49
Cheap translation from (in this case en > fi) from command line
# install @sishen's ruby gem for access to Google's translate API access:
# https://github.com/sishen/rtranslate
$ gem install sishen-rtranslate
# add alias for quick access and reload:
# (adjust/add languages as needed)
$ echo "alias fin='rtranslate -f en -t fi'" >> .profile
$ source .profile
# try it: