Skip to content

Instantly share code, notes, and snippets.

View wice_grid.coffee
WiceGridProcessor = (name, base_request_for_filter, base_link_for_show_all_records, link_for_export, parameter_name_for_query_loading, parameter_name_for_focus, environment) ->
this.checkIfJsFrameworkIsLoaded = () ->
if ! jQuery
alert "jQuery not loaded, WiceGrid cannot proceed!"
this.checkIfJsFrameworkIsLoaded()
this.name = name
this.parameter_name_for_query_loading = parameter_name_for_query_loading
View wice_grid.coffee.js
var WiceGridProcessor, toggle_multi_select;
WiceGridProcessor = function(name, base_request_for_filter, base_link_for_show_all_records, link_for_export, parameter_name_for_query_loading, parameter_name_for_focus, environment) {
this.checkIfJsFrameworkIsLoaded = function() {
if (!jQuery) {
return alert("jQuery not loaded, WiceGrid cannot proceed!");
}
};
this.checkIfJsFrameworkIsLoaded();
this.name = name;
this.parameter_name_for_query_loading = parameter_name_for_query_loading;
@leikind
leikind / infinite_multidimensional_game_of_life_with_configurable_rules.rb
Created Aug 7, 2011
Infinite multidimensional game of life with configurable rules :)
View infinite_multidimensional_game_of_life_with_configurable_rules.rb
# Yuri Leikind && Dmitry Adamushko :)
require 'set'
class Array # To understand recursion you have to understand recursion
def permutations(i = 0, *a)
return [a] if i == size
self[i].map do |x|
self.permutations(i+1, *(a + [x]))
View route.erl
-module(route).
-compile(export_all).
main(Filename) ->
% Filename = "road.txt",
{ok, Binary} = file:read_file(Filename),
NumberList = parse_input(Binary),
RouteTuples = lists:reverse(split_by_three(NumberList, [])),
Optimal = calculate_route(RouteTuples),
@leikind
leikind / infinite_multidimensional_game_of_life_with_configurable_rules.erl
Last active Sep 27, 2015
Infinite multidimensional game of life with configurable rules :)
View infinite_multidimensional_game_of_life_with_configurable_rules.erl
-module(game_of_life).
% -export([run/0, neighbours_for/1]).
-compile(export_all).
%%%% Coordinates %%%%
make_coordinate(List) when is_list(List) -> {coordinates, List};
make_coordinate(_) -> erlang:error(badarg).
@leikind
leikind / trap.erl
Created Nov 18, 2011
exit/1, exit/2, link, trap_exit
View trap.erl
-module(trap).
-export([simple_exit_demo/0, kill_demo_v2/0, kill_demo/0, successfully_killing_a_non_system_process/0]).
listen() ->
receive
Message -> io:format("~p has caught a system message: ~p~n~n", [self(), Message]),
listen()
after 1000 ->
io:format("I, ~p, live on~n", [self()]),
View dog_fsm.erl
-module(dog_fsm).
-behaviour (gen_fsm).
% gen_fsm behavior implementation
-export([ init/1, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3, code_change/4]).
% states
-export([ barks/2, wag_tail/2, sit/2]).
% test
-export([ test/0]).
View cat_fsm.erl
-module(cat_fsm).
-behaviour(gen_fsm).
% gen_fsm behavior implementation
-export([ init/1, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3, code_change/4]).
% states
-export([ dont_give_crap/3]).
% test
-export([ test/0]).
@leikind
leikind / roman_to_num.erl
Created Dec 18, 2011
Roman to decimal number converter (tail-recursive)
View roman_to_num.erl
-module(roman_to_num).
% https://github.com/ruby-fatecsp/dojos/blob/8cb15023eec6d4a5c9cdcf1723adff1ed5864a03/roman_to_numerals/lib/roman_to_num.rb
-export([convert/1, test/0]).
digit_to_num(D) ->
% io:format("~p~n", [D]),
case D of
$I -> 1;
$V -> 5;
@leikind
leikind / roman_to_num.erl
Created Dec 19, 2011
non tail-recursive version
View roman_to_num.erl
-module(roman_to_num).
% https://github.com/ruby-fatecsp/dojos/blob/8cb15023eec6d4a5c9cdcf1723adff1ed5864a03/roman_to_numerals/lib/roman_to_num.rb
-export([convert/1, test/0]).
digit_to_num(D) ->
case D of
$I -> 1;
$V -> 5;
$X -> 10;
$L -> 50;