Skip to content

Instantly share code, notes, and snippets.

@lucaspiller
lucaspiller / gist:3104392
Created July 13, 2012 11:23
Support writing a header and footer with the Spreadsheet gem
module Spreadsheet
module Excel
module Writer
class Worksheet
alias_method :write_from_scratch_without_header_footer, :write_from_scratch
def write_from_scratch
if @worksheet.header
write_op opcode(:header), [@worksheet.header.bytesize, 0].pack("vC"), @worksheet.header
end
THREE.Mesh.prototype.rotateAboutObjectAxis = (axis, radians) ->
rotationMatrix = new THREE.Matrix4()
rotationMatrix.makeRotationAxis axis.normalize(), radians
@matrix.multiplySelf rotationMatrix
@rotation.getRotationFromMatrix @matrix
THREE.Mesh.prototype.rotateAboutWorldAxis = (axis, radians) ->
rotationMatrix = new THREE.Matrix4()
rotationMatrix.makeRotationAxis axis.normalize(), radians
rotationMatrix.multiplySelf @matrix
THREE.Mesh.prototype.rotateAboutObjectAxis = (axis, radians) ->
rotationMatrix = new THREE.Matrix4()
rotationMatrix.makeRotationAxis axis.normalize(), radians
@matrix.multiplySelf rotationMatrix
@rotation.getRotationFromMatrix @matrix
THREE.Mesh.prototype.rotateAboutWorldAxis = (axis, radians) ->
rotationMatrix = new THREE.Matrix4()
rotationMatrix.makeRotationAxis axis.normalize(), radians
rotationMatrix.multiplySelf @matrix
@lucaspiller
lucaspiller / prepare-commit-msg.sh
Created October 8, 2015 11:34
Automatic @vjt style Git commit messages
#!/bin/sh
# Install this in your Git repo in .git/hooks/prepare-commit-msg. Git doesn't
# support global hooks, but you can work around it using templates, see:
#
# https://github.com/mroth/lolcommits/wiki/Enabling-Lolcommits-for-all-your-Git-Repositories.
ORIGINAL_COMMIT_MSG=$(cat "$1")
# from http://www.emoji-cheat-sheet.com/
@lucaspiller
lucaspiller / test_log_formatter.rb
Created August 15, 2012 10:02
Test Log Formatter
require 'rspec/core/formatters/progress_formatter'
#
# Test Log Formatter
#
# * Logs example descriptions to the Rails test.log
# * If the PRINT_FAILURE_LOG env is set, the test.log for failed examples will
# be printed to stdout
#
# Put this somewhere, e.g. spec/support/test_log_formatter.rb, then add this to your .rspec:
@lucaspiller
lucaspiller / index.html
Created September 20, 2012 23:00
Isometric CSS Test
<!-- See example at http://bl.ocks.org/3758852 -->
<html>
<head>
<title>Isometric Test</title>
<style>
.board {
-webkit-transform:matrix(1,-0.6, 1,0.6, 0,0);
-moz-transform:matrix(1,-0.6, 1,0.6, 0,0);
-o-transform:matrix(1,-0.6, 1,0.6, 0,0);
transform:matrix(1,-0.6, 1,0.6, 0,0);
@lucaspiller
lucaspiller / gist:3760620
Created September 21, 2012 09:39
Zsh Bug
~ ‹1.9.3-p194› $ mkdir a
~ ‹1.9.3-p194› $ cp -r a a
cp: a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/
%%%-------------------------------------------------------------------
%%% File : quad_tree.erl
%%% @author Jamie Burrell
%%% @doc Erlang implementation of a quadratic tree.
%%% @end
%%% @since 2009-02-10
%%% @end
%%%-------------------------------------------------------------------
-module(quad_tree).
#!/bin/zsh
# computer activity data collection for http://jehiah.cz/one-two/
# Originally by Jehiah Czebotar. This verison by Luca Spiller.
FILE="$HOME/Dropbox/activity_log/`hostname`-`date +%Y%m%d`.log"
function log_activity()
{
local TIME=`date "+%Y-%m-%dT%H:%M:%S%z"`
local IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
class CalendarController
SKIP_DAYS = 35
constructor: (@parent, @date = moment()) ->
@parent.on 'click', '[data-direction=prev]', @movePrevious
@parent.on 'click', '[data-direction=next]', @moveNext
@parent.on 'changeDate', '[data-date-picker]', @changeDate
movePrevious: (e) =>
e.preventDefault()