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 / semxx.c
Last active April 21, 2023 09:58
#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include "console.h"
#include "cpu/isr.h"
#include "drivers/keyboard.h"
#include "drivers/port.h"
#include "drivers/uart.h"
#include "drivers/vga.h"
enum {
PIT_CRYSTAL_HZ = 1193182,
// 0..4294967295
// buf.len() after stripping leading zeros must be >= 16.
pub fn parse_u32(buf: &[u8]) -> Result<(&[u8], u32), ExpectedDecNumber> {
const RANGES: [u8; 16] = [b'0', b'9', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const SHUFFLE_MASK: [u8; 16] = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
const FACTOR1: [u16; 8] = [1, 10, 100, 1000, 1, 10, 100, 1000];
const FACTOR2: [u32; 4] = [1, 10000, 100000000, 0];
let mut zi = 0;
let len = buf.len();
#!/usr/bin/env ruby
require 'git'
require 'logger'
require 'optparse'
require 'semantic'
require 'semantic/core_ext'
require 'tempfile'
require 'tty-prompt'

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

#[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());
sudo: required
services:
- docker
language: cpp
env:
global:
- COMMIT=${TRAVIS_COMMIT::8}
@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( \
@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
sudo dpkg -i ../*`dpkg-parsechangelog | sed -n 's/^Version: //p'`*.deb