Skip to content

Instantly share code, notes, and snippets.

View sherpc's full-sized avatar

Alexander Sher sherpc

View GitHub Profile
(defn if-column
[data column f]
(if-not column
data
(f column data)))
(defn where* [data condition-func]
(if-column data condition-func filter))
(defn limit* [data lim]
if (_rules == null)
_rules = CreateRules();
return _rules;
// ...versus...
return _rules ?? (_rules = CreateRules());
@sherpc
sherpc / base.html
Last active January 3, 2016 16:19
clj->js problem
<!DOCTYPE html>
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome to sweethome</title>
</head>
<body>
<!-- navbar -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
(defmacro defn-nil
[fname args body]
`(defn ~fname ~args (if (nil? ~(first args)) nil ~body)))
(defn-nil f
[x y]
(+ x y))
(f 1 2) ;; => 3
(f nil 2) ;; => nil
# Пусть магический метод называется defnil
# Тогда обычный вариант:
def f(x,y)
return nil if x == nil
x + y
end
f(1,2) # => 3
f(nil,2) # => nil
@sherpc
sherpc / test.rb
Last active December 16, 2015 11:19
# Метод, который хотим тестировать
def det(matrix)
# fake implementation
0
end
def do_det_test(test_case)
result = det(test_case[:data])
assert_equal(result, test_case[:expected])
@sherpc
sherpc / morozov.cpp
Last active December 11, 2015 15:28
// for Morozov
void RetSignal(int status) {
if (WIFEXITED(status))
;
else if (WIFSIGNALED(status)) {
printf("ERROR: return signal %d\n", WTERMSIG(status));
}
else if (WIFSTOPPED(status)) {
printf("STOP: return signal %d\n", WSTOPSIG(status));
}
@sherpc
sherpc / lab2.cs
Created June 3, 2012 10:16 — forked from anonymous/lab2
Newton's method & simple iterations method
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace NumericalAnalysis
{
class NonlinearEquations
{
@sherpc
sherpc / Program.cs
Created May 14, 2012 20:27
RefTest
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RefTest
{
class SomeClass
{
public int SomeProperty { get; set; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NullTest
{
class SomeClass
{
}