Skip to content

Instantly share code, notes, and snippets.

@leikind
leikind / wice_grid.coffee
Created July 6, 2011 12:55
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
@leikind
leikind / wice_grid.coffee.js
Created July 6, 2011 12:55
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 August 7, 2011 18:59
Infinite multidimensional game of life with configurable rules :)
# 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]))
-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 September 27, 2015 21:58
Infinite multidimensional game of life with configurable rules :)
-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 November 18, 2011 18:02
exit/1, exit/2, link, trap_exit
-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()]),
-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]).
-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 December 18, 2011 23:00
Roman to decimal number converter (tail-recursive)
-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 December 19, 2011 08:28
non tail-recursive version
-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;