Skip to content

Instantly share code, notes, and snippets.

View danigb's full-sized avatar

danigb danigb

  • InVideo
  • Seville, spain
View GitHub Profile
@danigb
danigb / EL TEST group_test.rb
Created June 13, 2012 21:18
Refactorizar el código
it 'has recipients' do
group = create(:group)
owner = group.user
member = create(:user)
group.add_member(member, :member)
follower = create(:user)
group.add_member(follower, :follow)
admin = group.recipients('admin')
admin.size.must_equal 1
@danigb
danigb / Install Leiningen OSX
Last active August 29, 2015 14:11
Introduction to Clojure using LightTable and Overtone
$ wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
$ mv lein /usr/local/bin
$ chmod +x /usr/local/bin/lein
$ lein --version
@danigb
danigb / Good Bye Pork Pie Hat.score
Last active August 29, 2015 14:22
Good Bye Pork Pie Hat
title = "Good Bye Pork Pie Hat"
author = "Charles Mingus"
time = "4/4"
key = -4
[chords]
r | F7 Db7 | Gbmaj7 B7 | Eb7 Db7 |
| Eb7 F7 | Bbm7 Db7 | Gm7 C7 |
| D7 G7 | Db7Gbmaj7 | B7 Bb7 |
| C7 Eb7 | F7 Db7 | Gbmaj7 B7 | r
@danigb
danigb / scale-test.js
Created July 11, 2015 08:57
note-pitch scales test
var Note = require('note-pitch')
function testScale (intervals, root) {
var scale = Note.transpose(root, intervals)
console.log(scale)
}
testScale([ 'P1', 'M2', 'M3', 'P5', 'm6' ], 'G7')
testScale([ 'P1', 'M2', 'M3', 'd5', 'M6', 'm7' ], 'G7')
testScale([ 'P1', 'M2', 'M3', 'd5', 'm6', 'm7' ], 'G7')
@danigb
danigb / musical-test.js
Created March 21, 2016 13:38
A javascript (incomplete) implementation of the paper "Lisp as second language" (http://www.mcg.uva.nl/papers/lisp2nd/functional.pdf)
/* global describe it */
var assert = require('assert')
var equal = assert.deepEqual
var M = require('./musical')
var note = M.note
var phrase = M.phrase
var chord = M.chord
var seq = M.sequential
var par = M.parallel

ScoreJS (next)

This is an explanation of how it works the 4th iteration of the scorejs prototype. All the examples shown are valid code (at least for today ;-)

Basics

The library makes two big assumptions:

  • an score is made by combining indivisible entities called elements: an object with a duration property. Currently the only type of elements supported are notes (an element with pitch property)
@danigb
danigb / tonal.js
Created May 8, 2016 03:42
One file tonal
// # Tonal
// __tonal__ is a functional music theory library. It deals with abstract music
// concepts like picthes and intervals, not actual music.
// `tonal` is also the result of my journey of learning how to implement a music
// theory library in javascript in a functional way.
// You are currently reading the source code of the library. It's written in
// [literate programming](https://en.wikipedia.org/wiki/Literate_programming) as
@danigb
danigb / Tests.elm
Created May 17, 2016 21:43
How to write and run test with elm-lang 0.17
import ElmTest exposing (..)
import String
tests : Test
tests =
suite "A Test Suite"
[
test "Addition" (assertEqual (3 + 7) 10),
test "String.left" (assertEqual "a" (String.left 1 "abcdefg")),
test "This test should pass" (assert True)
@danigb
danigb / elm-test-project-setup.sh
Last active May 23, 2016 18:31
elm-lang Test Driven project setup
mkdir elm-twelve-tone
cd elm-twelve-tone
mkdir src
mkdir test
elm-package install -y elm-lang/core
elm-package install -y elm-community/elm-test
-- NAMING ERROR ---------------------------------------- test/TwelveToneTest.elm
Cannot find variable `noteToPc`
7| test "noteToPc" (assertEqual 7 (noteToPc 55))
^^^^^^^^