Skip to content

Instantly share code, notes, and snippets.

View amoilanen's full-sized avatar
💭
"Simplicity is prerequisite for reliability." Edsger W. Dijkstra

Anton Moilanen amoilanen

💭
"Simplicity is prerequisite for reliability." Edsger W. Dijkstra
View GitHub Profile
@amoilanen
amoilanen / rhino_calculator.js
Created July 15, 2011 14:21
JavaScript Rhino Calculator
/*
* Copyright (C) 2011 by Anton Ivanov anton.al.ivanov@gmail.com
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
@amoilanen
amoilanen / xss_demo.html
Created July 19, 2011 21:31
Potentially Insecure Web Document
<!--
* This software can be used solely in educational purposes, all other uses are prohibited.
* No derivative works are allowed.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@amoilanen
amoilanen / text_search_and_highlighting.html
Created July 31, 2011 19:18
Text Search and Highlighting
<html>
<header>
<style type="text/css">
body
{
background-color:#FAEBD7;
}
button
{
width:70;
@amoilanen
amoilanen / string_search.js
Created August 2, 2011 19:13
Rabin-Karp Algorithm for Searching Strings Implemented in JavaScript
function simpleSearch(text, str) {
var matches = [];
for (var i = 0; i <= text.length; i++) {
if (matchesAtIndex(i, text, str)) {
matches.push(i);
}
}
return matches;
}
@amoilanen
amoilanen / skill_advisor.rb
Created August 13, 2011 18:58
Skills advisor rates your skills and compares them to the skills that are most in demand according to data from stackoverflow.com
#
# Automated skills advisor: based on the data available at careers.stackoverflow.com
# it generates the statistics which skills are most in demand and how they compare to
# what you know.
#
# Copyright (c) 2011 Anton Ivanov anton.al.ivanov(no spam)gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@amoilanen
amoilanen / delicious_links.html
Created September 18, 2011 16:33
Mashup that shows popular links from delicious.com
@amoilanen
amoilanen / FunctionalJavaExample.java
Created September 19, 2011 20:55
Demo of "Functional Java" library http://functionaljava.org
package functional.examples;
import static fj.data.Array.array;
import org.junit.Assert;
import org.junit.Test;
import fj.F;
import fj.data.Array;
@amoilanen
amoilanen / apartment_watcher.rb
Created October 11, 2011 18:06
Script Automatically Notifying about New Apartments
#
# Script that monitors new apartments that are available for rent and sends a notification
# in case something new shows up. The script can be scheduled to run, say, each 30 minutes.
#
# Copyright (c) 2011 Anton Ivanov anton.al.ivanov(no spam)gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@amoilanen
amoilanen / java_test_explorer.rb
Created November 5, 2011 20:48
Java test explorer. Lists all JUnit test cases in a Java project in a human readable form.
# ruby java_test_explorer.rb selftest
# Test the library
# ruby java_test_explorer.rb /home/user/eclipse_workspace/TestJavaProject
# List all the JUnit test cases in the project TestJavaProject
require 'find'
$separator = "-" * 50
def toCamelNotation(name)
words = name.split("_")
@amoilanen
amoilanen / ascii_binary_conversion.rb
Created November 18, 2011 22:18
Conversion from ASCII to binary codes and back
require "test/unit"
def fromBinaryCodes(text)
text.split(" ").map{|symbol| symbol.to_i(2).chr}.join("")
end
def toBinaryCodes(text)
text.split(//).map{|symbol| symbol.ord.to_s(2)}.join(" ")
end