{{ message }}

Instantly share code, notes, and snippets.

Mikko Harju mharju

Last active Aug 29, 2015
Solution to the newest Reaktor FastTrack. Mathematically elegant, code-wise maybe not so :)
View outrun.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 ; A solution to the latest http://reaktor.fi/careers/fast_track/ ; ; Calculates recursively the maximum path function ; S(i,j) = W(i,j) + max { S(i-1, j-1), S(i-1, j) } ; ; Solution to the problem is just finding ; M = max { S(N, i) }, 1 <= i <= N (using 1-based indexing) ; ; then prints out the solution from the given node as an HTML table.
Created Jun 30, 2014
View waves.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 void main(void) { vec2 n = 2.0 * (gl_FragCoord.xy / iResolution.xy) - 1.0; vec2 uv = vec2(0,0); float theta = iGlobalTime * 0.2; uv.x = cos(theta) * n.x + sin(theta) * n.y; uv.y = -sin(theta) * n.x + cos(theta) * n.y; vec4 v = texture2D(iChannel0, vec2(0.0,iChannelTime[0]));
Last active Aug 29, 2015
Yet another fasttrack solution
View pairs.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 (ns pairs.core (:require [clojure.string :as str] [clojure.math.combinatorics :as combo])) (def letters (map identity "pairs")) (defn name->counts [name] (reduce (fn [acc value] (if-not (nil? value)
Created Jul 7, 2010
View gist:466339
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include #define QUESTIONS_FILE "hello.txt" #define BUFFER_SIZE 255 #define OPTSEPARATOR ';' #define QUESTIONSEPARATOR '\n' struct option_t
Created Aug 25, 2010
View gist:549324
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 00000000 00 03 00 00 00 01 00 0b 2f 31 2f 6f 6e 52 65 73 /1/onRes 00000010 75 6c 74 00 04 6e 75 6c 6c 00 00 00 00 11 0a 07 ult null 00000020 3b 66 6c 65 78 2e 6d 65 73 73 61 67 69 6e 67 2e ;flex.messaging. 00000030 69 6f 2e 4f 62 6a 65 63 74 50 72 6f 78 79 0a 81 io.ObjectProxy 00000040 03 55 66 6c 65 78 2e 6d 65 73 73 61 67 69 6e 67 Uflex.messaging 00000050 2e 6d 65 73 73 61 67 65 73 2e 41 63 6b 6e 6f 77 .messages.Acknow 00000060 6c 65 64 67 65 4d 65 73 73 61 67 65 09 62 6f 64 ledgeMessage bod 00000070 79 11 63 6c 69 65 6e 74 49 64 1b 63 6f 72 72 65 y clientId corre 00000080 6c 61 74 69 6f 6e 49 64 17 64 65 73 74 69 6e 61 lationId destina 00000090 74 69 6f 6e 0f 68 65 61 64 65 72 73 13 6d 65 73 tion headers mes
Created Aug 25, 2010
View gist:549314
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

Created Sep 1, 2010
View el purkka.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 elif isinstance(field, models.ForeignKey) and\ field.rel.limit_choices_to: key = field.rel.get_related_field().name choices = field.rel.limit_choices_to info.choices = list() for choice in field.rel.to._default_manager.filter(**choices).values(): info.choices.append( (choice[key], unicode(choice.values()[0]),) ) info.shortName = '%s_id' % info.shortName info.fullName = '%s_id' % info.fullName
Created Dec 19, 2010
Tässä vähän tämmöstä pikaista testiä! :)
View choice_game.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 from itertools import chain import random def shift(cards, shift): return [ cards[(i - shift) % len(cards)] for i in range(0, len(cards) ) ] def shuffle(cards, m): return [ [ card for pos, card in enumerate(chain(*cards)) if pos % m == p ] for p in range(0, m) ] def shift_amt(position, m, n):
Created Mar 2, 2011
View just_an_idea.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 var application = Sammy.Bundle('#element', { 'base': my_app.base, // A Sammy.Application in its own right 'add-event': my_app.add_event // So is this }, function() { // Rules how to change states. Can be triggered by binding or routing? this.get('#/add', function() { this.setApplication('add-event');
Created Apr 3, 2011
A function to include in your .zshrc to copy passwords to OS X clipboard from Sala
View salaclip.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 SALADIR=~/.sala function _sala_all { (cd \$SALADIR && find . | cut -d'/' -f 2,3 | grep '/' | grep -v '.git' | xargs) } function _salacomp { reply=(`_sala_all`) } compctl -K _salacomp sc function sc {