Tuesday, December 6, 2011

Simple browser cache bypass

I need a quick solution to go over a browser page caching problem...
After some research..... I look for this quick solution....
Add a random argument to your url..:

var forwardUrl = 'http://yourcachedpage.html?' + (new Date()).getTime();

Bye...



Thursday, December 1, 2011

JSON-P: quick and dirty how-to

JSONP borns to provides cross-domain resources interoperability....
It simply works by creating and adding a <script> element tag in runtime...

Here is a simple implementation.....

function methodA () {
//your code.....
//and call to remote(and with other domain) url.....
jsonp_request('http://another_site:1234/YourServletOrOtherService');
}


//
//http://another_site:1234/YourServletOrOtherService
//will returns a string similar to this...
//                    methodB([{"result":"pippo"}])
//
//methodB
//                 stay for the next js method that will be called....
//
//{"result":"pippo"}
//                 stay for json data structure to send as returns data
//
//


function jsonp_request (url) {
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("SCRIPT");
    script.type = "text/javascript";
    script.src = url ; 
    head.appendChild(script);    
}



function methodB (data) {
    var current_result = data[0].result;
    alert (current_result) ;
    //elaborate your data json structure..... a single value or an array of values.....
}


Reference url....: http://json-p.org

Bye....

Simple Reg-Exp...

Two simple regexp.......
for match string pippo.pluto
^.*(?:pippo.pluto).*$

or for not match string pippo.pluto
^((?!pippo.pluto).)*$

Useful links....
to test.....
http://www.regular-expressions.info/javascriptexample.html
to search ready-to-use reg expressions....
http://regexlib.com

Thursday, October 6, 2011

Recursively dos2unix....

Recusrsively dos2unix for all file in the current folder and all subfolders....

find ./ -type f -exec dos2unix '{}' \;



Bye...

Search and replace a string, recursively..... under linux

Under linux.....

sed -i 's/stringA/stringB/g' *
 
replace stringA with stringB in all files under current directory....
Recursively way.....
find ./ -type f -exec sed -i 's/stringA/stringB/g' '{}' \; 
 
Bye... 

apt-get through proxy server under Debian

Declare and export http_proxy and ftp_proxy into /etc/bash.bashrc

FTP_PROXY=http://your_net_account_username:your_net_account_password@proxy_host:proxy_port
HTTP_PROXY=http://your_net_account_username:your_net_account_password@proxy_host:proxy_port
export FTP_PROXY
export HTTP_PROXY


Open new console.... and you're ready....

Bye..

Monday, September 26, 2011

Web develop tools....

Some useful links for help designing and developping....

1) Create image of loading state....: http://www.ajaxload.info/

2) Create simple and clean forms, js and css inclusive...: http://www.phpform.org/

3) Search free icons(very good!!): http://findicons.com/

4) Test, and produce over 68 differents screenshot for each browser for your site: http://browsershots.org/

Bye...

Monday, September 19, 2011

Mootools FormCheck: Ajax configuration

Currently I need to use a, ready to use, form to login....
I decide to use form-check of mootools available at:
http://mootools.floor.ch/docs/formcheck/files/formcheck-js.html

This is my configuration to allow ajax authentication(script tag in the head...)
No other configuration. The rest is the pure standard form-check:

<script type="text/javascript">
        window.addEvent('domready', function(){loginFormCheck = new FormCheck('formular', {
            submit : false,
            submitByAjax: true,
            submitAction: './loginManager',                //Action page used to submit the form data to.
            submitMethod: 'post',                //Method used to submit the form, valid options : 'post' or 'get'
            onAjaxRequest : onAjaxRequest,                //Function to fire when the Request event starts
            //onAjaxComplete : onAjaxComplete,            //Function to fire when the Request is complete, before and regardless of Success or Failure
            onAjaxSuccess : onAjaxSuccess,   
            display : {
                errorsLocation : 1,
                indicateErrors : 2,
                flashTips : true,
                fadeDuration : 1500,
                scrollToFirst : false
            },
            alerts : {
                required : 'This field is ablolutely required! Please enter a value'
            }
        })});
       
        function onAjaxRequest () {
            document.getElementById("loadingDiv").style.display = "block";
        }
       
        function onAjaxSuccess () {
            document.getElementById("loadingDiv").style.display = "none";
            window.location = "./home.jsp";
        }
       
       
    </script>

loadingDiv is a div where I have a simply "loading" animated gif.
loginManager is my servlet the manage the login logic.
Bye

Monday, September 12, 2011

Thumbnails creations overview: Imagemagick for pictures form videos

First of all, I need to create thumbnails of various types of document.
Pdf, video, doc, xls...... ecc.....
Pdf:
Ensure to have imagemagick already installed....
In case of not, you give:
 
apt-get install imagemagick

For thumbnail of pdf document you give:
convert -thumbnail 200x200 document.pdf document_preview.png
where 200x200 is the height for width you want to give to the  document_preview.png
In case of more than one pages for pdf document, you can give directly the page you want to obtain the preview image:
convert -thumbnail 200x200 document.pdf[0] document_preview.png

Video(avi):
Install ffmpeg
apt-get install ffmpeg
install ffmpeg.
So give the follow command:
ffmpeg -itsoffset -4 -i xxx.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 95x155 yyy.jpg

Friday, September 9, 2011

AIRCRACK easy source compilation and installation under Debian Squeeze 6.0.2

With the following commands I correctly install aircrack..... on my debian 6.0.2..
The binary installation fault for me..... I forgot the exactly error....
So.....
apt-get install build-essential devscripts dpkg-dev debhelper
wget http://ftp.debian.org/debian/pool/main/a/aircrack-ng/aircrack-ng_1.0~rc1-2.dsc
wget http://ftp.debian.org/debian/pool/main/a/aircrack-ng/aircrack-ng_1.0~rc1-2.diff.gz
wget http://ftp.debian.org/debian/pool/main/a/aircrack-ng/aircrack-ng_1.0~rc1.orig.tar.gz 
for building dependencias we have to download the following packets for packets version dependencies 
wget http://ftp.de.debian.org/debian/pool/main/s/sqlite3/libsqlite3-dev_3.7.3-1_i386.deb
dpkg -i libsqlite3-dev_3.7.3-1_i386.deb
wget http://ftp.de.debian.org/debian/pool/main/libn/libnl/libnl-dev_1.1-6_i386.deb
dpkg -i libnl-dev_1.1-6_i386.deb
wget http://ftp.de.debian.org/debian/pool/main/libp/libpcap/libpcap0.8-dev_1.1.1-2_i386.deb
dpkg -i libpcap0.8-dev_1.1.1-2_i386.deb
dpkg-source -x  aircrack-ng_1.0~rc1-2.dsc
cd aircrack-ng-1.0~rc1 
dpkg-buildpackage 
cd .. 
dpkg -i aircrack-ng_1.0~rc1-2_i386.deb
(In my case before the last dpkg -i commanmd I need to remove iw package..(with apt-get remove iw)) 


Bye and good luck......

Thursday, September 1, 2011

MySQL: install as deamon, for start/stop at system startup/shutdown (under CentOS 5.6 64 bit)

Go under mysql execution commands directory....:
cd /usr/bin/
Create startupMysql.sh file with the follow code:
#!/bin/bash
/etc/init.d/mysqld start
Create shutdownMysql.sh file with the follow code:
#!/bin/bash
/etc/init.d/mysqld stop
Give to them the execution privileges only for root
chmod 700 startupMysql.sh
chmod 700 shutdownMysql.sh
Choose the your "favourite" rcXXX.d directory (depends to your configuration)
to put into your deamon startup/shutdown commands.
I choose rc5.d, so:
cd /etc/rc5.d
and give the following ln -s commands:
ln -s /usr/bin/startup_mysqld.sh S100startupMysql
ln -s /usr/bin/shutdown_mysqld.sh K100shutdownMysql
Your deamon startup/shutdown commands are done well...
Now clean up the mysql log file(you find it into /etc/my.cnf), usually /var/log/mysqld.log
cd /var/log
echo "" > mysqld.log
to check, if at the system restart, you mysql restart too.
Restart the system.....:
shutdown -r now

Byw


MySQL installation and configuration under CentOS 5.6 64-bit

We have to search the name ho the packet to install....
yum search mysql
For my distribution the packet name mysql-server.x86_64
so do:
yum install mysql-server.x86_64
At installation completed, mysql is without password, and is down.
So startup the mysql
service mysqld start
so give the following command to reset password
UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE user='root';
and
flush privileges;
to runtime flush up the executed command.
Give exit to logout to the mysql connection and test new root account logging in with the new credentials:
mysql -uroot -p

Bye

Wednesday, August 31, 2011

VSFTPD installation and configuration under CentOS 5.6 64-bit

INSTALLATION
Execute the follow command to search available packets for you repository
yum search vsftp
This is the output.....
#Loaded plugins: fastestmirror
#Loading mirror speeds from cached hostfile
# * base: centos.fastbull.org
# * extras: centos.fastbull.org
# * updates: centos.fastbull.org
#================================ Matched: vsftp #================================
#vsftpd.x86_64 : vsftpd - Very Secure Ftp Daemon
So now we can correcly install it via:
yum install vsftpd

CONFIGURATION
Add a new user:
useradd -m example
give a password
passwd examplePassword

Now we can modify the vsftp configuration file...
/etc/vsftpd/vsftpd.conf
to allow or not the anonymous access and the other settings....

After we can start the vsftp deamon
/etc/init.d/vsftpd start
Every configuration file editing wants a restarts of the deamon...
/etc/init.d/vsftpd restart


USE
connect via ftp to your host and one of the availables system accounts.


Bye

Thursday, August 25, 2011

MySql: how to reset root password

Ensure that all mysql processes are down.
Kill all one by one or use
killall mysqld
and/or
killall mysql
Then create a new file /home/usr_home/reset_root_pwd with the following content

UPDATE mysql.user SET Password=PASSWORD('YourNewRootPassword') WHERE User='root';
FLUSH PRIVILEGES;

Then login a console as mysql user and give the following command:
mysqld_safe --init-file=/home/usr_home/reset_root_pwd &

 
After stop the server and restart it.
Now You should be able to connect as root with the new password.

Bye...

Usefull links: 
- http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
- http://openskill.info/infobox.php?ID=1033


Wednesday, August 24, 2011

Friday, August 19, 2011

YUI DataTable: Highlighting Cells, Rows, or Columns

Usefull links:
- http://developer.yahoo.com/yui/examples/datatable/dt_highlighting.html
- http://developer.yahoo.com/yui/datatable/
- http://developer.yahoo.com/yui/articles/hosting/?datatable&MIN#configure
- http://yuilibrary.com/
- http://twiki.di.uniroma1.it/pub/TWiki/YahooUserInterfaceContrib/examples/datatable/inlineediting.html

Thursday, July 14, 2011

Alfresco commonly used data types (out of the box)

Commonly used data types out of the box are:
  • d:text: A text value, a character string
  • d:mltext: A multilingual text value where many localized representations of the text value may be held
  • d:content: An arbitrarily long text or binary stream
  • d:int: An integer value (java.lang.Integer equivalent)
  • d:long: A long value (java.lang.Long equivalent)
  • d:float: A float value (java.lang.Float equivalent)
  • d:double: A double value (java.lang.Double equivalent)
  • d:date: A date value (java.lang.Date equivalent)
  • d:datetime: A date and time value (java.lang.Date equivalent)
  • d:boolean: A boolean value (java.lang.Boolean equivalent)
  • d:any: Any value, regardless of type

Original source link:
http://docs.alfresco.com/3.4/index.jsp?topic=%2Fcom.alfresco.Enterprise_3_4_0.doc%2Fconcepts%2Fmetadata-model-props.html

Bye...

Join and split pdf files under linux with pdftk

Install pdftk
apt-get install pdftk

then to merge, example command is:
pdftk test1.pdf test2.pdf cat output test_output.pdf

to split(from page 1 to 5)
pdftk test_output.pdf cat 1-5 output test_output2.pdf


official site link: www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
official site quick examples link: www.pdflabs.com/docs/pdftk-cli-examples/


Bye...

Tuesday, July 12, 2011

Skype - up/down camera problem on Debian Squeeze 32 bit

Here are for a curious problem with camera on skype.
Differently of cheese(all it's ok) image camera output on skype is rendered up/down.

So this solution works with my Debian Squeeze 32 bit.....
First of all those libraries should be installed....
- libv4l-0(that contains v4l1compat.so)
and

If you haven't them.... give...
apt-get install libv4l-0
apt-get install libqt3-mt

After you can try in the same shell to export those variables

export QT_PLUGIN_PATH=/usr/lib/qt3/plugins
export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so

so you can try to launch skype and assure that now webcam output is ok.....

If so.... now you only do a simple script to wrap the variables export before launching skype....
One way....
cp /usr/bin/skype /usr/bin/skype_appl
echo "" > /usr/bin/skype
(to empty /usr/bin/skype file)
and after edit /usr/bin/skype in way of it contains those lines:
#!/bin/bash
export QT_PLUGIN_PATH=/usr/lib/qt3/plugins
export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so
skype_appl&


Now launch from terminal skype or add a new launcher on Desktop/Toolbar
and all it's ok!!!


Bye

Hamachi LogMeIn - install and configure on Debian 32 bit Squeeze 6.0.1

Note that the follow post:
Hamachi LogMeIn on Debian 64 bit Squeeze
at the link
http://maurizio-franco.blogspot.com/2011/07/debian-64-bit-squeeze-601-install-and.html
...explains how to install LogMeInHamachi on Debian with amd64 architecture.

For Debian 32 bit architecture it's all the same....
Pay only attention to the deb dependencies packages.... that should be for i386(or your different.....) architecture.

This is the link for
https://secure.logmein.com/labs/logmein-hamachi_2.0.1.15-1_i386.deb

At this
https://secure.logmein.com/labs/
the other versions.....

Bye....

Hamachi LogMeIn - install and configure on Debian 64 bit Squeeze

- INSTALLATION -
Download LogMeIn deb package.
At write time the current url for download the amd64 version is: https://secure.logmein.com/labs/logmein-hamachi_2.0.1.15-1_amd64.deb
(Complete list of available versions at https://secure.logmein.com/labs/)


Dependecies for the hamachi package is lsb.
Personally I installed the follows
libcairo2_1.8.10-6_amd64.deb
libgtk2.0-0_2.20.1-2_amd64.deb
libpango1.0-0_1.28.3-1+squeeze2_amd64.deb
lsb-desktop_3.2-23.2squeeze1_amd64.deb
lsb-core_3.2-23.2squeeze1_amd64.deb
lsb-cxx_3.2-23.2squeeze1_amd64.deb
lsb-graphics_3.2-23.2squeeze1_amd64.deb
lsb_3.2-23.2squeeze1_all.deb
and for at the end
logmein-hamachi_2.0.1.15-1_amd64.deb

But if you have a "good" sources.list you can before works with...
apt-get clean
apt-get upgrade
apt-get update
and after by apt-get install the differents depends-on packets.....

When you install logmein-hamachi_2.0.1.15-1_amd64.deb
(dpkg -i logmein-hamachi_2.0.1.15-1_amd64.deb)
and you have the current message.....
Starting LogMeIn Hamachi VPN tunneling engine logmein-hamachi
.....you have successfully installed LogMeIn.....

- CONFIGURATION -

We have to follow /opt/logmein-hamachi/README file......
So....

###>  hamachi login
...set up hamachi deamon....

###> hamachi set-nick <nickname>
....optionally command.......set the <nickname> (without < and >....:-)) to your machine in the hamachi net
###> hamachi join <network id>


....join your pc to the <network id> net......
....
......
........ now you are joined!!!!.....




###>hamachi list
.....list network members and their status....* if active....
###>hamachi
....give information about you....(as your ip!!...)


Bye.