Skip to content

Instantly share code, notes, and snippets.

View avdotion's full-sized avatar
🚩
Available in t.me/avdotion

Danila Avdoshin avdotion

🚩
Available in t.me/avdotion
  • Moscow, Russia
View GitHub Profile
@avdotion
avdotion / main.cpp
Last active April 11, 2019 15:12
Sum of two squares (hypotenuse-method)
#include <iostream>
int sqr(int n) {
return n * n;
}
int main() {
int r{};
std::cin >> r;
int x{};
@avdotion
avdotion / main.js
Last active January 28, 2019 16:55 — forked from killreal17/main.js
15 puzzle
'use strict'
const readline = require('readline')
const input = readline.createInterface({
input: process.stdin,
output: process.stdout
})
input.setPrompt('> ')
# User Settings
## Set up Node Version Manager
source /usr/share/nvm/init-nvm.sh
## Env
export WALLPAPERS_HOME="/home/avdotion/Wallpapers/404339/"
alias settings="subl3 ~/.oh-my-zsh/oh-my-zsh.sh"
alias bk="cd ../"
@avdotion
avdotion / nn.js
Created August 22, 2018 09:28
Tensorflow.js NN-model
// This is the model
const model = tf.sequential();
// Create hidden layer
const hiddens = tf.layers.dense({
units: 4,
inputShape: [2],
activation: 'sigmoid'
});
@avdotion
avdotion / sketch.js
Last active August 12, 2018 22:01
Snake p5.js
const GRID_SCALE = 20;
const GRID_CELLS = 20;
const FPS = 15;
let snake;
let food;
function setup() {
createCanvas(GRID_SCALE * GRID_CELLS, GRID_SCALE * GRID_CELLS);
frameRate(FPS);
@avdotion
avdotion / .py
Created July 30, 2018 09:18
SortedDict — Python 3 Sorted dictionaty class
from bisect import insort
class SortedDict(dict):
def __init__(self):
super(dict, self).__init__()
self.sorted_keys = list()
def __setitem__(self, key, value):
super(SortedDict, self).__setitem__(key, value)
@avdotion
avdotion / flashbox.js
Created July 27, 2018 22:17
Implementations (Stack, List, Queue)
/**
* Stack implementation
* https://www.wikiwand.com/en/Stack_(abstract_data_type)
*/
export class Stack {
/**
* array implementation
* without shift (trying to be O(1) for adding and deleting)
* @param {Number} [maxsize=-1] [maxsize may be equal to -1 for dynamic]
*/
@avdotion
avdotion / source.py
Created July 17, 2018 11:17
Reading Coefs in Polynom (str to dict)
class Polynom:
def __init__(self, s):
self.coefs = self.reborn(s)
def reborn(self, source):
result = list()
coefs = dict()
source = source.split('+')
@avdotion
avdotion / arch-intallation-instruction.md
Last active August 29, 2018 08:32
Arch installation commands

Arch Installation Yokel Guide

Pay attention to zsh and swapfile

Setup the network

sudo wifi-menu

Update the Pacman database

pacman -Syyy

@avdotion
avdotion / sketch.js
Created June 11, 2018 14:29
Fractal Trees - Recursive (p5.js)
const maxRecurtionDepth = 15;
let slider, angle;
const len = 200;
function setup() {
createCanvas(600, 600);
slider = createSlider(0, PI, PI/4, PI/16);
}