Skip to content

Instantly share code, notes, and snippets.

View zjor's full-sized avatar
🏠
Working from home

Sergey Royz zjor

🏠
Working from home
View GitHub Profile
@zjor
zjor / mov2mp4
Last active July 30, 2023 12:59
Bash script for converting *.mov to *.mp4 with ffmpeg
#!/bin/bash
if [ $# -eq 0 ]; then
echo -e "\n\tUsage: $(basename $0) <filename.mov>\n"
exit -1
fi
INPUT=$1
FILENAME=${INPUT%.*}
@zjor
zjor / linux-security-the-complete-iptables-firewall-guide-lab-1.md
Created July 17, 2023 11:43
Challenges - The Iptables Command: Lab 1

iptables challenges 101

  1. Write the iptables commands that set the default POLICY to ACCEPT on INPUT and OUTPUT chains and DROP on FORWARD chain.
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
@zjor
zjor / FlyoutEffect.java
Created June 5, 2023 16:16
Flyout effect with JavaFX
package org.sandbox.jfx;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.embed.swing.JFXPanel;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
@zjor
zjor / TrafficLight.java
Created April 27, 2023 10:27
Implementation of a state machine, an example of a traffic light
package com.github.zjor;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.github.zjor.Sandbox.State.GREEN;
import static com.github.zjor.Sandbox.State.RED;
@zjor
zjor / generate_spiral.py
Created March 11, 2023 21:31
Generates a spiral of numbers in a matrix
RIGHT = (0, 1)
LEFT = (0, -1)
UP = (-1, 0)
DOWN = (1, 0)
def rotate(d):
if d == RIGHT:
return DOWN
elif d == DOWN:
return LEFT
@zjor
zjor / RosterBuilder.java
Created November 25, 2022 00:11
Assigns members to weeks till the specified year
package org.sandbox;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.util.Arrays;
@zjor
zjor / arduino_rp2040_mpu.ino
Created October 25, 2022 06:29
Arduino Nano RP2040: reads LSM6DSOX sensor and switches RGB LED color depending on the orientation.
#include <Arduino_LSM6DSOX.h>
#include <WiFiNINA.h>
#define TOLERANCE 0.25
enum Side {
TOP, BOTTOM, RIGHT, LEFT, FRONT, BACK
};
typedef struct {
@zjor
zjor / ZeroExERC20Swap.java
Created September 17, 2022 12:02
Swaps ERC20 tokens with 0x.org. Shows how to set target allowance.
package org.example.crypto;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.core.config.Configurator;
import org.web3j.contracts.eip20.generated.ERC20;
import org.web3j.crypto.Credentials;
import org.web3j.crypto.WalletUtils;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
@zjor
zjor / esp_idf_hue_rotation.c
Created September 13, 2022 13:45
Hue rotation of an RGB LED using ESP-IDF framework
// color_utils.h
#ifndef _COLOR_UTILS_
#define _COLOR_UTILS_
typedef struct RGB {
unsigned char r;
unsigned char g;
unsigned char b;
} rgb_t;
@zjor
zjor / esp_idf_blink.c
Created September 11, 2022 18:58
ESP-IDF blink example