Skip to content

Instantly share code, notes, and snippets.

View driversti's full-sized avatar
🦝
Have been making 🪲 since birth

Yurii Chekhotskyi driversti

🦝
Have been making 🪲 since birth
View GitHub Profile
@driversti
driversti / calculator.java
Created July 27, 2015 18:30
Simple Calculator
package lesson5.mycalculator;
import javax.swing.*;
import java.awt.*;
public class Calculator {
// Объявление всех компонентов калькулятора.
JPanel windowContent;
JTextField displayField;
@driversti
driversti / LoggingFilter.java
Created January 11, 2018 11:33 — forked from baberali/LoggingFilter.java
Instead of writing your own classes to cache request response for logging, Spring provides a couple of useful classes i.e. ContentCachingRequestWrapper and ContentCachingResponseWrapper. These classes can be utilized very effectively, for example, in the following little filter:
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@driversti
driversti / README.md
Created December 3, 2021 12:50 — forked from moonmilk/README.md
manually authorize a twitter app to a twitter account

So you're writting a twitterbot and you need to authorize your application to post to the account. You need an access token and secret for the account you're posting to. If the posting account is the same account that owns the application, no problem, you just push the button on your application's settings page to make the keys. But if you want to post to a different twitter account, there's no UI on apps.twitter.com to authorize it. So I made this bare-minimum node server to run through the authorization process. There's probably a much better way to do this, so please let me know what that way is!

ignore this and go down to the comments for better solutions

  • You'll need a server with node.js!
  • Make sure your application has a callback URL specified in its settings page, even if it's just a placeholder. If there's nothing in the callback URL slot, this method of authorization won't work.
  • In authorize.js, fill in your application's consumer key and secret, and the domain on which you'll be running th
@driversti
driversti / ListsRealTest.groovy
Created December 13, 2021 06:13
OAuth 1.0a Twitter API example
import static java.lang.String.format
import static java.net.http.HttpRequest.BodyPublishers
import static java.net.http.HttpResponse.BodyHandlers
import com.github.driversti.twittygram.utils.PercentUtil
import com.github.driversti.twittygram.utils.SignatureUtil
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.time.Instant
import org.apache.commons.lang3.RandomStringUtils
#!/bin/bash -x
DESTS=( "http://duma.gov.ru/" "http://president-sovet.ru/" "https://sovetnational.ru/" "https://www.gosuslugi.ru/ru/" "https://zakupki.gov.ru/epz/main/public/home.html" "https://gossluzhba.gov.ru/" "http://defence.council.gov.ru/" "http://budget.council.gov.ru/" "http://www.kremlin.ru/" "https://government.ru/" "http://www.scrf.gov.ru/" "http://www.ksrf.ru/ru/Pages/default.aspx" "http://www.vsrf.ru/" "http://premier.gov.ru/events/" "https://www.mchs.gov.ru/" "https://minjust.gov.ru/ru/" "http://www.fsb.ru/" "https://rosguard.gov.ru/" "https://customs.gov.ru/" "https://udprf.ru/" "http://favt.gov.ru/" "http://194.67.2.109:53/UDP" "http://194.67.7.1:53/UDP" "http://194.54.14.187:53/UDP" "http://194.54.14.186:53/UDP" )
TIME="180s"
while TRUE
do
for DEST in ${DESTS[@]}
@driversti
driversti / endorse_and_travel.sh
Last active April 11, 2023 11:19
The commands allow you to automate endorsing and traveling in eRepublik during the Spring Break event.
=== ENDORSES ===
Open the browser's console and paste the command:
for(let i=0;i<=220;i++){setTimeout(()=>{fetch('https://www.erepublik.com/en/main/donate-article',{method:'POST',headers:{'content-type':'application/x-www-form-urlencoded','cookie':`erpk=${erepublik.settings.pomelo.authToken}`},body:`articleId=${2765400+i}&amount=5&_token=${SERVER_DATA.csrfToken}`,compress:true})},5000*i);}
Press Enter. In about 17,5 min you will have about 200 endorses of 5сс
=== TRAVELLING ===
// ==UserScript==
// @name ErepComp
// @version 0.1
// @author Mike Dreams
// @match https://www.erepublik.com/en/economy/myCompanies
// @match https://www.erepublik.com/uk/economy/myCompanies
// @grant none
// ==/UserScript==
(function(){var ePar=document.getElementById("help_manage").parentElement;function selectallhp(){for(var e=Math.floor((erepublik.citizen.energy+erepublik.citizen.energyFromFoodRemaining)/10),t=getCompanies(),n=0;n<t.length;)t[n].classList.contains("active")?0<e?e--:(t[n].classList.remove("active"),calculateProduction(t[n].parentElement.parentElement,!0)):0<e&&(t[n].classList.add("active"),calculateProduction(t[n].parentElement.parentElement,!0),e--),n++;finalize()}function plus10(){for(var e=getCompanies(),t=0,n=0;n<10&&t<e.length;)e[t].classList.contains("active")||(e[t].classList.add("active"),calculateProduction(e[t].parentElement.parentElement,!0),n++),t++;finalize()}function minus10(){for(var e=getCompanies(),t=e.length-1,n=0;n<10&&-1<t;)e[t
@driversti
driversti / MC Cheat Sheet
Created June 12, 2023 05:39 — forked from samiraguiar/MC Cheat Sheet
Midnight Commander Cheat Sheet / Shortcuts
Note for newcomers:
In the shortcuts below, "C" stands for CTRL and "A" stands for "ALT". This is a convention
used in the Midnight Commander documentation and was kept here.
You can also use "ESC" instead of "ALT", which is useful on Macbooks.
Main View
---------------------------------------------------------------
- File/directory operations

Get Started with the Profile Statistic Script

Here's a step-by-step guide on how to run the profile statistic script either with Node.js or Docker.

Prerequisites

  • A computer running a GNU/Linux or macOS operating system.
  • Basic knowledge of the command-line interface.
  • Administrator (root) access to your machine.

1. Running with Node.js

@driversti
driversti / fb_install_alpine.sh
Last active February 24, 2024 12:26
Installs, enables and runs FileBrowser on a server. Since all my servers are accessible via VPN only I want to be able to choose to which IP bind FileBrowser
#!/bin/sh
# Install FileBrowser
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
# Get all IP addresses using ip command and filter out the IP addresses
IPS=$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)
# Print them out for the user
echo "Available IPs:"