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
@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';
}
};
@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);
python -c 'import time; print(time.strftime("%a, %d %b %Y %H:%M:%S %z", time.localtime()))'
<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>
sudo dpkg -i ../*`dpkg-parsechangelog | sed -n 's/^Version: //p'`*.deb
@3Hren
3Hren / BF
Created September 16, 2015 14:29
KoKoKoKoKoKoKoKoKoKo KudKudah KoKoKoKoKoKoKoKoKudahKoKoKoKoKoKoKoKoKoKoKoKudahKoKoKo kudah kudah kudah kO kud Kudah KoKoKoKo Kukarek
KudahkOkOkOkOkO Kukarek
KudahKoKo Kukarek
kudahKoKoKoKoKoKoKo Kukarek
kOkOkOkOkOkOkO Kukarek
kOkOkOkOkO Kukarek
KoKoKoKoKoKoKoKoKoKoKo Kukarek
KoKoKo Kukarek
@3Hren
3Hren / gist:921d34af687ff8d5d26d
Created February 11, 2016 14:32
BOOST PP MAGIC
#include <boost/preprocessor/comparison/not_equal.hpp>
#include <boost/preprocessor/punctuation/remove_parens.hpp>
#include <boost/preprocessor/tuple/pop_back.hpp>
#include <boost/preprocessor/tuple/push_back.hpp>
#include <boost/preprocessor/tuple/reverse.hpp>
#include <boost/preprocessor/variadic/to_array.hpp>
#define __COCAINE_LOG_IS_NEW_SYNTAX(...) \
BOOST_PP_NOT_EQUAL(1, \
BOOST_PP_LIST_FIRST( \
sudo: required
services:
- docker
language: cpp
env:
global:
- COMMIT=${TRAVIS_COMMIT::8}
#[test]
fn from_str_strfix_decode_buf() {
// Wrap an incomplete buffer into the Cursor to see how many bytes were consumed.
let mut cur = Cursor::new(vec![0xaa, 0x6c, 0x65, 0x20, 0x6d, 0x65, 0x73]);
assert!(read_str_from_buf_read(&mut cur).is_err());
// Did not read anything actually.
assert_eq!(0, cur.position());

Hub as a Gateway

Miners are required to have a public IP address and a properly configured firewall to make all things work properly. But sometimes it is not possible due to either security, privacy or provider limitations. This also includes miners behind the NAT.

To be able to work with these miners a Hub can be configured as a gateway.

Note: we assume that it is possible to build a private network between Hub and miners.

NAT