Convert video to mp3 in entire directory with ffmpeg in windows?

For Windows:

Here I’m Converting all the (.mp4) files to (.mp3) files.
Just open cmd, goto the desired folder and type the command.

Shortcut: (optional)
1. Goto the folder where your (.mp4) files are present
2. Press Shift and Left click and Choose “Open PowerShell Window Here”
or “Open Command Prompt Window Here”
3. Type “cmd” [NOTE: Skip this step if it directly opens cmd instead of PowerShell]
4. Run the command

for %i in (*.mp4) do ffmpeg -i "%i" "%~ni.mp3"

If you want to put this into a batch file on Windows 10, you need to use %%i.

Simple arduino clock

Well, I like clocks, especially custom made or diy. Here is the code and some photos.

#include "Wire.h"
#include "LiquidCrystal_I2C.h"

#include "TimeLib.h"
#include "DS1307RTC.h"

LiquidCrystal_I2C lcd(0x27,20,4);
String time;

int inPinA = 2;  
int inPinB = 3;  
int valPinB = 0;

boolean previousStatusPinA = false;
boolean previousStatusPinB = false;

byte x10[8] = {0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07};   
byte x11[8] = {0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C};
byte x12[8] = {0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F};
byte x13[8] = {0x07,0x07,0x07,0x07,0x07,0x1F,0x1F,0x1F};
byte x14[8] = {0x1C,0x1C,0x1C,0x1C,0x1C,0x1F,0x1F,0x1F};
byte x15[8] = {0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C};
byte x16[8] = {0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07};
byte x17[8] = {0x00,0x00,0x0E,0x0E,0x0E,0x00,0x00,0x00};

const String dayTitle[8] = { "", "Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sam" };
const String monthTitle[13] = { "", "Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Noi", "Dec" };
const String modeTypeTitle[8] = { "", "Setare ora", "Setare minute", "Setare secunde", "Setare data", "Setare luna", "Setare an +", "Setare an -"};

void setup()
  lcd.createChar(0, x10);                      
  lcd.createChar(1, x11);                      
  lcd.createChar(2, x12);                      
  lcd.createChar(3, x13);                      
  lcd.createChar(4, x14);                      
  lcd.createChar(5, x15);                      
  lcd.createChar(6, x16);                      
  lcd.createChar(7, x17);                      

  pinMode(inPinA, INPUT);
  pinMode(inPinB, INPUT);


void loop()
  if (timeStatus() == timeSet) {
  } else {
    setTime(12, 34, 56, 1, 1, 2018);
    time_t t = now();

void digitalClockButtons(){
  if (digitalRead(inPinB) == 1 && previousStatusPinB == false) {
    if (valPinB == 8) {
      valPinB = 0;
    previousStatusPinB = true;
    lcd.print("                    ");
  } else if (digitalRead(inPinB) == 0 && previousStatusPinB == true) {
    previousStatusPinB = false;

  if (digitalRead(inPinA) == 1 && previousStatusPinA == false && valPinB > 0) {
    int Hour = hour();
    int Min = minute();
    int Sec = second();
    int Day = day();
    int Month = month();
    int Year = year();

    if (valPinB == 1) ++Hour;
    if (valPinB == 2) ++Min;
    if (valPinB == 3) Sec = 0;
    if (valPinB == 4) ++Day;
    if (valPinB == 5) ++Month;
    if (valPinB == 6) ++Year;
    if (valPinB == 7) --Year;

    setTime(Hour, Min, Sec, Day, Month, Year);
    time_t t = now();
    previousStatusPinA = true;
  } else if (digitalRead(inPinA) == 0 && previousStatusPinA == true && valPinB > 0) {
    previousStatusPinA = false;

void digitalClockDisplay(){
    // Display the time using bigNumber
    int row = 0;
    int col = 0;

    bigNumber(getDigit(hour(),2) ,row,col);
    col = col + 3;
    bigNumber(getDigit(hour(),1) ,row,col);
    col = col + 3;

    col = col + 2;

    bigNumber(getDigit(minute(),2) ,row,col);
    col = col + 3;
    bigNumber(getDigit(minute(),1) ,row,col);
    col = col + 3;

    if (valPinB == 0) {
      lcd.print(dayTitle[weekday()] + "  ");
    } else {




// Position a custom big font digit
// position number 'num' starting top left at row 'r', column 'c'
void bigNumber(byte num, byte r, byte c) {
    switch(num) {
      case 0: lcd.write(byte(2)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+1); lcd.write(byte(5)); lcd.write(byte(6)); 
              lcd.setCursor(c,r+2); lcd.write(byte(4)); lcd.write(byte(3)); break;

      case 1: lcd.write(byte(0)); lcd.write(byte(1)); 
              lcd.setCursor(c,r+1); lcd.print(" "); lcd.write(byte(5));
              lcd.setCursor(c,r+2); lcd.write(byte(0)); lcd.write(byte(4)); break;

      case 2: lcd.write(byte(2)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+1); lcd.write(byte(2)); lcd.write(byte(3)); 
              lcd.setCursor(c,r+2); lcd.write(byte(4)); lcd.write(byte(2)); break;  

      case 3: lcd.write(byte(2)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+1); lcd.write(byte(0)); lcd.write(byte(3)); 
              lcd.setCursor(c,r+2); lcd.write(byte(2)); lcd.write(byte(3)); break;  

      case 4: lcd.write(byte(1)); lcd.write(byte(0)); 
              lcd.setCursor(c,r+1); lcd.write(byte(4)); lcd.write(byte(3)); 
              lcd.setCursor(c,r+2); lcd.print(" "); lcd.write(byte(6)); break;  

      case 5: lcd.write(byte(2)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+1); lcd.write(byte(4)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+2); lcd.write(byte(2)); lcd.write(byte(3)); break;  

      case 6: lcd.write(byte(1)); lcd.print(" ");     
              lcd.setCursor(c,r+1); lcd.write(byte(4)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+2); lcd.write(byte(4)); lcd.write(byte(3)); break;  

      case 7: lcd.write(byte(2)); lcd.write(byte(2));
              lcd.setCursor(c,r+1); lcd.print(" "); lcd.write(byte(6)); 
              lcd.setCursor(c,r+2); lcd.print(" "); lcd.write(byte(6)); break;  

      case 8: lcd.write(byte(2)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+1); lcd.write(byte(4)); lcd.write(byte(3)); 
              lcd.setCursor(c,r+2); lcd.write(byte(4)); lcd.write(byte(3)); break;  

      case 9: lcd.write(byte(2)); lcd.write(byte(2)); 
              lcd.setCursor(c,r+1); lcd.write(byte(4)); lcd.write(byte(3)); 
              lcd.setCursor(c,r+2); lcd.print(" "); lcd.write(byte(6)); break;  

      case 11: lcd.setCursor(c,r+1); lcd.write(byte(7)); lcd.setCursor(c,r+2); lcd.write(byte(7)); break;

      case 12: lcd.print("   ");
               lcd.setCursor(c,r+1); lcd.print("   ");
               lcd.setCursor(c,r+2); lcd.print("   ");break; 

// Get a digit of a number 
// used to draw the individual big numbers one at a time
int getDigit(unsigned int number, int digit) {
    for (int i=0; i

Config mail server on digital ocean

login to your droplet of digital ocean

1. output the hostname

2. modify the hosts
nano /etc/host

3. the first line in this file, should use the hostname on the end. For example: "Lee" localhost localhost.domainname Lee

4. install mail
sudo apt-get install sendmail

5. configure the mail, answer yes to everything:
sudo sendmailconfig

6. Restart apache2
sudo service apache2 restart

Prevent the spam folder
1. Make sure your IP address is not on a blacklist.

2. Make sure the SPF record is set properly in a TXT record of the DNS for your domain:
“v=spf1 +a +mx +ip4:xx.xx.xx.xx ~all”

3. Make sure that the DKIM record is set properly in a TXT record of the DNS for your domain:
“v=DKIM1; k=rsa;\;

4. Make sure your server is not an open relay

vault with docker

doker-compose.yml file

version: '3'
        image: vault
        container_name: vault
          - 8200:8200
          - ./data:/vault/data:rw
          - ./config:/vault/config:rw
          - IPC_LOCK
        entrypoint: vault server -config=/vault/config/vault.conf


ui = true

storage "file" {
  path = "/vault/data"

listener "tcp" {
  address     = ""
  tls_disable = 1
  #tls_disable = 0
  #tls_cert_file = "/vault/conf/cert/fullchain.pem"
  #tls_key_file = "/vault/conf/cert/privkey.pem"

vault client in java

package com.crossinx;

import java.util.List;
import java.util.Map;

import com.bettercloud.vault.Vault;
import com.bettercloud.vault.VaultConfig;
import com.bettercloud.vault.VaultException;
import com.bettercloud.vault.api.Auth.TokenRequest;
import com.bettercloud.vault.response.AuthResponse;
import com.bettercloud.vault.response.LogicalResponse;

public class VaultService {

    private int vaultEngineVersion = 2;
    private String vaultAddress;
    private String vaultToken;
    private String defaultTtl = "1h";

    public void setVaultAddress(String vaultAddress) {
        this.vaultAddress = vaultAddress;

    public void setVaultToken(String vaultToken) {
        this.vaultToken = vaultToken;

    private Vault getDefaultConfig() throws VaultException {
        VaultConfig config = new VaultConfig()
        return new Vault(config);

    public String getSecretValue(String path, String key) {
        String value = null;
        try {
            value = getDefaultConfig()
        } catch (VaultException e) {
        return value;

    public LogicalResponse setSecretValue(String path, Map secrets) {
        try {
            return getDefaultConfig()
                    .write(path, secrets);
        } catch (VaultException e) {

        return null;

    public String createToken() {
        return createToken(defaultTtl, null);

    public String createToken(String ttl, List polices) {
        try {
            TokenRequest tokenRequest = new TokenRequest().ttl(ttl);
            if (polices != null && !polices.isEmpty())

            AuthResponse response = getDefaultConfig()

            return response.getAuthClientToken();
        } catch (VaultException e) {

        return null;

Turning wifi off at night on mikrotik routers

If you think that you must turn off WiFi at night due to security reasons or looking for a healthy rest time, here is how to do that on Mikrotik RouterOS.

To program a Mikrotik router for turning off and on WiFi you must use scripting and scheduling capabilities fo RouterOS.

The command you must run to turn off WiFi is:
interface wireless disable 

So you have to wrote a very small script with just that command. Using WinBox:

Open System -> Scripts window
Press Add button and the script editor window will open
Type a script name like DisableWLAN
Select required policies or check all of them
Type script into the Source text area: interface wireless disable 
You can to test the script with Run Script button
Save the script with Ok button
Now create a similar EnableWLAN script with the opposite command:
interface wireless enable 
Next add the schedule scripts:

Open System -> Scheduler window
Press Add button to open the Scheduler window
Type some meaningful name for the scheduled task like CronDisableWLAN (can be the same as the script’s)
Type the name of your script, DisableWLAN, into the On Event text area
Select the start date (i.e today), start time (hh:mm:ss format, i.e. 23:00:00) and the interval for repeating the action like 1d 00:00:00
Select required policies or check them all
Save the schedule with Ok button

Repeat the same to schedule the enabling script (i.e. CronEnableWLAN starting at 09:00:00 with an interval of 1d 00:00:00)

Now your Mikrotik router will turn off and on at your desired times.

Good rest!

Digispark lock button

Ok here is the code for locker button. The main feature of this device is to lock the screen of the computer when you leave the office.

#include "DigiKeyboard.h"

const int buttonPin=0;
int buttonState=0;

void setup() {


  pinMode(buttonPin, INPUT);

void loop() {


  if (buttonState == HIGH) {
    DigiKeyboard.sendKeyStroke(KEY_L, MOD_GUI_LEFT);

ncat chat server

Basic chat server / client with netcat

Install netcat

pkg install nmap

On server start daemon
ncat --ssl --chat -l port &

On client run
ncat --ssl address port

### Broker server 
ncat -k -l -p xxx --broker

### Netcat client script
echo "HELLO" | nc ip port -q 1

Git server under FreeBSD

Time comes when big boys wants to build their own private repos to commit or deploy. Well my time has come.

Install git and add users, with your favorite editor

# pkg install git
# git config --global "user"
# git config --global "email"
# git config --global core.editor "ee"
# git config --list

Add to `rc.conf`


Start daemon
service git_daemon start

Install cgi handler
# pkg install fcgiwrap

Add to `rc.conf`

Add new nginx configuration
server {
    listen 80;
    server_name domain;
    return 301 https://$server_name$request_uri;

server {
    listen 443;
    server_name domain;

    root /home/path-to-root;

        ssl on;
        ssl_certificate /usr/local/etc/letsencrypt/live/domain/fullchain.pem;
        ssl_certificate_key /usr/local/etc/letsencrypt/live/domain/privkey.pem;
        ssl_session_cache shared:SSL:10m;

    auth_basic "Unauthorized";
    auth_basic_user_file /home/user/git/.passwords;

    location /gitweb.cgi {
            fastcgi_pass    unix:/var/run/fcgiwrap/fcgiwrap.sock;
            fastcgi_param   REMOTE_USER $remote_user;
            fastcgi_param     SCRIPT_NAME gitweb.cgi;
        fastcgi_param   SCRIPT_FILENAME /home/path-to-root/gitweb.cgi;
            fastcgi_param   DOCUMENT_ROOT /home/path-to-root;
        fastcgi_param     GITWEB_CONFIG /usr/local/etc/git/gitweb.conf;
        include         fastcgi_params;

        location / {
        root            /home/path-to-root;
            index           gitweb.cgi;
            autoindex       off;

open `/usr/local/etc/git/gitweb.conf` and add path to root directory of git repos
our $projectroot="/home/user/git";

And now it's time to create a new repo
cd /home/user/git
mkdir project-name.git
cd project-name.git
git --bare init

Now you will be able to commit changes on this project.


Base64 spring

Encoding file to base64

@RequestParam("file") MultipartFile file


if (!file.isEmpty()) {
            String base64 = Base64.getEncoder().encodeToString(file.getBytes());

Decoding base64 to file

HttpServletResponse response


response.addHeader("Content-disposition", "inline");

Attachment attachment = attachmentRepository.findOne(id);
byte[] decodedBytes = Base64.getDecoder().decode(attachment.getBase64());

OutputStream output = response.getOutputStream();

Secure spring boot with letsencrypt ssl certificate

Install the Certbot client

pkg install py27-certbot

Generate certificate

certbot certonly --webroot -w /usr/local/www/example -d

or wildcard certificate

certbot certonly --server --manual --preferred-challenges dns -d '' -d '*'

I’m using spring on http and nginx as proxy server for ssl layer. Here is the nginx config:

        server {
                listen 443;

                ssl on;
                ssl_certificate /usr/local/etc/letsencrypt/live/;
                ssl_certificate_key /usr/local/etc/letsencrypt/live/;
                ssl_session_cache shared:SSL:10m;

                location / {
                        proxy_pass http://localhost:8080;
                        proxy_set_header Host $host;

                location /.well-known {
                        alias /home/path-to-root/.well-known/;

        server {
                listen 80;
                return 301 https://$server_name$request_uri;

Open the renewal option of letsencrypt and make sure default values are set

# Options used in the renewal process
authenticator = webroot
installer = None
account = ...
webroot_path = /home/path-to-root,
domain = /home/path-to-root

Renew your certificates automatically before they expire. Since Let’s Encrypt certificates last for 90 days only

Add to cron, with `crontab -e` command the following

0 4 * * * certbot -q renew --renew-hook "service nginx reload"