Skip to content

Instantly share code, notes, and snippets.

View margusmartsepp's full-sized avatar
😇
It is that simple

Margus Martsepp margusmartsepp

😇
It is that simple
  • Gunvor SA
  • Tallinn
View GitHub Profile
@margusmartsepp
margusmartsepp / gist:1111497
Created July 28, 2011 13:04
binary search
/**
* Function returns location of unique item in a sorted list.
*
* @param <T> Class, that implements comparable interface.
* @param data list of elements
* @param searchValue element to search for
* @return Location of the the element. If item is not found, -1 is returned.
* @throws java.lang.NullPointerException
* If any checked element in the list is 'null'.
*/
@margusmartsepp
margusmartsepp / gist:1111536
Created July 28, 2011 13:25
binary search
/// <summary>
/// Function returns location of unique item in a sorted list.
/// </summary>
/// <typeparam name="T">Class, that implements comparable interface.</typeparam>
/// <param name="data">list of elements</param>
/// <param name="searchValue">element to search for</param>
/// <returns>Location of the the element. If item is not found, -1 is returned.</returns>
/// <exception cref="System.NullReferenceException">
/// If any checked element in the list is 'null'. (Other then first one)
/// </exception>
/**
* Gives the Fibonacci number.
*
* @param n
* element to return.
* @return Fibonacci and Negafibonacci numbers.
*/
public static BigInteger fibonacci(final int n) {
if (n == 0)
return BigInteger.ZERO;
/// <summary>
/// Gives the Fibonacci number.
/// </summary>
/// <remarks>using System.Numerics;</remarks>
/// <param name="n">element to return.</param>
/// <returns>Fibonacci and Negafibonacci numbers.</returns>
public static BigInteger fibonacci(int n)
{
if (n == 0)
return BigInteger.Zero;
@margusmartsepp
margusmartsepp / getFunctionCalls
Created October 28, 2011 00:00
Method that finds possible function calls in a script string.
/**
* Method that finds possible function calls in a script string.
*
* @param eval
* script string
* @return Collection of function calls
* @author Margus Martsepp
*/
public static Collection<String> getFunctionCalls(String eval) {
ArrayList<String> result = new ArrayList<String>();
@margusmartsepp
margusmartsepp / gist:1321253
Created October 28, 2011 00:01
Method that finds possible function calls in a script string.
/**
* Method that finds possible function calls in a script string.
*
* @param eval
* script string
* @return Collection of function calls
* @author Margus Martsepp
*/
public static Collection<String> getFunctionCalls(String eval) {
ArrayList<String> result = new ArrayList<String>();
@margusmartsepp
margusmartsepp / gist:4034761
Created November 7, 2012 21:56
Map financial entity by it's relations using Google finance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Requires reference to WebDriver.dll and WebDriver.Support.dll
// Furthermore, Firefox uses "selenium-ide-1.9.0.xpi" plugin.
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
@margusmartsepp
margusmartsepp / gist:4040530
Created November 8, 2012 18:14
Mathematica input
This file has been truncated, but you can view the full file.
{{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 10}, {0, 11}, {0, 12}, {0, 13}, {0, 14}, {0, 15}, {0, 16}, {0, 17}, {0, 18}, {0, 19}, {0, 20}, {0, 21}, {0, 22}, {0, 23}, {0, 24}, {0, 25}, {0, 26}, {0, 27}, {0, 28}, {0, 29}, {1, 30}, {1, 31}, {1, 32}, {2, 33}, {2, 34}, {2, 35}, {3, 36}, {3, 37}, {3, 38}, {3, 39}, {3, 40}, {3, 41}, {3, 42}, {3, 43}, {3, 44}, {3, 45}, {3, 46}, {4, 38}, {4, 39}, {4, 47}, {4, 48}, {5, 38}, {5, 39}, {5, 48}, {5, 49}, {5, 50}, {5, 51}, {5, 52}, {5, 53}, {5, 54}, {5, 55}, {5, 56}, {5, 57}, {5, 58}, {6, 32}, {6, 41}, {6, 59}, {6, 60}, {6, 61}, {6, 62}, {7, 3}, {7, 39}, {7, 48}, {8, 63}, {8, 64}, {8, 65}, {8, 66}, {8, 67}, {8, 68}, {9, 32}, {9, 69}, {10, 48}, {10, 70}, {10, 71}, {10, 72}, {11, 39}, {11, 73}, {11, 74}, {11, 75}, {11, 76}, {11, 77}, {11, 78}, {11, 79}, {12, 36}, {12, 38}, {12, 39}, {12, 41}, {12, 48}, {12, 79}, {12, 80}, {12, 81}, {13, 82}, {13, 83}, {13, 84}, {14, 41}, {14, 85}, {14, 86}, {14, 87}, {14, 88}, {15, 39}, {15, 48}, {15,
@margusmartsepp
margusmartsepp / gist:4076425
Created November 15, 2012 03:13
C# selenium log in / log out
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
namespace Testimine
@margusmartsepp
margusmartsepp / gist:4179201
Created November 30, 2012 22:35
Automated testing in c# using selenium
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System.Text.RegularExpressions;
using System.Globalization;