Skip to content

Instantly share code, notes, and snippets.

Viktar Basharymau DNNX

Block or report user

Report or block DNNX

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
DNNX / gcj_solver.rb
Created May 14, 2011
GCJ 2011 CandySplitting problem
View gcj_solver.rb
class GCJSolution
def initialize(input = STDIN, output = STDOUT)
@input = input
@output = output
def read_strings
@input.gets.chomp.split(' ')
DNNX / magicka.rb
Created May 15, 2011
Solution of GCJ's Magicka problem
View magicka.rb
RUN_TEST = false
require 'set'
require 'test/unit' if RUN_TEST
class Magicka
def initialize(combines, opposes)
@combs = build_combs(combines)
@opps = build_opps(opposes)
@counts =
DNNX / cons.rb
Created May 26, 2011
cons/car/cdr in ruby
View cons.rb
def cons(x, y)
->(label) do
case label
when :first then x
when :second then y
else raise "Argument is neither :first nor :second -- cons"
DNNX / true.rb
Created May 26, 2011
True cons/car/cdr in ruby
View true.rb
def cons(x,y)
->(m) {, y) }
def car(z) ->(p, q) { p }
def cdr(z) ->(p, q) { q }
Created Jun 29, 2011
Checks if directory exists and readable
public class DirectoryChecker
public static boolean isWindows()
String os = System.getProperty("").toLowerCase();
return os.indexOf("windows") != -1;

This simple framework allows you to assert things that should happen tomorrow*. For example:

assert_tomorrow { == 2 } # => :passed
                                       # assuming today is Monday (i.e. wday == 1)

Another example shows that the time will never be the same again:

today =
assert_tomorrow { == today } # => :failed
DNNX / which.cmd
Created Jul 19, 2011
Windows equivalent of Unix which command by Pankaj Kumar
View which.cmd
@echo off
rem --------------------------------------------------------
rem File: which.cmd
rem Description: Windows equivalent of Unix which command
rem Author: Pankaj Kumar
rem Copyright 2004 Pankaj Kumar. All Rights Reserved.
rem License: This software is available under GPL
rem ---------------------------------------------------------
if "%1" == "" goto noArg
View haml.haml
- (1..4).each do |x|
%p= x
View UriExt.cs
Copyright (c) 2003 Microsoft Corporation
Module Name:
Uri extensibility model Implementation.
View my_formatter.rb
require 'rspec/core/formatters/progress_formatter'
require 'awesome_print'
class MyFormatter < RSpec::Core::Formatters::ProgressFormatter
def start_dump
current_hash = examples_to_hash(examples)
if File.exist? 'result.txt'
lines = read_log 'result.txt'
previous_hash = lines_to_hash lines
You can’t perform that action at this time.