Skip to content

Instantly share code, notes, and snippets.

Sub ExportSelected_Click()
Dim CWS As Worksheet
Set CWS = ActiveSheet
' Fields whose values are used when generating the exported directory name
Dim FieldNames
FieldNames = Array("Quote Ref (YY-MMXX)", _
"Customer/ End user", _
"Project Name or description")
@miroslavradojevic
miroslavradojevic / ffmpeg_mp4.bash
Last active February 14, 2021 12:12
Use ffmpeg to modify .mp4 videos with terminal commands
# https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video-with-ffmpeg
# https://superuser.com/questions/841235/how-do-i-use-ffmpeg-to-get-the-video-resolution
# To get mp4 video resolution
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4
# Use crop filter
ffmpeg -i input.mp4 -filter:v "crop=out_w:out_h:x:y" output.mp4
# To crop a 80×60 section, starting from position (200, 100)
@miroslavradojevic
miroslavradojevic / ScoutCollisionAvoidance.cpp
Created January 25, 2021 16:13
Scount 2.0 collision avoidance controller for Scout 2.0 supplied with four distance sensors
#include <webots/Robot.hpp>
#include <webots/Motor.hpp>
#include <webots/DistanceSensor.hpp>
#include <webots/Lidar.hpp>
#include <algorithm>
#include <iostream>
#define TIME_STEP 64
#define MAX_SPEED 5.0
#define ALPHA 2.0
@miroslavradojevic
miroslavradojevic / yml2requirements.py
Last active November 4, 2020 10:59
Import anaconda environment .yml in virtualenv
import ruamel.yaml
import argparse
from pathlib import Path
from os.path import exists
parser = argparse.ArgumentParser(description='(anaconda) environment.yml -> (pip) requirements.txt')
parser.add_argument('yml', type=str, metavar='environment.yml', default='environment.yml', help='the input file')
parser.add_argument('-o', type=str, metavar='requirements.txt', default=None, help='the output file')
args = parser.parse_args()
# sudo apt install nmap
nmap -sn 192.168.1.0-254 -oN output.txt
@miroslavradojevic
miroslavradojevic / rsync-without-pass.bash
Created May 31, 2020 19:41
Rsync with remote Jetson Nano with ssh password stored in a jetson-nano-pass
sshpass -p $(cat jetson-nano-pass) rsync -avzh miro@192.168.1.59:/home/miro/cam-rpi.py/ /home/miro/cam-rpi.py/
@miroslavradojevic
miroslavradojevic / install_cuda_10.0_ubuntu_18.04.sh
Last active February 26, 2020 16:13
Install Cuda 10.0 on Ubuntu 18.04 - compatible with Nvidia Isaac 2019.3
# Install Cuda 10.0 and nvidia-driver 440 - compatible with Isaac 2019.3
# Inspiration https://gist.github.com/bogdan-kulynych/f64eb148eeef9696c70d485a76e42c3a
# Calling default installer results with the installment of Cuda 10.2 and nvidia-driver 410 where both are not compatible with Nvidia Isaac
# https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal
# List Nvidia hardware (inspection only)
lspci | grep -i nvidia
# Check if there are cuda/nvidia drivers already installed
dpkg -l | grep cublas
@miroslavradojevic
miroslavradojevic / DirectoryExport.vb
Last active December 9, 2019 14:37
Create and rename directory name based on the values from the Excel sheet table. Use Excel's Visual Basic for Applications (VBA).
Private Sub ExportSelected_Click()
Dim CWS As Worksheet
Set CWS = ActiveSheet
' Fields whose values are used when generating the exported directory name
Dim FieldNames
FieldNames = Array("Start date", _
"Customer", _
"Agent", _
@miroslavradojevic
miroslavradojevic / gist:eed0421ae52022ba17614ac6134efb1b
Created March 22, 2019 08:37
Rename figure files in given directory, excluding dot and '/': ./fig/dir/file_param_1.1_param2.2.pdf into ./figdirfile_param1_1_param2_2.pdf For compiling latex project it was necessary to have all the files in one directory and retaining their unique name, at the same time replacing the '.' from file name.
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
@miroslavradojevic
miroslavradojevic / BacteriaAnnotator.java
Created November 28, 2018 00:49
ImageJ plugin for pinpointing or delineating objects or regions of interest.
import ij.IJ;
import ij.ImageListener;
import ij.ImagePlus;
import ij.Prefs;
import ij.gui.*;
import ij.io.FileSaver;
import ij.io.OpenDialog;
import ij.plugin.PlugIn;
import ij.plugin.frame.RoiManager;
import ij.process.ByteProcessor;