Skip to content

Instantly share code, notes, and snippets.

View akimboyko's full-sized avatar
🙃

Akim Boyko akimboyko

🙃
View GitHub Profile
@akimboyko
akimboyko / 1natural_numbers.md
Last active December 25, 2015 17:08
Quiz from Functional Programming Principles in Scala by Martin Odersky, lecture 4.2 rewritten on C#/F#

Provide an implementation of the abstract class Nat that represents non-negative integers

Do not use standard numerical classes in this implementation. Rather, implement a sub-object and sub-class:

class Zero : Nat
class Succ(n: Nat) : Nat

One of the number zero, then other for strictly positive numbers.

@akimboyko
akimboyko / fp_types_and_recirsion_quiz_42.txt
Last active December 25, 2015 09:59
Quiz from Functional Programming Principles in Scala by Martin Odersky, lecture 4.2
Provide an implementation of the abstract class Nat that represents non-negative integers
abstract class Nat {
def isZero: Boolean
def predecessor: Nat
def successor: Nat
def + (that: Nat): Nat
def - (that: Nat): Nat
}
@akimboyko
akimboyko / week#02.scala
Created October 5, 2013 18:46
Functional Programming Principles in Scala week #02 Confusing sample with λ expression
def isCloseEnough(x : Double, y : Double) = {
val tolerance = 0.0001
Math.abs((x - y) / x) < tolerance
}
def fixedPoint(f : Double => Double)(firstGuess : Double) = {
def iterate(guess : Double) : Double = {
val next = f(guess)
if(isCloseEnough(guess, next)) next
else iterate((next + guess) / 2)
@akimboyko
akimboyko / ImmediateFunctions.fs
Created July 30, 2013 05:18
JavaScript-like immediate function in F#, am I losing sanity?
let magicSquare = (fun () ->
let randomSequence =
(seq { 1 .. N * N })
|> Seq.sortBy(fun n -> random.Next())
|> Seq.toArray
Matrix.Generic.init N N
(fun nRow nColumn -> randomSequence.[nRow * N + nColumn]))()
@akimboyko
akimboyko / FivePrincipleOfCodeGeneration.md
Created June 19, 2013 09:52
Five principle of code generation by @KathleenDollard

Five principle of code generation by @KathleenDollard

  1. Code generation has to be under your control, your control being the organization or the individual.
  2. Metadata is discreet and more morphable, and actually metadata is a subgenre all on its own.
  3. Code generation has to be an easy process. It should be a part of the normal continuous integration build process.
  4. Handcrafted code is sacred and protected.
  5. Generated code should be an equal or a better quality than nongenerated code.

From Code Generation and T4 with Kathleen Dollard, Text transcript of show #152

@akimboyko
akimboyko / EdgeJs2ClrSample.js
Created June 13, 2013 04:59
Edge.js samples: calling C# from Node.js, passing parameters and functions, and returning C# functions to be called by Node.js
var edge = require('edge');
// Call C# async lambda from node.js
// Compile source code on the fly
// Use C# dynamics to access objects passed from JavaScript
var funcCs = edge.func('cs', function() { /*
using System.Threading.Tasks;
async (dynamic input) =>
{
@akimboyko
akimboyko / SeleniumWebDriver.FireFox.csx
Last active December 18, 2015 10:09
Selenium WebDriver integration testing using ScriptCs. FireFox and PhantomJs drivers are used
// load all require references
#r "System.Drawing"
#r "D:\work\Courses\MetaProgramming\Snippets\Scripting\ScriptCs\SeleniumWebDriver\bin\WebDriver.dll"
#r "D:\work\Courses\MetaProgramming\Snippets\Scripting\ScriptCs\SeleniumWebDriver\bin\WebDriver.Support.dll"
#r "D:\work\Courses\MetaProgramming\Snippets\Scripting\ScriptCs\SeleniumWebDriver\bin\nunit.framework.dll"
#r "D:\work\Courses\MetaProgramming\Snippets\Scripting\ScriptCs\SeleniumWebDriver\bin\FluentAssertions.dll"
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
@akimboyko
akimboyko / 1readme.md
Last active October 22, 2018 08:45
ScriptCs as embedded scripting engine for .Net application with NuGet support

ScriptCs as embedded scripting engine for .Net application with NuGet support

This gist contains:

  • ExecuteScriptCs.cs — class that are able to execute ScriptCs from another .Net application
  • ScriptModule.cs — AutoFac configuration for ScriptCs/NuGet dependencies
  • Program.cs — command-line example
  • Sample.csx — sample ScriptCs script
  • packages.config — NuGet packages configuration

К завтрашнему тренингу по JavaScript просьба установить самостоятельно или с помощью Chocolatey:

  • Node JS; или cinst nodejs.install и cinst nodejs.commandline
  • Установить git: cinst git
  • Редактор или IDE на выбор:
  • Sublime Text или cinst sublimetext2
  • Live Reload + plugin для Вашего браузера
  • unzip itera-training.zip
  • cd itera-training
  • npm -g install bower
@akimboyko
akimboyko / test.html
Last active December 18, 2015 04:08
Sample for Mocha that supports both NodeJs Mocha runner and RequireJs + Browsers + LiveReload
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link rel="stylesheet" href="css/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="scripts/require.js"></script>
<script>