Skip to content

Instantly share code, notes, and snippets.

View antic183's full-sized avatar

Antic Marjan antic183

View GitHub Profile
@antic183
antic183 / ftp.py
Last active April 12, 2024 10:55
run a simple Python FTP Server on windows as a system service
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import ThreadedFTPServer
from pyftpdlib.authorizers import DummyAuthorizer
class FtpServer:
def start(self):
authorizer = DummyAuthorizer()
authorizer.add_user('user', '12345', 'C:\\..wathever...\\ftp-public', perm='elradfmwMT')
handler = FTPHandler
handler.authorizer = authorizer
@antic183
antic183 / howto
Last active March 14, 2024 09:06
work with several openjdk version on windows
1.) download your desired jdk version --> https://jdk.java.net/archive/
2.) unzip the and move the jdk folder on the desired place
3.) add java/bin/ folder to the PATH env.-variable permamently
- open powershell as admin !important
- $env:Path+=";C:\_YOUR-DESIRED-JAVA-PATH_\jdk-xx.xx.xx\bin"
- [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
@antic183
antic183 / mysql-random-character.sql
Created November 17, 2020 08:27
mysql, mariadb generate random character
select elt(( FLOOR(1 + (RAND() * 26)) ),'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
dim speachobject
set speachobject=createobject("sapi.spvoice")
speachobject.speak "corona"
public class FloatingPointProblem {
public static void main(String []args) {
float f = 3.1f;
double d = 3.1;
System.out.println(Float.floatToRawIntBits(f) + "\n"); // 1078355558
System.out.println(Double.doubleToRawLongBits(d) + "\n"); //4614162998222441677
if (d == f) {
System.out.println("f == d");
@antic183
antic183 / Car.h
Last active May 9, 2020 17:24
C++ oop playground. The pattern doesn't have to make sense. Below the extendet factory with singleton per type.
#pragma once
#include <string>
#include "IMotoVehicle.h";
using namespace std;
class Car: public IMotoVehicle {
int doors;
public:
@antic183
antic183 / encode-decode-email.php
Last active March 13, 2024 08:21
a very simple and effectively way to hide email from spam bots
<?php
$email = 'your-email@example.com'; // when email-domain-part contains umlauts, use the idn format: idn_to_ascii('your-email@example-äöü.com');
$emailLength = mb_strlen($email);
$randomFactor = '';
$encodedMail = '';
for ($ix = 0; $ix < $emailLength; $ix++) {
$randomFactor .= rand(1, 9);
}
@antic183
antic183 / example.html
Last active April 5, 2019 11:30
fancybox gallery groups
<!DOCTYPE html>
<html>
<head>
<title>fancybox</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css">
@antic183
antic183 / RegexExampleNumberOfHits.java
Last active May 23, 2018 11:16
java regex examples find number of hits
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexExampleNumberOfHits {
public static void main(String[] args) {
String txt = "dfsd weqwe asdasdw und \nsch\nqschwexs xsdad\nschaber\n\reewwww dxddasdfsf\n\rsch\n\r dfsgfgd bieeewwwww";
// word content
Matcher matchSentence = Pattern.compile("sch", Pattern.CASE_INSENSITIVE).matcher(txt);
int hits = 0;
@antic183
antic183 / passwordGenerator.php
Created February 21, 2018 08:08
php random password generator
<?php
function getRandomPassword($passwordLength = 4) {
$alphabet = 'abcdefghijklmnopqrstuvwxyz';
$characterCollection = array_merge(str_split($alphabet), str_split(strtoupper($alphabet)), str_split('1234567890'), str_split('!~@#-_+<>[]{}'));
$randomPassword = '';
for($i = 0; $i < $passwordLength; $i++) {
$randomPassword .= $characterCollection[array_rand($characterCollection)];
}