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.
iVBORw0KGgoAAAANSUhEUgAAAxwAAAHECAIAAAA8l7s0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAgAElEQVR4AQCmgll9Afv8/f39AP7///8AAP7+/urq6dTT09va2uTk4/Ly8fr6+wAA/wABAQAAAQAAAAABAAAAAAEBAAAAAP/////+/wAAAAEAAAAAAQAAAP8A/wAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAQEBAP//AQAAAQAAAQACAwIDBwQHCAYFBRAJCBwUER4aEBIMCgsGCAgFCQgGCAgHBgICAAULBgUOB/3//fX58vwEAQECAwL8A/72/vv2/Pn3/Pf29/8C/BUeEQ0TEP8AAP/7/wL7/wD9/wAD/wEDBPz0+/rx+wUMCg0fEf8C//77+//3/P74/f38/Pn9+fb99/gE+gITCAMLDQX7CQLzAADv+P/28+v27Pf++wACAgYCBQUBA+js7uru8e7x9e/w9e7w8gAB/wEA//7//fz6+vn5+P79/QAAAAH/AAAAAAAB/wAAAQECAgYHBwoLCwoLCgUEBAICAfn6+vTz9vT09/79/QYGAwMEAf8C/gECAAYHCAD/Bvr4//n4/QIDAwkGAyYiGSsoHSMhGAQDAfr+/QkQDv8EB/X3//Lx+//39P/99vLs7+bf6OXj6uTs8PX7+/z//wEB/wIBAQAEAgoMCw4PDBIRDhIUDg4NDAoLCgcHCAYDCAkACA0RCQUEBv35//v3/gAEAf39/AMCAQUFBAUGBQIFAvL29fr9/f/9/gUAAgwJCfsA/AAEAQMEAgIBAv/4/O7t8gEEAAYGBP/+AO7q9Pr6/AgLBwoLBwkHBgYDAwH///4C/gUIBgUHB/f5+fj8+gQEBAQBAwH+Af36//r2/vbz9/z7+QAB/AEGAv8FAAACAgD/AQD9/v7//QEEAQ4PCgsJCAcDBP3//wACAe/v8uTl7ODg6O/u7v3++v///vz7+/z7+QEA/gcLAQAB/gL/AAD9APn3/vv6/wAAAQkJ
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 - валюта, в которой рассчитывается профит