Skip to content

Instantly share code, notes, and snippets.

@salamantos
salamantos / README.md
Created December 3, 2020 18:24
Word counter in bash/awk

Counts number of occurences of each word in text

Run:

chmod +x map.sh reduce.sh
./map.sh macbeth.txt > output.txt
vim output.txt

Requires linux (tested on Ubuntu 20.04)

@salamantos
salamantos / parse_dependencies.py
Created March 19, 2020 18:55
Parse python libraries
import re
from typing import List
def parse_dependencies(file_path: str) -> List[str]:
"""
:param file_path - path of file to be parsed
:return list of strings
Example file.py:
@salamantos
salamantos / t.txt
Created February 24, 2019 11:49
field tree list
[
{
"id": "5c68190151dc694e2e033f72",
"name": "Test 1",
"wells": []
},
{
"id": "5c681f3551dc694e2e033f73",
"name": "Тестовое месторождение",
"wells": [
This file has been truncated, but you can view the full file.
Retrieved: b'Digitized by the Internet Archive \n'
Traceback (most recent call last):
File "/home/salamantos/projects/dropbox_november/test.py", line 145, in <module>
verifying_key=alices_verifying_key1)
File "/home/salamantos/projects/dropbox_november/nucypher/characters/base.py", line 350, in decrypt
return self._crypto_power.power_ups(EncryptingPower).decrypt(message_kit, verifying_key)
File "/home/salamantos/projects/dropbox_november/nucypher/keystore/keypairs.py", line 104, in decrypt
decrypting_key=self._privkey,
File "/home/salamantos/.local/share/virtualenvs/dropbox_november-LD2SWqYs/lib/python3.7/site-packages/umbral/pre.py", line 487, in decrypt
encapsulated_key = _open_capsule(capsule, decrypting_key, check_proof=check_proof)
#pragma once
#include <tpcc/stdlike/atomic.hpp>
#include <tpcc/stdlike/condition_variable.hpp>
#include <tpcc/stdlike/mutex.hpp>
#include <tpcc/support/compiler.hpp>
#include <algorithm>
#include <forward_list>
@salamantos
salamantos / A
Created March 26, 2018 12:24
heuristic
int inline heuristic( vector<int>& boardVector )
{
// Manhattan distance
int res = 0;
for (size_t i = 0; i < 16; i++) {
if (boardVector[i] != 0) {
res += abs( x[boardVector[i]] - maskX[i] );
res += abs( y[boardVector[i]] - maskY[i] );
}
}
#include <assert.h>
#include <fstream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
using namespace std;
//const vector<int> goal = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0 }; // Положение фишек, до которого нужно дойти
def plot_laba():
x = table_0.values[:, 0]
y = table_0.values[:, 3]
k = table_0.values[0, 3]
b = 0
dx = np.zeros(len(table_0.values))
dy = table_0.values[:, 5]
plt.figure(figsize=(15,6))
plt.grid(linestyle='--')
@salamantos
salamantos / Buy_sell.py
Created February 7, 2018 11:22
Расчет выгоды от покупки и продажи валюты
FEE = 0.001
REBATE = 0.0001
USDT = 1.0
RUB = 56.0
# Buy coins; sell coins; profit in USDT
def count_profit(byu_price, sell_price, amount, currency = USDT):
"""
Цена покупки/продажи в USDT; currency - валюта, в которой рассчитывается профит