Skip to content

Instantly share code, notes, and snippets.

View yakovenkodenis's full-sized avatar
:octocat:

Denis Yakovenko yakovenkodenis

:octocat:
  • Ukraine, Kharkiv
View GitHub Profile
@yakovenkodenis
yakovenkodenis / DES.py
Created May 1, 2016 09:21
DES algorithm that works with bit arrays and uses PKCS7 padding
import bitarray
import itertools
from collections import deque
class DES(object):
_initial_permutation = [
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
@yakovenkodenis
yakovenkodenis / rsa.py
Last active May 1, 2016 12:39
Simple RSA implementation that stores cipher array as a json string in base64.
import json
from random import randint
class RSA(object):
def __init__(self):
self.p, self.q = self.gen_p_q()
self.N = self.p * self.q
self.phi = self.euler_function(self.p, self.q)
@yakovenkodenis
yakovenkodenis / DES.js
Created May 26, 2016 15:29
ES6 DES implementation (with PKCS7 padding)
export default class DES {
_initial_permutation = [
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
@wojteklu
wojteklu / clean_code.md
Last active October 30, 2025 16:14
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@yakovenkodenis
yakovenkodenis / grid_search_for_wlr.py
Created October 15, 2016 17:02
Grid Search for Locally Weighted Linear Regression
import numpy as np
import pandas as pd
from statistics import mean
from sklearn.grid_search import ParameterGrid
from sklearn.preprocessing import StandardScaler
def getPredict(theta, x):
return np.dot(x, theta)
@yakovenkodenis
yakovenkodenis / cartpole.py
Last active April 29, 2019 03:58
Solving CartPole-v0 in OpenAI gym environment using tabular Q-learning
import os
import gym
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from collections import defaultdict
@yakovenkodenis
yakovenkodenis / anagram.js
Last active January 3, 2017 17:06
A function that takes an array of random words and outputs a two-dimensional array of anagrams.
// Very inefficient but purely declarative approach
const findAnagrams = words => {
const pairIsAnagram = (word1, word2) =>
word1.split('').sort()
.reduce(
(acc, el, i) => { acc[i] = el == acc[i]; return acc; },
word2.split('').sort()
)
.reduce((acc, el, i) => acc && el, true);
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
import pandas as pd
from collections import Counter
import tensorflow as tf
from tffm import TFFMRegressor
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
import numpy as np
# Loading datasets'
@artalar
artalar / map_typed.ts
Last active September 22, 2022 07:35
type M = [any, any];
type Delete<k, m extends M> = k extends m[0]
? m extends [k, any]
? never
: m
: m[0] extends k
? [unknown, unknown]
: m;
type Add<k, v, m extends M> = [k, v] | Delete<k, m>;
type Get<k, m extends M> = k extends m[0]