Install Meld if you don’t have it already
sudo apt-get install meld
Configure git to skip the difftool prompt, suggesting diff tools.
Set meld as default diff tool
git config --global difftool.prompt false
git config --global diff.tool meld
Run following command to open and see the diff files in meld
git difftool
* {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
First, list all shared folders on a remote computer
$ smbclient -L 192.168.1.16
Response looks like this:
Enter haris's password:
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.34]
Sharename Type Comment
--------- ---- -------
Public Disk My Public folder
Then hook right to Public folder, for example
$ smbclient //192.168.1.16/Public
After successful login, you will get a command prompt.
Enter haris's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.34]
smb: \> ls
. D 0 Fri Jun 17 09:02:43 2011
.. D 0 Fri May 20 00:44:39 2011
Type help to display all available commands
On my Ubuntu I run Apache vhost for each of my projects.
Now, wouldn’t it be cool if you could access your Apache vhost from IE running in VirtualBox!?
I managed to solve this problem by editing a Vbox instance settings:
Settings: Network: Adapter 1: Attached to: Bridged Adapter
Start a VirtualBox instance and type http://localhost in IE and you’ll see a localhost running on Ubuntu.
Now, associate IP address to a host name in Windows (192.168.1.38 is my Ubuntu IP address)
# c:/Windows/System32/drivers/etc/hosts
192.168.1.38 projectx.local
and Ubuntu
# /etc/hosts
192.168.1.38 projectx.local
Then create a new Apache config file
#/etc/apache2/sites-available/vbox-projectx
<VirtualHost projectx.local>
DocumentRoot /var/www/projectx
</VirtualHost>
Enable the config
$ sudo a2ensite vbox-projectx
$ sudo /etc/init.d/apache2 restart
Now, in IE (running in VirtualBox) type http://projectx.local and… that’s it
Create a new file
$ sudo vim /etc/init.d/$NAME
Change the template to suit your needs
#!/bin/bash
case "$1" in
start)
# start commands here
;;
stop)
# stop commands here
;;
restart)
# restart commands here
;;
*) # no parameter specified
echo "Usage: /etc/init.d/$NAME start|stop|restart"
exit 1
;;
esac
exit 0
Hook the script to all runlevels
$ sudo update-rc.d $NAME defaults
Let’s say you have a gallery and it consists of three database tables (photos, category and gallery). Each of these tables has lots of related data, obviously…
By following the old database routine, I started indexing data from top to bottom (from gallery to photos table).
But this resulted in a weird behavior where SOLR would index gallery id and name, and only the first category; It simply ignored all other gallery categories and photos.
After spending days mind boggling what could go wrong, it suddenly occurred to me that the proper way to index data into SOLR would be to index is “opposite direction”, from bottom to top that is (from photos to gallery).
It was a great relief to finally see all relational data properly indexed :)
The example that bothered me was:
MySQL schema
photos
- id
- categoryId
- views
- url
- title
category
- id
- name
- galleryId
gallery
- id
- name
SOLR db-data-config.xml
<dataConfig>
<dataSource
type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/database"
user="username"
password="password"/>
<document name="gallery">
<entity rootEntity="true" name="photos" query="select *, rand() as uuid from photos">
<field name="photo_id" column="id" />
<field name="photo_categoryId" column="categoryId" />
<field name="photo_views" column="views" />
<field name="photo_url" column="url" />
<field name="photo_title" column="title" />
<entity name="category" query="select * from category where id='${photos.categoryId}'">
<field name="category_id" column="id" />
<field name="category_name" column="name" />
<field name="category_galleryId" column="galleryId" />
<entity name="gallery" query="select * from gallery where id='${category.galleryId}'">
<field name="gallery_id" column="id" />
<field name="gallery_name" column="name" />
</entity>
</entity>
</entity>
</document>
</dataConfig>
To create swap space in a file:
First, create a file. I have 4GB of RAM, hence I create 4GB large file
$ sudo dd if=/dev/zero of=/media/4GB.swap bs=1G count=4
Set proper file attributes
$ sudo chmod 600 /media/4GB.swap
Set created file as a swap space
$ sudo mkswap /media/4GB.swap
Start swapping
$ sudo swapon /media/4GB.swap
Edit the fstab file
$ sudo vim /etc/fstab
and set the swap file to mount automatically on next reboot
/media/4GB.swap swap swap defaults 0 0
With the release of PHP 5.3.0 there is an option to shorten the ternary operator.
So, if we start with variable $foo, which is true ($foo = true), instead of writing:
$bar = $foo ? true : false; // $bar = true
you can easily shorten it like this
$bar = $foo ?: false // $bar = true
The bad side of using a short ternary operator is that most of PHP IDEs are marking it as syntax error (well, at least for now)
One of the best ways to report a bug in Ubuntu is to report it right at Launchpad.
First, you need to identify a process that is causing a problem.
Open “System Monitor”, click on “Processes” tab and find a process ID that is bugging you.
Then open “Terminal” and run following command
$ ubuntu-bug $ID
The system will collect system and process data and upload it to Launchpad site.
All you need to provide is your description of a problem.
After that, just sit and wait (and provide aditional details about the bug to the developers)
DELETE
$table1
FROM
$table1
LEFT JOIN
$table2
ON
$table1.fieldId = $table2.fieldId
WHERE
$table2.fieldId == NULL
;