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
View CalculatorTest.cs
using NUnit.Framework;
namespace Calculator.Test
{
[TestFixture]
public class CalculatorTest
{
[TestCase( 2, 2, Result = 4)]
[TestCase( -3, -4, Result = -7)]
[TestCase( 0, 0, Result = 0)]
View leaves.rb
class Hash
# {'x'=>{'y'=>{'z'=>1,'a'=>2}}}.leaves == [1,2]
def leaves
each_value.flat_map do |value|
value.respond_to?(:leaves) ? value.leaves : [value]
end
end
end
View my_formatter.rb
require 'rspec/core/formatters/progress_formatter'
require 'awesome_print'
class MyFormatter < RSpec::Core::Formatters::ProgressFormatter
def start_dump
super
current_hash = examples_to_hash(examples)
if File.exist? 'result.txt'
lines = read_log 'result.txt'
previous_hash = lines_to_hash lines
View UriExt.cs
/*++
Copyright (c) 2003 Microsoft Corporation
Module Name:
UriExt.cs
Abstract:
Uri extensibility model Implementation.
View haml.haml
%html
%ul
- (1..4).each do |x|
%p= x
@DNNX
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 ---------------------------------------------------------
setlocal
if "%1" == "" goto noArg
View README.md

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

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

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

today = Time.now
assert_tomorrow { Time.now == today } # => :failed
@DNNX
DNNX / DirectoryChecker.java
Created Jun 29, 2011
Checks if directory exists and readable
View DirectoryChecker.java
import java.io.File;
public class DirectoryChecker
{
public static boolean isWindows()
{
String os = System.getProperty("os.name").toLowerCase();
return os.indexOf("windows") != -1;
}
@DNNX
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"
end
end
end
@DNNX
DNNX / true.rb
Created May 26, 2011
True cons/car/cdr in ruby
View true.rb
def cons(x,y)
->(m) { m.call(x, y) }
end
def car(z)
z.call ->(p, q) { p }
end
def cdr(z)
z.call ->(p, q) { q }
You can’t perform that action at this time.