How to change MAC address in Debian 6.0 Linux

2012-01-11

First of all we have to stop networking. /etc/network/interfaces file and under eth0 (or other network interface) add following line:

 hwaddress ether your_new_mac_address

After that you can start networking again. 

Example:

sudo /etc/init.d/networking stop  

sudo vi /etc/network/interfaces

#now add:  hwaddress ether 01:02:03:04:05:06 

sudo /etc/init.d/networking start

 


How to use Blackberry App World in unsupported country

2011-05-22

If you have BlackBerry Playbook but are now in unsupported country, You can’t download or update any applications. Looks like 20th century, doesn’t it? But You know that we are in 21st century and RIM cannot do anything about it ;)

Here I will describe a way to access AppWorld from unsupported country. The only thing you need is Mac with wifi, connected to the Internet using ethernet cable. If You have a PC with windows 7, you can follow this tutorial.

Generally, AppWorld checks Your IP address is it from the country they allow. So basically, we need to change the IP address we are using to one from supported countries. For example from US. To this, we will use VPN.

Firstly, we have to find VPN server with IP from USA and connect our Mac to it. Secondly we have to share this connection through wifi.

How to connect your Mac to VPN you can read here.

How to share this connection read here.

PS. If you don’t want to buy VPN account, try this one for free.

PPS. If you like this post, write it in comments ;)


How to compile and deploy BlackBerry PlayBook Tablet WebWorks program on MacOs (and maybe linux)

2011-03-08

If you want to make programs for BlackBerry PlayBook Tablet using html5 and javascript you have to download and install SDK. It’s quite simple and described in documentation quite well. But when you start compiling and deploying program to simulator things are getting quite complicated and very badly documented (at least at the time when this post is written). Even a program downloaded from Blackeberry tutorial doesn’t want to compile.

First of all, to compile a program, you have to compress all files of your project (usually those ate html, js, css files and images) into a single zip file. First mistake that you will make is adding whole folder to archive . This doesn’t work ;) You should archive only files. Secondly, there shouldn’t be any unnecessary files like eclipse’s .project or Mac-Os’s .DS-Store hidden files. If compiler will find some of them i zipped file – it will fail.

So here is a short tutorial how to get started developing for  BlackBerry PlayBook Tablet using WebWorks (and not Adobe AIR) on MacOs without any software for money.

  1. Create folder where your programs will be stored. For this tutorial let’s call it “progs”
  2. Inside this folder you can create as many folders as you want. One folder per program. For example you can extract SketchBook example program that can be taken from BlackBerry tutorial page and rename that folder to “sb”. Just try using short folder names without spaces and any other unnecessary symbols, because compiler seems to not like such names.
  3. Inside folder "progs" create file named "compile_deploy" and fill it with:
    #!/bin/bash
    dir="sb" #directory name
    path="/Users/Username/bbwp/" #path to SDK
    password="pass" #password set on emulator
    ip="172.16.220.135" #IP of emulator
    #do not edit from this point
    cd $dir
    find . -name '*.DS_Store' -type f -delete
    zip -r ../$dir.zip *
    cd ..
    "$path"bbwp $dir.zip
    "$path"blackberry-tablet-sdk/bin/blackberry-deploy -installApp -password $password -device $ip -package bin/$dir.bar

    In the first part of file there are some variables that should be changed: directory in which is the program (“sb”), path to directory where SDK was installed, password set in emulator, IP address of emulator.

  4. Start terminal. go to “progs” directory and run command:
    chmod a+x compile_deploy
  5. Now if you run
    ./compile_deploy

    Script that we just created will remove all DS_STORE files, zip all files inside directory, compile progarm and deploy everything into emulator (which by the way should have been started before ;))

  6. Test your program :)

If you have any questions feel free to ask in comments.


Some useful linux commands for a new server

2011-02-15

First of all I would recommend to change the port of ssh:

vi /etc/ssh/sshd_config

service sshd reload

Find line Port 22 and change it to some other number greater than 1024.

Then, you would like to login to the server without using password. This procedure is described here. By the way, if by that time you have changed your ssh port, don’t forget to add -p1024 (or other port used) tu ssh commands you use in this tutorial. What is more, it is recommended to set .ssh folder permissions to 700 and .ssh/authorized_keys to 640:

chmod 700 .ssh

chmod 640 .ssh/authorized_keys


How to list folders with their sizes on Linux

2011-02-02

I catched myself I google for this every month or two, so I decided to write it here so I (and you) could always find it.

If you need to list all directories with their sizes use this:

du --max-depth=1 -h

Yes, its so simple :)


Reinstalling WordPress Multisite (Warning: An existing WordPress network was detected.)

2010-11-08

There can be some reasons why you want to reinstall wordpress multisite (network). For example, you decide to change it from sub-domain to sub-directory. Even if you remove all entries from wp-config.php file, it won’t let you reinstall network and will write: “Warning: An existing WordPress network was detected.“.

To remove this message, you have to delete these tables from database (after removing everything from config file):

  • blogs
  • blog_versions
  • site
  • sitemeta

That’s it, now you can start installing WordPress network (Multisite) as if it was never installed before :)


WordPress 3 for multilanguage site (using wp multisite network)

2010-11-08

If You have to maintain a site with more than one different languages you have three options:

  1. Install separate WP sites each with its own language, database, files, etc. Advantage of this method is that you can have different site structure for each language. Drawbacks are that you have to maintain several WordPress installs – update and backup everything separately. What is more, several installs will consume hard disk space on your server.
  2. Install one of plugins for multilingual site. It doesn’t have drawbacks of the first point, but there are other disadvantages. You have to learn special syntax to write multilingual posts. What is more, you have to write pages in all languages at once. This can be very inconvenient in some cases. That’s why I recommend you third option.
  3. Use new feature of WordPress 3 – network of sites (Multisite). It let’s you create number of blogs (sites) using single wordpress install. Every site can be used for a site in a different language. This way with one WP install you have site with multiple languages. What is more, every site can be edited separately, meaning you can write a post in one language on one day, and translate whenever you want to (or even never :)).

Short multilanguage wordpress tutorial

First of all, you have to enable multisite in your WordPress 3. To do that, follow these simple steps from WordPress documentation.

Little tip: you can enable sub-directory sites even if your blog is older than one month. Just google a little bit or ask in comments, I’ll try to find it.

Now, if you want to make a list of all available languages of your site, you can use a function from social ink. It provides simple function that generates list of links to all of sites sub-sites. If you name all your sub-sites according to their language, you already have a function that can be inserted in your header.php file to link all available languages.


Insert (embed) Google map with saved position and zoom level

2009-10-27

When making maps through “My Maps” and using “Paste HTML to embed in website” field to post it to you site, final map is often not zoomed properly, and can be positioned not very well… To overcome this, find the src=”" property of iframe tag you just copy-pasted and change its value (what goes after src=” and next ) with URL from “Paste link in email or IM” field.

Thats it :)

Example:

Paste HTML to embed in website:

<iframe width=”425″ height=”350″ frameborder=”0″ scrolling=”no” marginheight=”0″ marginwidth=”0″ src=”http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=102719723394616996847.00046f832873f2afd6c03&amp;ll=55.273186,23.354578&amp;spn=1.250365,4.485588&amp;output=embed“></iframe><br /><small>View <a href=”http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=102719723394616996847.00046f832873f2afd6c03&amp;ll=55.273186,23.354578&amp;spn=1.250365,4.485588&amp;source=embed” style=”color:#0000FF;text-align:left”>Map</a> in a larger map</small>

Change bold text with text from Paste link in email or IM:

http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=102719723394616996847.00046f832873f2afd6c03&ll=54.706772,25.213623&spn=0.211449,0.497818&z=11

PS. By the way if you have some other tips like this, you are welcome to post them in comments.


Change encoding of all files in folder on Unix, Linux or MacOS

2009-04-05

Here is some simple bash script to bulk change encoding of all files in directory. It uses iconv for change of encoding.

#!/bin/bash

if [ $# -ne 3 ]; then
echo “usage: “$0″ dest_directory original_encoding destination_encoding”
exit
fi;

dir=$1
from=$2
to=$3

if [ ! -d $dir ]; then
mkdir $dir
fi

for f in $( ls . ); do
if [ -f $f ]; then
iconv -f $from -t $to $f > $dir$f
fi
done

To run it, create a file recode.sh and paste above code into it. Then in terminal run

chmod +x recode.sh

adn then just

./recode.sh encoded_dir/ ISO-8859-13 UTF-8

Command mentioned above recodes all files in current directory from  ISO-8859-13 encoding to UTF-8 and copies new files to encoded_dir/ directory.


Optimize MySQL

2009-03-05

To get some really good advices on your MySQL DB on server run these commands:

wget http://mysqltuner.com/mysqltuner.pl

chmod +x mysqltuner.pl

./mysqltuner.pl

Of course this would work only on unix server (not Windows;)) and you should have wget installed


Follow

Get every new post delivered to your Inbox.