Skip to content

Instantly share code, notes, and snippets.

View navopw's full-sized avatar
💻
What is a programmer's favourite hangout place? Foo Bar

Navo | Stanislav navopw

💻
What is a programmer's favourite hangout place? Foo Bar
View GitHub Profile
@navopw
navopw / main.go
Last active August 25, 2022 22:06
Convert .mov to .mp4 recursively in folder (Go)
package main
import (
"fmt"
ffmpeg "github.com/u2takey/ffmpeg-go"
"log"
"os"
"path/filepath"
"strings"
)
@navopw
navopw / FileChooserExample.java
Created April 6, 2019 09:58
FileChooserExample
FileChooser.open((file) -> {
/*
Die Variable "file" ist null, wenn die Auswahl abgebrochen wurde.
Ansonsten ist dies ein valides "File" Objekt.
*/
});
@navopw
navopw / ServerPinger.java
Last active February 14, 2019 12:31
A method to determine the ping of a server in milliseconds in Java
/**
* A method to determine the ping of a server in milliseconds
* @param ip The ip address of the server you want to ping
* @param timeout The time window in which the destination has time to respond
* @return If the server is reachable within the timout it returns the ping time in ms, otherwise -1
* @throws IOException
*/
public static long pingServer(String ip, int timeout) throws IOException {
InetAddress address = InetAddress.getByName(ip);
long currentTime = System.currentTimeMillis();
@navopw
navopw / OSDetector.java
Created April 13, 2018 13:58
OSDetector
public class OSDetector {
public static OperatingSystem getOperatingSystem() {
//Der Name vom Betriebssystem kann aus den System Eigenschaften gelesen werden (Unter os.name)
String osName = System.getProperty("os.name").toLowerCase();
//Enthält der osName "win", so ist das Betriebssystem Windows
if (osName.contains("win")) {
return OperatingSystem.WINDOWS;
}
@navopw
navopw / GzipCompressionTest.java
Last active May 9, 2017 14:21
GzipCompressionTest
package pw.navo.compression;
import java.io.IOException;
public class GzipCompressionTest {
public static void main(String[] args) {
/**
* Für dieses Beispiel nehme ich einen String, da diese sich viel einfacher visualisieren lassen
*
@navopw
navopw / GzipCompression.java
Created May 5, 2017 22:26
GzipCompression
package pw.navo.compression;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class GzipCompression {
public static byte[] compress(byte[] bytes) throws IOException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(bytes.length);
@navopw
navopw / DirectoryChooser.java
Created March 10, 2017 18:51
DirectoryChooser - Java 8 Consumer Style
package de.navo.anything;
import java.awt.EventQueue;
import java.io.File;
import java.util.function.Consumer;
import javax.swing.JFileChooser;
public class DirectoryChooser {
/**
@navopw
navopw / AESEncryptionTest.java
Created February 18, 2017 16:45
AESEncryptionTest.java
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
public class AESEncryptionTest {
@navopw
navopw / AESEncryption.java
Last active May 6, 2017 14:39
AESEncryption
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
@navopw
navopw / mongodb.script
Last active May 6, 2017 14:45
MongoDB: How to add admin user & database user
use admin
db.createUser({
user: "<username>",
pwd: "<password>",
roles: [
"userAdminAnyDatabase",
"dbAdminAnyDatabase",
"readWriteAnyDatabase"
]
})