Skip to content

Instantly share code, notes, and snippets.

View zefirka's full-sized avatar
🤔

Trdat Mkrtchyan zefirka

🤔
View GitHub Profile
@zefirka
zefirka / README.md
Created July 6, 2018 21:45 — forked from quagliero/README.md
Installing cpuminer-multi on macOS 10.13.2 (High Sierra)

Installing cpuminer-multi on macOS 10.13.2 (High Sierra)

This assumes you have brew installed and are comfortable using a terminal.

Following the guide on https://github.com/tpruvot/cpuminer-multi will likely lead to errors about invalid paths to OpenSSL, and neoscrypt errors to the tune of Undefined symbols for architecture x86_64 during the build. I managed to piece together different fixes into an installation that has worked for me. So I hope it works for you.

Requirements

Ensure a c compiler is installed. Type g++ in the terminal and continue with the xcode installation if necessary. If it prints clang: error: no input files, then you can proceed.

const crypto = require('crypto');
const cluster = require('cluster');
const [_, __, ALGO = 'sha256', DIFF = '32', forks = 4] = process.argv;
const FORK_ID = process.env.FORK_ID;
const hash = data => crypto.createHash(ALGO).update(data);
const hashBlock = ([prevBlockHash, data, salt]) => hash([salt, prevBlockHash, JSON.stringify(data)].join(''));
class Block {
@zefirka
zefirka / ExtraNonceGenerator.js
Created September 22, 2017 16:47
ExtraNonceGenerator
function packUInt32BE(num) {
const buff = new Buffer(4);
buff.writeUInt32BE(num, 0);
return buff;
}
function pad(n, v, i = '0') {
return v.length < n ? new Array(n - v.length).fill(i).join('') + v : v
}
@zefirka
zefirka / reduce.py
Created February 16, 2017 11:35
Python reduce implementation
def my_reduce(fn, lst, initial=None):
start = 0
if not initial:
result = lst[0]
start = 1
else:
result = initial
while start < len(lst):
result = fn(result, lst[start])
start += 1
a = 0
def incer():
def inc():
global a
a+=1
return a
return inc
def sm(x=incer()):
@zefirka
zefirka / words.js
Created August 22, 2016 14:11
Word counter
'use strict';
const {readFile} = require('fs');
const uniq = (res, x) => {
if (!~res.indexOf(x)){
res.push(x);
};
return res;
import json
import utils
def read_json(filename):
with open(filename, 'r') as jsonfile:
content = jsonfile.read()
return json.loads(content)
def write_json(filename, struct):
with open(filename, 'w+') as jsonfile:
class Product:
'Class for products'
def __init__(self, name, cost, cur='₽'):
self.name = name
self.cost = int(cost)
self.cur = cur
def __str__(self):
return'Product: < name: {0.name}, cost: {0.cost}{0.cur}>'.format(self)
class Product:
'Class for products'
def __init__(self, name, cost, cur='₽'):
self.name = name
self.cost = int(cost)
self.cur = cur
def __str__(self):
return'Product: < name: {0.name}, cost: {0.cost}{0.cur}>'.format(self)
class User:
rights = ['read']
def __init__(self, name, age):
self.name = name
self.age = int(age)
def __str__(self):
return 'User: <name: {name}, age: {age}>'.format(name=self.name, age=self.age)