Skip to content

Instantly share code, notes, and snippets.

View fxposter's full-sized avatar

Pavlo fxposter

View GitHub Profile
@fxposter
fxposter / README.md
Created October 20, 2015 10:20
Ruby quiz

Представьте что у вас есть некий класс API, который вы хотите использовать. Но вместо того чтобы всегда и везде писать api.method(args) вы хотите просто писать use_dsl { method(args) } внутри вашего обьекта.

Имея следующие классы, соответственно, API и его клиента реализуйте метод use_dsl так, чтобы получить такой вот результат:

client = Client.new(ThirdPartyAPI.new)

client.run_local_variable
# Output:
'use strict';
class Executor {
constructor(maxTasksInParallel) {
this._maxTasksInParallel = maxTasksInParallel;
this._currentTasks = 0;
this._queue = [];
}
start(task) {
$ docker ps -a
3b64a3316725 image:tag "entrypoint.sh" 13 days ago Dead
252a55928f11 image2:tag "forever index.js" 2 weeks ago Dead
$ docker rm 3b64a3316725 252a55928f11
Error response from daemon: Cannot destroy container 3b64a3316725: Driver aufs failed to remove root filesystem 3b64a3316725c30f7d9d9c77c52addf595e8ba08cb75e56cf513353a78bbf31b: rename /var/lib/docker/aufs/mnt/3b64a3316725c30f7d9d9c77c52addf595e8ba08cb75e56cf513353a78bbf31b /var/lib/docker/aufs/mnt/3b64a3316725c30f7d9d9c77c52addf595e8ba08cb75e56cf513353a78bbf31b-removing: device or resource busy
Error response from daemon: Cannot destroy container 252a55928f11: Driver aufs failed to remove root filesystem 252a55928f11a95d9f885383f53275b3d134dfb5f95bebec5e5c41c59ba8ee15: rename /var/lib/docker/aufs/mnt/252a55928f11a95d9f885383f53275b3d134dfb5f95bebec5e5c41c59ba8ee15 /var/lib/docker/aufs/mnt/252a55928f11a95d9f885383f53275b3d134dfb5f95bebec5e5c41c59ba8ee15-removing: de
$ brew reinstall mono
==> Reinstalling mono
==> Downloading https://homebrew.bintray.com/bottles/mono-3.12.1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/mono-3.12.1.yosemite.bottle.tar.gz
==> Pouring mono-3.12.1.yosemite.bottle.tar.gz
==> Caveats
To use the assemblies from other formulae you need to set:
export MONO_GAC_PREFIX="/usr/local"
==> Summary
🍺 /usr/local/Cellar/mono/3.12.1: 1131 files, 219M
SIGABRT: abort
PC=0x5fb6c8
goroutine 308297 [syscall, 4433 minutes]:
syscall.Syscall6(0x3d, 0x10a0c, 0xc2084e3aec, 0x0, 0xc2084b86c0, 0x0, 0x0, 0xc208433400, 0x347, 0x3b7)
/usr/local/go/src/syscall/asm_linux_amd64.s:46 +0x5 fp=0xc2084e3a50 sp=0xc2084e3a48
syscall.wait4(0x10a0c, 0xc2084e3aec, 0x0, 0xc2084b86c0, 0x90, 0x0, 0x0)
/usr/local/go/src/syscall/zsyscall_linux_amd64.go:124 +0x79 fp=0xc2084e3ab0 sp=0xc2084e3a50
syscall.Wait4(0x10a0c, 0xc2084e3b34, 0x0, 0xc2084b86c0, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/syscall_linux.go:224 +0x60 fp=0xc2084e3af8 sp=0xc2084e3ab0
@fxposter
fxposter / group_by.clj
Last active October 7, 2015 03:07
group-by as a transducer
(defn group-by [f]
(fn [rf]
(let [groupped-value (volatile! (transient {}))]
(fn
([] (rf))
([result]
(rf (rf result (persistent! @groupped-value))))
([result input]
(let [key (f input)]
(vswap! groupped-value assoc! key (conj (get @groupped-value key []) input))
@fxposter
fxposter / keybase.md
Created October 29, 2014 14:20
keybase.md

Keybase proof

I hereby claim:

  • I am fxposter on github.
  • I am fxposter (https://keybase.io/fxposter) on keybase.
  • I have a public key whose fingerprint is C3E9 634A 49DC 9EA6 4B86 25AA AE8A BD4F E714 9770

To claim this, I am signing this object:

def one
yield 1
end
def a
one { |x| yield x }
end
def b(&block)
one(&block)
@fxposter
fxposter / product.rb
Last active August 29, 2015 13:58 — forked from scaint/product.rb
class Product < ActiveRecord::Base
end
def check
yield
rescue => e
e
end
check { "hello, #{1}" } # ?
check { "hello, " + 1 } # ?
check { "hello, " << 1 } # ?