Skip to content

Instantly share code, notes, and snippets.

View 3Hren's full-sized avatar
:shipit:
WAT?

Evgeny Safronov 3Hren

:shipit:
WAT?
View GitHub Profile
<Custom measure="call" label="Workers: active">cocaine-tool info --name=ruby-v0.12 | python -c "import json, sys; c = json.loads(sys.stdin.read()); r = c['apps']['ruby-v0.12']['slaves']['active']; sys.stdout.write(str(r))"</Custom>
<Custom measure="call" label="Workers: idle">cocaine-tool info --name=ruby-v0.12 | python -c "import json, sys; c = json.loads(sys.stdin.read()); r = c['apps']['ruby-v0.12']['slaves']['idle']; sys.stdout.write(str(r))"</Custom>
python -c 'import time; print(time.strftime("%a, %d %b %Y %H:%M:%S %z", time.localtime()))'
@3Hren
3Hren / gist:dab2b08a472cc1a3f09c
Created March 25, 2014 13:54
Half-compile-time attribute extractor.
mixin template UriBasedRequest(T) {
public string uri() @property const {
UriBuilder builder = new UriBuilder();
string[] paths;
foreach (memberName; __traits(allMembers, T)) {
// TODO: Iterate only over fields.
alias Member = TypeTuple!(__traits(getMember, this, memberName))[0];
alias MemberType = typeof(Member);
@3Hren
3Hren / gist:6479124
Created September 7, 2013 20:43
Compile-time simple format string check.
template<typename T>
struct FormatTraits;
template<std::size_t N>
struct FormatTraits<char[N]> {
constexpr static bool supports(char c) {
return c == 's';
}
};