showunicode





Description

showunicode is a simple program that displays unicode characters in your terminal emulator (if the appropiate fonts are installed on your system)


USAGE

% showunicode | less

% showunicode U+1234-U+12FF

% showunicode hex

% showunicode U+218f-U+23ff | less

% showunicode U+2190-U+21ff hex


Author

g0 , http://ipduh.com/contact


License

Same as Perl, free software.


Install ( in *nix and clones )

# wget kod.ipduh.com/lib/showunicode && chmod 755 showunicode && mv showunicode /usr/bin/







Source:

#!/usr/bin/perl
use strict;
no warnings;

=head1 Description

showunicode is a simple program that displays unicode characters in your terminal emulator 
(if the appropiate fonts are installed on your system) 

=cut

my $USAGE= <<"EOU";

=head1 USAGE


% showunicode | less

% showunicode U+1234-U+12FF 

% showunicode hex

% showunicode U+218f-U+23ff | less

% showunicode  U+2190-U+21ff hex

=cut

EOU

=head1 Author

g0 , L<http://ipduh.com/contact>

=head1 License

Same as Perl, free software.

=head1 Install ( in *nix and clones )

# wget kod.ipduh.com/lib/showunicode && chmod 755 showunicode && mv showunicode /usr/bin/  

=cut

my $PRINT_HEX=0;
my $COLS=50;
my $MIN=256;
my $MAX=110_000;

if(@ARGV){
  $PRINT_HEX=1 if($ARGV[0] =~ /^hex/i);

  if($ARGV[0] =~ /^U\+([0-9a-f]{1,6})-U\+([0-9a-f]{1,6})/i){
    my ($from,$to)=(sprintf("%d",hex($1)),sprintf("%d",hex($2)));
    if( $to > $from ){
      if($ARGV[1] =~ /^hex/i) { $PRINT_HEX=1; }
      unicode_range($from , $to);
      print "\n"; 
      exit 0;
    } else {
      print "U+$1 is greater than U+$2 \n";
      exit 3;
    }
  }
 
  if($ARGV[0] =~ /^U\+([0-9a-f]{1,6})/i){
    my $code=$1;
    print "U+$code: " if ($ARGV[1] =~ /^hex/i);
    print chr sprintf("%d",hex($code)), "\n"; 
    exit 0;
  }

  if($ARGV[0] =~ /^help|-h|-help|--h|--help/i){
    print "\nShowunicode Usage Examples\n";
    for my $line (split /\n/,$USAGE){
      print "$line\n" unless ($line =~ /^=.*/);
    }
    print "\nWould you like to see the  perldoc for showunicode? [y/*]:";
    my $answer=<STDIN>;
      system("perldoc $0") if($answer =~ /^y|yes/i); 
    exit 0;
  }
}

print "\n";
unicode_range($MIN,$MAX);
print "\n";
exit 0;

sub unicode_range {
  my ($from,$to)=@_;
  $COLS=8 if ($PRINT_HEX);
  for ($from..$to){
    print sprintf("U+%x",$_) , ":" if ($PRINT_HEX);
    print chr $_, ($_ - $from + 1)%$COLS?" ":"\n";
  }
}






Screenshots





showunicode

move virtualbox guest to KVM

Notes on migrating virtualbox guest to KVM

Convert the vdi image to raw
$ vboxmanage clonehd /media/some/virtualbox-guest.vdi /media/some/x-virtualbox-guest.img --format raw


virt-install --connect qemu:///system --description x-virtualbox-guest -r 4096 --os-type=linux --disk /home/vm/jira/jira.img,device=disk --network=bridge:br0 --hvm --vnc --noautoconsole --name= x-virtualbox-guest--import




Notes on migrating a virtualbox guest to KVM

debian, console speak greek

Show and Input greek and other utf8 characters in a debian console

on
Debian GNU/Linux 7 \n \l
If you are using the gnome windows manager, then the gnome-terminal is the culprit (I could not figure out how to make it UTF-8 literate) and the Internets are full of bad advice ... gnome-terminal Unicode UTF-8

The easiest way to get a slick utf-8 able terminal emulator is to use xterm with UTF-8 encoding eg -en UTF-8 or gnome-terminal Unicode UTF-8

Even though xterm in debian 7 is using UTF-8 encoding by default beeing explicit does not hurt
$ xterm -en UTF-8


an easy way to put it in your gnome menu is to use alacarte
# apt-get install alacarte
# exit
$ 
and put in Accessories -> New Item
NAME => xterm-UTF8
Command => /usr/bin/xterm -en UTF-8







debian console speak Greek ....

perl locale debian ...

to fix


$ perl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = "en_US.UTF-8",
 LC_ALL = (unset),
 LC_MONETARY = "en_US.utf8",
 LC_NUMERIC = "en_US.utf8",
 LC_MEASUREMENT = "en_US.utf8",
 LC_TIME = "en_US.utf8",
 LANG = "en_GB.utf8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
^C




on
$ cat /etc/debian_version; uname -a
7.5
Linux debie64 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3 x86_64 GNU/Linux


upon installing stuff that broke my|your bash env locale variables

do

$ echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc 
$ echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc 
$ echo "export LANG=en_US.UTF-8" >> ~/.bashrc 
$ source ~/.bashrc 



$ perl
^C

taraaaaa

perl should not warn and fall back to C from now on.


perl ... debian package ... bash env ... locale .... crap ... tarrraaaa

debian jessie, notes on setting up subversion

Notes on setting up a subversion server on debian Jessie

Install subversion
# apt-get install subversion


Install the apache HTTP daemon
# apt-get install apache2


Install the WebDAV apache2 module
# apt-get install libapache2-svn


Create directories for the repositories
# mkdir -p /srv/svn/dev
# mkdir /srv/svn/doc


Create the dev and doc repositories
# svnadmin create --fs-type fsfs /srv/svn/dev
# svnadmin create --fs-type fsfs /srv/svn/doc


Add an svn group
# groupadd svnchmod -R 770 /srv/svn/
# addgroup someuser svn
# addgroup someotheruser svn


# chown -R www-data:svn /srv/svn
# chmod -R 770 /srv/svn/ 


Commit on subversion server over SSH
$ mkdir test
$ echo "testing svn over ssh" > test/testing.txt
$ svn import -m "testing testing 123" test/ svn+ssh://192.168.101.11/srv/svn/doc
Adding         test/testing.txt

Committed revision 1.



Check on the server
# svnlook tree /srv/svn/doc/
/
 testing.txt



Configure WebDAV for subversion
# a2enmod dav_svn
# a2enmod dav_fs
# service apache2 restart


Webauth for someuser
# htpasswd -c /etc/subversion/dav_svn.passwd someuser


Configure a repository over WebDAV in /etc/apache2/mods-available/dav_svn.conf e.g.
<Location /svn>
  DAV svn
  SVNParentPath /srv/svn
  SVNListParentPath On
  AuthType Basic
  AuthName "yetAnother Subversion Repository"
  AuthUserFile /etc/subversion/dav_svn.passwd
  Require valid-user
</Location>


restart apache
# /etc/init.d/apache2 restart
rechown /srv/svn, the previous test may brake webdav
# chown -R www-data:svn /srv/svn


Test svn over WebDAV
$ svn co --username=someuser http://192.168.101.11/svn/doc
Authentication realm:  Incelligent Doc Repository
Password for 'someuser': *******

A    doc/testing.txt
Checked out revision 1.
$ echo "testing webdav" > doc/testing-webdav.txt
$ svn ci -m "testing webdav transport"






notes on setting up subversion

Class::Accessor debian package

The debian package for Class:Accessor is libclass-accessor-perl.

Install Class::Accessor to debian system Perl.
# apt-get install libclass-accessor-perl


List installed modules.
# lspm|egrep "Class.*Accessor"
/usr/share/perl5/Class/Accessor.pm
/usr/share/perl5/Class/Accessor/Fast.pm
/usr/share/perl5/Class/Accessor/Faster.pm




Class::Accessor debian package

raspbian watchdog



Install the watchdog daemon on raspberry pi raspbian

update `firmware`
$ sudo -s
# rpi-update


install the watchdog deamon
# apt-get install watchdog


load the watchdog module
# modprobe bcm2708_wdog
# echo "bcm2708_wdog" >> /etc/modules  


set /etc/watchdog.conf ...
this is what I ended up enabling
# cat /etc/watchdog.conf |egrep -v "^#.*"

max-load-1  = 24
max-load-5  = 18
max-load-15  = 12



watchdog-device = /dev/watchdog



realtime  = yes
priority  = 1

I just need to watch for system hangs ... the ping and the user commands seem nice though.

# shutdown -r now


raspberry pi software watchdog

keep raspberry pi images small



remove the GUI if you don 't need it

delete downloaded .deb packages
# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          3.6G  1.2G  2.3G  34% /
...

# ls /var/cache/apt/archives/
autoconf_2.69-1_all.deb      libldap2-dev_2.4.31-1+nmu2_armhf.deb     lockfile-progs_0.1.17_armhf.deb
automake_1%3a1.11.6-1_all.deb     liblockfile1_1.09-5_armhf.deb      m4_1.4.16-3_armhf.deb
autotools-dev_20120608.1_all.deb    liblockfile-bin_1.09-5_armhf.deb

...



# apt-get clean
# ls /var/cache/apt/archives/ 
lock  partial



# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          3.6G  1.1G  2.4G  32% /
...




keep raspberry pi images small

Install Log::Dispatch to debian system Perl.

Install Log::Dispatch to debian wheezy system Perl.



The Log::Dispatch debian package is liblog-dispatch-perl.



# apt-get install liblog-dispatch-perl
# lspm |grep Log|grep Dispatch
/usr/share/perl5/Log/Dispatch.pm
/usr/share/perl5/Log/Dispatch/Email.pm
/usr/share/perl5/Log/Dispatch/Handle.pm
/usr/share/perl5/Log/Dispatch/Syslog.pm
/usr/share/perl5/Log/Dispatch/Output.pm
/usr/share/perl5/Log/Dispatch/File.pm
/usr/share/perl5/Log/Dispatch/ApacheLog.pm
/usr/share/perl5/Log/Dispatch/Screen.pm
/usr/share/perl5/Log/Dispatch/Base.pm
/usr/share/perl5/Log/Dispatch/Null.pm
/usr/share/perl5/Log/Dispatch/Email/MailSendmail.pm
/usr/share/perl5/Log/Dispatch/Email/MailSender.pm
/usr/share/perl5/Log/Dispatch/Email/MIMELite.pm
/usr/share/perl5/Log/Dispatch/Email/MailSend.pm
/usr/share/perl5/Log/Dispatch/File/Locked.pm




Install Log::Dispatch to debian system Perl

install Time::Format to debian wheezy system Perl

Install Time::Format to debian wheezy system Perl.



Time::Format wheezy system Perl



# apt-get install libtime-format-perl
# lspm |grep Time|grep Format
/usr/share/perl5/Time/Format.pm




Install Time::Format to debian wheezy system Perl

rsync basics

rsync basics

A common use
$ rsync -azv -e "ssh -p 22" user@remote-host:/path/to/origin/ /path/to/destination


Sync the directory destination in the local host with the contents of the directory origin in the remote-host over SSH.

Common Options
 -v, --verbose            increase verbosity
 -a, --archive            archive mode; equals -rlptgoD (no -H,-A,-X)
 -z, --compress           compress file data during the transfer
 -e, --rsh=COMMAND        specify the remote shell to use 


-a expansion
 -r, --recursive          recurse into directories
 -l, --links              copy symlinks as symlinks
 -p, --perms              preserve permissions
 -t, --times              preserve modification times
 -g, --group              preserve group
 -o, --owner              preserve owner (super-user only)
 -D                       same as --devices --specials
 --specials               preserve special files
 --devices                preserve device files (super-user only)


Other Useful options-flags
 -n, --dry-run           perform a trial run with no changes made

 -P                      same as --partial --progress
 --progress              show progress during transfer
 --partial               keep partially transferred files

 --delete                delete extraneous files from dest dirs

 --exclude-from=FILE     read exclude patterns from FILE
 --exclude=PATTERN       exclude files matching PATTERN




Note that,
$ rsync -azv -e "ssh -p 22" user@remote-host:/path/to/origin /path/to/destination
without the slash after origin would create a copy of the directory user@remote-host:/path/to/origin
in the directory /path/to/destination
like /path/to/destination/origin







rsync basics