Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
namespaces=(
"github.com/disolovyov"
"bitbucket.org/disolovyov"
)
function gopath() {
if [ -z "$1" ]; then
echo "Usage: gopath PROJECT"
use std::char;
use std::collections::HashMap;
use std::sync::{Arc, Barrier};
use std::sync::mpsc::{Sender, channel};
use std::thread;
const NTHREADS: u32 = 5;
fn slow(n: u32) -> char {
thread::sleep_ms(n);
use std::fmt;
use std::ops;
enum Nat {
Zero,
Succ(Box<Nat>)
}
impl ops::Add for Nat {
type Output = Nat;
@disolovyov
disolovyov / frp.js
Created November 2, 2013 11:46
Coding Dojo: Functional Reactive Programming with JavaScript
var Signal = function(value) {
this.value = value;
this.callbacks = [];
};
Signal.prototype.setValue = function(value) {
if (value == null) {
return;
}
this.value = value;
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;
}
@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>
[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 / 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())
@disolovyov
disolovyov / gist:5075712
Last active December 14, 2015 10:59
Choose the next LDN event
@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