domenica 5 novembre 2017

UBUNTU - Reduce PDF file size with pdf2gs and gs2pdf

First convert pdf to ghostscript:
pdf2ps file1.pdf file2.ps
then reconvert ghostscript to pdf:
ps2pdf file2.ps file3.pdf
file3.pdf is smaller about 50% than file1.pdf bye

UBUNTU - Batch convert SVG files to PDF and join them in a single PDF

I extracted SVG pictures from a site that allow me only to see the files and not to download it with Chrome browser and this extension:

https://chrome.google.com/webstore/detail/export-svg-with-style/dkjdcaddoplepioppogpckelchefhddi?utm_source=chrome-app-launcher-info-dialog

The result is a bunch of SVG files numbered progressively (e.g saved0.svg,saved1.svg....,saved45.svg).
I renamed the first 10 files saved0.svg to saved9.svg to saved00.svg..saved09.svg to avoid problems when merging all pages together. I moved all in a folder and applied this little bash script:



paste it in new file give it execution permission ( chmod 755 filename)
 I dropped the script in the same folder but you can put in /usr/bin to have it always ready ..
The script simply check all files on the folder, verify if they are svg files and attempt comversion to pdf.
The result should be a bunch of pdf files numbered progressively (e.g saved0.pdf,saved1.pdf....,saved45.pdf).


Now with pdftk we can join all single pdf pages lying in the folder in one single file (You need an ordered sequence of files to do it).

pdftk *.pdf cat output FILE.pdf

That's all

mercoledì 22 marzo 2017

BUSYBOX - SSHing to a W-Gate Router

I had to ssh ing to this box running a a stripped version of BusyBox witha really tiny ssh server support with Dropbear that wasn't accepting connection from a regular ssh client on Ubuntu.
After succesfully trying connecting with the dbclient (the dropbear client that acts more or less as a ssh client) , dbclient that is available in ubuntu official software I have noticed that thas box need a specific kind of MAC (Message Authentication Code) algorithm to connect.



Using this option ( -o MACs=hmac-sha1 ) the ssh client connected succesfully letting me make the tunnel that I wanted:


ssh -o MACs=hmac-sha1 -vvvl user ip


mercoledì 15 marzo 2017

UBUNTU - pdftk to join 2 pdf, one wiht odd pages and one with even pages

I have 2 files resulting from my network scanner yet in pdf format.
One file has all even pages with correct order ( Pari.pdf ).
The other has all odd pages but with inverted order (Dispari_invertite.pdf)
The document will start with an even page and then I have to shuffle page one by one from every source file.

This is the (impressive for me) one command solution:




pdftk A=Pari.pdf B=Dispari_invertite.pdf shuffle A Bend-1 output collated.pdf


I assume that you have been entered in the working folder before. The "Bend-1" option reverse the order of B file; so if you need to join 2 ordered odd and even files will use "B" instead. Collated.pdf is the output file of course. For me its an impressive one line command that make me love linux terminal to make things quicker and better than installing a lot of dedicated software. Bye

mercoledì 11 maggio 2016

OPENWRT - Using Sanguinololu as USB to serial adapter USB2TTL

I had to connect to the serial interface of a router with OpenWRT, the router is Pirelli AGPF .
My old cable (a CA42 Nokia Cable) was broken, so I tryed with a crappy usb 2 serial adapter with ch340 chip with no luck.

I remeber I have a spare Sanguinololu board that I buyed to replace my old one on my 3D Printer. I have seen is possible to use an Arduino Uno to act as usb to serial interface, so I thinked the Sanguinololu could do the same.

Ok, let me explain...

IMPORTANT : To enable the serial socket we need to short the reset pin to the ground in some way, I used an old jumper to keep the board resetted.

Under the USB female port of the Sanguinololu there is a socket labelled USB2TTL , in my case nothing is soldered to it.
We will use Tx , Rx and Ground on USB2TTL socket.

Could be a good idea to test the socket firing up your favourite program (hyperterminal, putty, minicom ecc) shorting Tx with Rx and check if typing something there is a return on the console.

If you want you can solder some male pins to Rx  , Tx and GND but I found a less invasive solution.
Looking the ATMEGA pinout http://reprap.org/wiki/Sanguinololu#Pin_Assignments

I found these pins on ATMEGA socket that are connected to the corrispective pins under the USB port:
  •  ftdi Tx on pin 14
  •  ftdi Rx on pin 15 
  •  GND on pin 31
So I removed the ATMEGA chip and inserted 3 needles on that and used alligator clips to connect to my router Rx , Tx and GND.

Aggiungi didascalia

This solution seems intresting because is fully reversible without soldering nothing on Sanguinololu board.

Maybe could work in other similar platform where there is an arduino-like board.

By the way .. ther router was successfully recovered.




martedì 22 settembre 2015

UBUNTU - DU (Disk usage)

Per vedere le dimensioni di tutti i file e le cartelle al livello 1  ( non entra nelle sottocartelle)

To show dimension of each file and folder at level 1 (not entering inside subfolders)


du -h -d 1 -t 1G


-h stands for "human readable" (show M for megabytes, G for gigabytes and so on)
-d deep of the folder search
-t threshold size (file bigger than 1 GB)



venerdì 11 settembre 2015

ANDROID - Reboot phone via ssh for ZTE MD SMART (MIMOSA MINI)

Need rooted phone


 reboot -f

" -f " stands for force , without my phone refuse to reboot

mercoledì 12 novembre 2014

UBUNTU - How to add a missing configuration to Ubuntu 14.04 with xrandr

Hello,
the problem was that, I made a fresh install of Ubuntu 14.04 on a Dell Optiplex 860 , with a AOC e943fws monitor that have a 1360x768 resolution at 60Hz.
The default configuration offers me only 1024x768 or 800x600 resolutions.
I spotted was possible to add the missing resolution with xrandr in this way.

give cvt with resolution and frequency

me@box:~$ cvt 1360 768 60
# 1360x768 59.80 Hz (CVT) hsync: 47.72 kHz; pclk: 84.75 MHz
Modeline "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync

Then give xrandr --newmode omitting "Modeline" word on the command
 It gives You no output.


me@box:~$ sudo xrandr --newmode "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync

 
then add new mode to our current output , for me was VGA1


me@box:~$ sudo xrandr --addmode VGA1 1360x768_60.00



Now giving xrandr I obtain this output with the new resolution listed

me@box:~$ sudo xrandr
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 32767 x 32767
VGA1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768       60.0*
   800x600        60.3     56.2 
   848x480        60.0 
   640x480        59.9 
   1360x768_60.00   59.8 
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)


Now we can change the resolution


 webstation1@webstation1:~$ sudo xrandr --output VGA1 --mode 1360x768_60.00


And for me that works fine.
At this point You will find the new resolution also in Monitor settings.

Bye

martedì 18 marzo 2014

Create AP with UBUNTU

You need to create infrastructure (Access Point mode) wireless hot-spot rather Ad-hoc hot-spot. In linux(ubuntu) i used ap-hotspot and which works for me(i got connected WP8 and Android 4.4, dont know about iPhones).
For installation
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install ap-hotspot
Then configure it as
sudo ap-hotspot configure
Configure_Sample
It will asks for interfaces, Access point name(which can be anything you want to see as wifi_hotspot name), password(which is your wifi_hotspot security key).
Now, if you able to configure successfully and dont get any kind of Unsupported wifi errors(if you get that simply means, your wifi_card doesnt support infrastrucutre Access point wifi_hotspot, so can do nothing on it), then procceed.
So just now start your hotspot as
sudo ap-hotspot start
If you want to stop then
sudo ap-hotspot stop
If you wanna see all available commands
sudo ap-hotspot
You don't see this hot-spot running in any indicator or something, i am still finding it how to determine status checking of it.
I am using is from last few weeks, and no bugs(no side-effects too) yet. I am using Gnome-Ubuntu 13.10 amd64 sharing eth0 to my WP8.

lunedì 10 febbraio 2014

BlackBerry Pearl 9105, Bold 9900 ,how to extract contacts without software....

Pair Your BB with an other phone using bluetooth (I used an android one).

If You have Italian Language Menu (like me)
Go in,  "Gestione Connessioni" > "Opzioni Bluetooth" > Select the paired phone or pc > "Trasferisci Rubrica"

If You prefer English Language Menu
Go in,  "Manage Connections" > "Bluetooth Options" > Select the paired phone or pc > "Transfer Contacts"

In this way the BB will send to the paired phone / pc a file Phonebook.vcf with all Your contacts.

You can then import this file in gmail from the pc for example or use it for other tasks, since it is a text file that You can read and edit with a simple text editor.

Probably should work for other BB models.

Edit.
I did the same procedure for a BB Bold 9900 ant it works flawlessly , the difference is that with this phone it creates a vcf file for every contact entry.

Bye


mercoledì 22 gennaio 2014

UBUNTU - How to kill several process with the same string in their name

new post

sudo kill -9 $( pgrep sshd )

sshd is the command to kill, easier then the old post


old post

Simply open Your terminal ctrl+alt+T an type


fem@ordinateur:~$ ps -ef | grep ingularity | awk '{print$2}' | xargs kill -9



Let's analyze the code....


fem@ordinateur:~$ ps -ef | grep ingularity

give the output of current processes filtering them with the "ingularity" string.


fem@ordinateur:~$ ps -ef | grep ingularity | awk '{print$2}'


Then pipe the output to awk that extract the pid and print them (the second column only).


fem@ordinateur:~$ ps -ef | grep ingularity | awk '{print$2}' | xargs kill -9


 Then pipe again sending to xargs and kill to terminate the pid found

Bye








giovedì 28 novembre 2013

Win7 - How to emulate middle-click mouse in Synaptics tuchpad with 2 buttons only

In win7 to do so:

Open regedit (registry editor) and create a DWORD 32 bit with the name 'HasBothButtonFeature' with value 1 at the location:


HKEY_LOCAL_MACHINE\Software\Synaptics\SynTP\Defaults\

log off and log on and you will be able to emulate the missing third button of touchpad pressing both the other buttons.

Bye




martedì 3 settembre 2013

UBUNTU - Change keyboard map language from terminal

For changing from default english keyboard map to italian simply open terminal and type:

setxkbmap it


Obiouvsly you can change "it" with every keyboard map you prefer.
That' all!!

venerdì 29 marzo 2013

UBUNTU - remote connection using rdp protocol failure connecting to 12.04

Premise:
I use Ubuntu 12.04 with classical gnome interface ( no unity )

Question:

new install of 12.04 64 bit
 installed vnc4server and xrdp
 trying to connect remotely to it using rdp protocol
 just getting blank screen with my desktop background
 then dialog box saying /usr/bin/compiz "the application has closed unexpectently"
 what can i try to allow me to access my desktop?

answer:

In 12.04 for Gnome-Classic with no effects use:

echo "gnome-session --session=gnome-fallback" > ~/.xsession

martedì 26 marzo 2013

Riconfigurare Xorg.conf su Packard Bell EasyNote TK85

Dopo fresh install Ubuntu 12.04 e installazione bumblebee per gestire Nvidia Optimus, Xorg non piu funzionante

da Xorg.0.log

non trovava piu i driver di nulla, quindi rimetto almeno quelli intel

fem@ordinateur:~$ sudo apt-get install xserver-xorg-video-intel

e qualcosa rivà ma niente touchpad (si mouse usb) e risoluzione sballata

editare xorg.conf e portare risoluzione a 1366x768

riavviare X , ctrl-alt-F1 killandolo /usr/bin/X

ok risoluzione touchpad nada

fem@ordinateur:~$ sudo apt-get install xserver-xorg-input-synaptics

riavviare X , ctrl-alt-F1 killandolo /usr/bin/X

sembra ok e anche touchpad ok

Riconfigurare optimus ....seguire guida

http://bumblebee-project.org/install.html#Ubuntu

ovvero:

sudo add-apt-repository ppa:bumblebee/stable

sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update

sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic



reboot or login

venerdì 24 agosto 2012

ANDROID - Remount Android rootfs RW via (ADB) Shell

To remount your root fs on android device as RW (read write) for any purpose without software to install on your devices, connect to your android phone via ADB or do it from internal Shell and type:

For RW roofs:

mount -o rw,remount -t rootfs rootfs /
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system


For RO rootfs:

mount -o ro,remount -t rootfs rootfs /
mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system


Working on Samsung Galaxy S5570 (Mini/Next) and SonyEricsson Xperia X8.

Reference:
http://chuacw.ath.cx/blogs/chuacw/archive/2011/02/25/remounting-android-rootfs.aspx

giovedì 10 maggio 2012

UBUNTU - Shell converting a list of images to one pdf

This is one example of why I love Ubuntu , and generally Linux.
I have to convert a bounch of high resolution Jpeg files to a lower resolution and I suppose to convert them to pdf and I know that via shell I can do it really quickly avoiding installing programs and dealing with complex graphical interface for doing a so simple task.

In Ubuntu (or Linux) I need ONE COMMAND in shell!!!!

This is what to do: I must have 'convert' command working

convert Man Page


File to convert are File_001.JPEG,File_002.JPEG,......File_050.JPEG





fem@rodizio:~$ convert File_0*.JPEG Single_pdf.pdf  


That's all, I have in a simple pdf 50 pages (one for every image I had) in that case, ready to print.

giovedì 15 marzo 2012

Midori Web browser - Using SOCK5 proxy server

If you need to use a ssh secure tunnel (as explained here for example)you have to set the correct proxy SOCK5 server in your browser.
Unfortunately Midori web browser lacks of this feature out of the box, but as mentioned on the official faqs we can found a workaround.

Install tsocks:


user@user-laptop:~$ sudo apt-get install tsocks


Edit the /etc/tsocks.conf file:


user@user-laptop:~$ sudo vi /etc/tsocks.conf


Edit in this way :


# Default server
# For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0
# the server at 192.168.0.1 should be used (again, hostnames could be used
# too, see note above)

server = 127.0.0.1
# Server type defaults to 4 so we need to specify it as 5 for this one
server_type = 5
# The port defaults to 1080 but I've stated it here for clarity
server_port = 1080


In this example configuration the proxy server is the localhost, the proxy server is a Sock5 and the localhost port is 1080 (you can change port number how you prefer)

Then launch midori in this way from terminal:


user@user-laptop:~$tsocks midori


Thats all