Skip to content

Instantly share code, notes, and snippets.

View mdusafp's full-sized avatar
🎯
Focusing

Vadim Maliutin mdusafp

🎯
Focusing
  • Grid Dynamics
  • Russia, Saint-Petersburg
View GitHub Profile
@mdusafp
mdusafp / .js
Created August 17, 2019 10:43
FP: carrying in js
const isEven = n => n % 2;
const isOdd = n => !isEven(n);
const curry = fn => (...args) => {
const closureArguments = [...args];
// arguments not enough
if (closureArguments.length < fn.length) {
return (...args) => curry(fn)(...closureArguments, ...args);
}
@mdusafp
mdusafp / .sh
Created December 13, 2018 01:13
traverse dir tree and filter files by date
#!/usr/bin/env bash
default_path="$(pwd)/file.txt"
counter=0
max_files=100
start_creation_date="Thu Dec 13 00:36:23 2018"
function scan_output_path() {
read custom_path
echo ${custom_path:-$default_path}
@mdusafp
mdusafp / .c
Last active November 26, 2017 12:13
controlling of symbol in terminal and polling of keyboard
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <linux/input.h>
#include <stdlib.h>
#define EV_PRESSED 1
// bounds
@mdusafp
mdusafp / .c
Last active November 26, 2017 12:15
graphics in c
#include <graphics.h>
void markup_ox(
const double scale_coeff,
const int max_x,
const int max_y,
const int offset_x
) {
// draw OX axis
@mdusafp
mdusafp / .cpp
Created November 8, 2017 19:38
fun with colors in terminal
#include <iostream>
#include <fstream>
#include <unistd.h>
using namespace std;
std::string to_cmd(const string &fg, const string &bg, const string &text) {
return "\033[38;5;" + fg + "m\033[48;5;" + bg + "m" + text + "\033[0m\t"
@mdusafp
mdusafp / .py
Created November 5, 2017 15:29
ACM ICP boolean satisfiability in one string
(lambda flag, deg: print(2 ** deg - 1 if flag else 2 ** deg))(*(lambda x: [
len(set(x)) == len(set([c if c[0] != '~' else c[1:] for c in x])),
len(set([c if c[0] != '~' else c[1:] for c in x]))
])(input().split('|')))
@mdusafp
mdusafp / .cpp
Last active November 6, 2017 20:08
binary representation of types
#include <typeinfo>
#include <iostream>
#include <cmath>
template<typename T>
bool get_bit(T number, int pos) {
return ((number >> pos) & 1);
}
class Coder:
def __init__(self, index, CC, TF, CCrank, TFrank, next, prev, wons):
self.index = index
self.CC = CC
self.TF = TF
self.CCrank = CCrank
self.TFrank = TFrank
self.next = next
self.prev = prev
self.wons = wons
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter44009384 = new Ya.Metrika({
id:44009384,
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
// non-working code
#include <fstream>
using namespace std;
int main()
{
long long w, h;
long long ax, ay;
long long bx, by;