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.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,
@yakovenkodenis
yakovenkodenis / wlr.md
Last active October 14, 2016 19:43
Weighted Linear Regression thoughts

Weighted Linear Regression $$ J(\theta)=\Sigma w_i (y_i - \theta^T x_i)^2 $$ $$ J'(\theta)=2\Sigma w_i x_i (\theta^T x_i - y_i) $$ $$ w_i = \exp(-\frac {(x_i - x) ^ 2} {2\tau^2}) $$

@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 / caffe.proto
Created December 10, 2016 21:00
src/caffe/proto/caffe.proto
syntax = "proto2";
package caffe;
// Specifies the shape (dimensions) of a Blob.
message BlobShape {
repeated int64 dim = 1 [packed = true];
}
message BlobProto {
@yakovenkodenis
yakovenkodenis / Makefile
Created December 11, 2016 19:39
Caffe Installation Makefiles
PROJECT := caffe
CONFIG_FILE := Makefile.config
# Explicitly check for the config file, otherwise make -k will proceed anyway.
ifeq ($(wildcard $(CONFIG_FILE)),)
$(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
endif
include $(CONFIG_FILE)
BUILD_DIR_LINK := $(BUILD_DIR)
@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);
@yakovenkodenis
yakovenkodenis / tokens.md
Created October 24, 2020 19:55 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@yakovenkodenis
yakovenkodenis / ws-server.js
Created November 14, 2022 15:43
WebSocket server from scratch in Node.js
const http = require('node:http');
const crypto = require('node:crypto');
const { setTimeout: sleep } = require('node:timers/promises');
const { EventEmitter } = require('node:events');
class WebSocketServer extends EventEmitter {
constructor(options = {}) {
super();
this.clients = new Set();
this.port = options.port || 8080;
const http = require('node:http');
const { EventEmitter } = require('node:events');
class WebSocketServer extends EventEmitter {
constructor(options = {}) {
super();
this.port = options.port || 4000;
this._init();
}