Skip to content

Instantly share code, notes, and snippets.

View izebit's full-sized avatar
🖖
mia san mia

Artem Konovalov izebit

🖖
mia san mia
View GitHub Profile
import datetime as dt
class Record:
def __init__(self, amount, comment, date=''):
self.amount = amount
# подобное присваивание читается сложнее, чем аналогичное с использованием конструкции вида
# if (...):
# self.date =
# else :
@izebit
izebit / chess.java
Created November 12, 2020 09:29
chess.java
public static boolean canMove(final String chessPiece,
final String currentLocationStr,
final String targetLocationStr) {
class Position {
private int x;
private int y;
public Position(String position) {
this.x = Character.toUpperCase(position.charAt(0)) - 'A';
this.y = position.charAt(1) - '1';
class IteratorWrapper implements Iterator<String> {
private Iterator<?> i1;
private Iterator<?> i2;
private String value;
IteratorWrapper(Iterator<?> iterator) {
this.i1 = iterator;
this.i2 = Collections.emptyIterator();
}
private static class CustomStackImpl<T extends Comparable<? extends T>> {
private final Node<T> EMPTY = new Node<>(null, null, null, -1);
private int counter = 0;
private Node<T> head = EMPTY;
private final TreeMap<T, SortedSet<Node<T>>> orderedMap = new TreeMap<>();
public T push(T x) {
int index = counter++;
head = head.add(x, index);
@izebit
izebit / falling-boulder.js
Created August 8, 2018 04:24
Falling boulder, processingJS
angleMode = "radians";
var Boulder = function(m, x, y) {
this.position = new PVector(x, y);
this.mass = m;
this.width = this.mass * 10;
this.angle = 0;
this.aVelocity = 0;
this.aAcceleration = 0;
@izebit
izebit / attraction.js
Created July 29, 2018 19:32
example-with-attraction-processing.js
var G = 1;
var Mover = function(m, x, y) {
this.mass = m;
this.position = new PVector(x, y);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
};
Mover.prototype.applyForce = function(force) {
// Adapted from Dan Shiffman, natureofcode.com
// Attractor: An object type for a draggable attractive body in our world
var Attractor = function() {
this.position = new PVector(width/2, height/2);
this.mass = 20;
this.G = 1;
this.dragOffset = new PVector(0, 0);
this.dragging = false;
this.rollover = false;
@izebit
izebit / mouse-walker.js
Created July 21, 2018 19:42
mouse-walker fanny animation
#this example uses processing.js library
var maxDir = new PVector(width,height);
var maxMag = maxDir.mag();
var Mover = function() {
this.position = new PVector(width/2, height/2);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
};
@izebit
izebit / ZookeeperExample.java
Created May 24, 2018 12:21
zookeeper example - client and server
package ru.izebit;
import org.I0Itec.zkclient.ZkClient;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
import java.io.File;
import java.net.InetSocketAddress;
@izebit
izebit / TestExample.java
Created April 29, 2018 22:36
throw new Object()
package ru.izebit;
import org.apache.bcel.Const;
import org.apache.bcel.generic.*;
import java.io.FileOutputStream;
/**
* @author <a href="izebit@gmail.com">Artem Konovalov</a> <br/>
* Date: 27/04/2018/.