Skip to content

Instantly share code, notes, and snippets.

View Brutt's full-sized avatar

Ukraїner Brutt

View GitHub Profile
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Created by Red8 on 20/03/2018.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Inject {
Class clazz();
}
import java.io.IOException;
import java.io.InputStream;
public class BufferedInputStream extends InputStream {
private InputStream inputStream;
private byte[] buffer = new byte[5];
private int start;
private int count;
public BufferedInputStream(InputStream inputStream) {
import java.io.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
public class LogAnalyzer {
public ArrayList<LogToken> getSuitableLogTokensFromFile(String path, LocalDateTime timeFrom, LocalDateTime timeTo) throws IOException {
ArrayList<LogToken> logTokens = new ArrayList<>();
BufferedReader bufferedReader = new BufferedReader(new FileReader(path));
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class HashMap<K, V> implements Map<K, V> {
@SuppressWarnings("unchecked")
private List<Entry<K, V>>[] buckets = new List[5];
private int size;
public HashMap() {
@Brutt
Brutt / ArrayQueue
Last active January 25, 2018 08:43
25.01.2018
import java.util.NoSuchElementException;
public class ArrayQueue extends Queue {
private Object[] array = new Object[5];
private int pointStart;
private void addCapacity() {
Object[] newArray = new Object[(int) (1.5 * array.length)];
System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
@Brutt
Brutt / DecToBin
Last active January 24, 2018 08:44
5. принимает массив байт, если в массиве есть повторяющиеся елементы, возвращает тру
public class DecToBinary {
String getBinary(int number, int outputLength){
if (number==0){
return "0";
}
String strNumber = "";
while (!((number/2==0)&&(number%2==1))){
strNumber = (number % 2) + strNumber;
number = number / 2;
}
@Brutt
Brutt / COM-ports
Created July 10, 2017 10:18
Get the list of available COM-ports from Windows Registry
uses Registry;
procedure getCOM_ports();
var
reg: TRegistry;
st: Tstrings;
begin
reg := TRegistry.Create(KEY_READ);
try
reg.RootKey := HKEY_LOCAL_MACHINE;
@Brutt
Brutt / CANames
Created July 5, 2017 06:13
CANames backup
/*
The name + type results of these queries will be used by the Code Assistant
if the "Describe Context" option is enabled. After typing 3 or more characters
the Code Assistant will show a list of matching names.
Separate multiple queries with semi-colons and use the :schema bind variable
to restrict names to the currently connected user.
In case of an error the query results will be omitted. No error message will
be displayed.
Place this file in the PL/SQL Developer installation directory for all users,
or in the "%APPDATA%\PLSQL Developer" directory for a specific user.
@Brutt
Brutt / ultrasonic_sensor_4wd_robot_arduino
Created April 1, 2017 12:18
From Youtube, corrected code for 4wd robot arduino and ultrasonic sensor
#include <Servo.h>
Servo myservo;
int enableA = 1;
int pinA1 = 3;
int pinA2 = 2;
int servposnum = 0;
int servpos = 0;
int enableB = 6;
@Brutt
Brutt / 4wd_robot_arduino_bluetooth
Created April 1, 2017 12:10
4wd robot arduino bluetooth control
int enableA = 1;
int pinA1 = 3;
int pinA2 = 2;
int enableB = 6;
int pinB1 = 5;
int pinB2 = 4;
char state = '0';