Skip to content

Instantly share code, notes, and snippets.

@disolovyov
disolovyov / TypeClass.hs
Created October 11, 2012 14:51 — forked from tonymorris/TypeClass.hs
Type-class hierarchy
{-# LANGUAGE NoImplicitPrelude, MultiParamTypeClasses, Rank2Types, TypeOperators #-}
newtype Id a =
Id a
data a :\/ b =
Left a
| Right b
data a :/\ b =
@disolovyov
disolovyov / resources.md
Created October 25, 2012 06:43
Resources for FP class @ 8-bit Panda

Functional Programming

Below is the material for lectures and sessions we've had so far, crammed into one file. When only concrete parts of a book chapter are required for understading, it is marked as such in parenthesis. Which is not to say it is forbidden to read whole chapters and learn new things outside of class.

Lecture: Essential Ideas

  • Functional programming
@disolovyov
disolovyov / gist:4126329
Created November 21, 2012 17:36
Lambdabot on OS X with Homebrew
brew install readline && \
cabal install readline --extra-include-dirs=/usr/local/Cellar/readline/6.2.4/include --extra-lib-dirs=/usr/local/Cellar/readline/6.2.4/lib --configure-option=--with-readline-includes=/usr/local/Cellar/readline/6.2.4/include --configure-option=--with-readline-libraries=/usr/local/Cellar/readline/6.2.4/lib && \
cabal install lambdabot
package checked.exceptions.suck;
public class RuntimeAllTheThingsHelper {
public interface RuntimeAllTheThings<T> {
T runLikeABoss() throws Exception;
}
public static <T> T runLikeABoss(RuntimeAllTheThings<T> block) {
try {
@disolovyov
disolovyov / class.lua
Last active December 12, 2015 04:58
Simple classes for Lua
--[[
No-nonsense classes for Lua.
Basic usage:
A = class() -- class declaration
B = class(A) -- inheritance
function A:init(arg, arg ...) -- constructor
function A:foo(arg, arg ...) -- method declaration
a = A(arg, arg ...) -- construction
@disolovyov
disolovyov / gist:5075712
Last active December 14, 2015 10:59
Choose the next LDN event
@disolovyov
disolovyov / 0.md
Last active December 16, 2015 16:19
Workshop: Google Go on App Engine
  • [App Engine Go SDK][appengine-go-sdk]
  • [App Engine Go manual][appengine-go-manual]
  • [Go Specification][go-spec]
  • [Go standard library docs][go-core-docs]
  • Go's [error handling][thispltlife]. You can try figuring it out: there's a [blog post][errors-blog] and a [book section][errors-book]. Alternatively, you can give up and use two error-handling functions provided below.
func error2(err error, c appengine.Context) bool {
    if err != nil {
 c.Errorf("%v", err.Error())
[29.04.2013 15:05:41] Alexey Buzdin:
assertThat(jonSnow.knows(any(Object.class), is(true)))
AssertionError!
[29.04.2013 15:09:21] Dimitry Solovyov:
class JonSnow {
public <T> boolean knows(T subject) {
return false;
}
}
@disolovyov
disolovyov / graphite.apacheconf
Last active December 18, 2015 00:28
Sample Apache config for graphite-web
# You need to manually edit this file to fit your needs.
# This configuration assumes the default installation prefix
# of /opt/graphite/, if you installed graphite somewhere else
# you will need to change all the occurances of /opt/graphite/
# in this file to your chosen install location.
<IfModule !wsgi_module.c>
LoadModule wsgi_module modules/mod_wsgi.so
</IfModule>
public class Batcher<T> {
private class Batch<T> {
private final Collection<T> items = new ConcurrentLinkedQueue<>();
private final AtomicInteger permits = new AtomicInteger();
private Collection<T> getItems() {
return items;
}