Skip to content

Instantly share code, notes, and snippets.

View kberov's full-sized avatar
🐢
I may be slow to respond.

Красимир Беров kberov

🐢
I may be slow to respond.
View GitHub Profile
@kberov
kberov / example_test.go
Last active December 16, 2023 02:05
A template and data manager for valya/fasttemplate with added wrapper and 'include' directives
package tmpls
import (
"bytes"
"fmt"
"io"
"log/slog"
"os"
"strings"
#!/usr/bin/env perl
use Mojo::Base -strict;
use Mojo::Util qw(dumper getopt encode decode);
use Mojo::File 'path';
getopt
'i|infile=s' => \my $file_in,
'o|outfile=s' => \my $file_out,
'c|cz2bg' => \my $_cz2bg_,
'b|bg2cz' => \my $_bg2cz_;
# /etc/apache2/sites-enabled/001-dev.slovo.conf
<VirtualHost *:80>
ServerName dev.slovo.bg
ServerAdmin webmaster@dev.slovo
DocumentRoot /home/berov/opt/dev.slovo.bg
<Directory "/home/berov/opt/dev.slovo.bg">
AllowOverride All
Require all granted
</Directory>
@kberov
kberov / uninstal_pm_from.sh
Last active October 1, 2018 19:59
Uninstall Perl modules installed via cpan or cpanm
#!/bin/sh
# I tried this even wth my system perl because I had installed modules there
# For this you need to be root, but beware you can break your system,
# if you have important scripts using some of these modules
# get list of installed modules via `cpanm` or `cpan`
export PERLLOCAL=`find "$1" -name 'perllocal.pod'`
# find and uninstall installed modules. cpanm will propt for each one
cpanm -U `perl -ne 'print "$1 " if /L\<([^\|]+)\|/' $PERLLOCAL`
@kberov
kberov / install-imagemagick-perl.sh
Last active July 24, 2018 20:29
To use Image::Magic with Perl, Perl must be compiled with some special CFLAGS! and ImageMagick must be compiled with this perl Example:
#!/usr/bin/env bash
# My notes - K. Berov:
# Copied from
# https://gist.githubusercontent.com/zmughal/8264712/raw/8831e421393143c5b48f22dcfa12eeda51c5cfbf/install-imagemagick-perl
# and modified for my self.
# I already have several perls
# I will use 5.26.2 for this installation
# See https://www.perl.com/article/57/2014/1/1/Shazam--Use-Image--Magick-with-Perlbrew-in-minutes/
# See mainly the following as this configuration actually worked:
# https://github.com/lecstor/DevNotes/wiki/Image-Magick-with-Perlbrew
@kberov
kberov / convert.pl
Last active February 3, 2018 12:58
Batch convert music/video files from one format to another using Perl (Mojo) and vlc. See also https://wiki.videolan.org/VLC_command-line_help
#!/usr/bin/env perl
use Mojo -strict;
use Mojo::File qw(path);
# cd to the directory where your files are
# and run this program
# $0 $format_in $format_out
my ($format_in, $format_out) = @ARGV;
say qq|Converting from "$format_in" to "$format_out"|;
for my $file ( path('./')->list->each ) {
fn largest<T: PartialOrd + Copy>(vec: &Vec<T>) -> T {
let mut largest = vec[0];
for e in vec {
if e > &largest {
largest = *e;
}
}
largest
}
fn main() {
@kberov
kberov / process_files.pl
Last active January 13, 2017 12:48
Process all files in a directory using Mojo::File! Четене и обработка на всички файлове в дадена папка с Mojo::File!
#!/usr/bin/env perl
use FindBin;
use lib "$FindBin::Bin/../lib/perl5";
use Mojo::Base -strict;
use Mojo::DOM;
use Mojo::File qw (path);
Mojo::Util::getopt \@ARGV,
'--input_folder|i=s' => \(my $in_folder = ''),
'--output_file|o=s' => \my $out_file,
@kberov
kberov / cookie.t
Last active August 29, 2015 14:07
setting a new cookie value is broken or it was?