Monday, November 19, 2012

Delete Documents From Solr Index By Query

If you simply want to delete documents from your Solr index by using the web interface, here's a code snippet that lets you do so:

http://localhost:8080/solr/update?stream.body=<delete><query>id:XXXXX</query></delete>&commit=true

This lets you delete documents where the id field matches XXXXX.
If you want to delete items that matches more than one field, just add another query:

http://localhost:8983/solr/update?stream.body=<delete><query>id:XXXXX</query><query>entitytype:YourContent</query></delete>&commit=true

If you want to delete all items in the index, just use this query:

<delete><query>*:*</query></delete>

Source: http://blog.dileno.com/archive/201106/delete-documents-from-solr-index-by-query/

Tuesday, November 13, 2012

Old Version MediaWiki & PHP 5.3

when you use old version of MediaWiki and PHP 5.3, you should see this error:


PHP Parse error:  syntax error, unexpected T_NAMESPACE, expecting T_STRING 


You must change only the Namspace calss with MWNamespace:

go to your MediaWiki root directory (please make a backup first) and run this command:

find -name "*.php" -exec sed -i 's/Namespace::/MWNamespace::/g' {} \;

Wednesday, October 31, 2012

Youtube Video's thumbnail in not showing when sharing to FaceBook

After posting the thumbnail-less link to my page for the hundredth time, I decided to try sharing the link via the Facebook App on my Mobile Phone. When I did, I noticed a that the app added a suffix to my original link "&sns=fb".

I tried it and it worked...first try. I'm hoping it works when I try to post our next weekly video.

Try the following steps. I hope they work for you, too!

1) On the YouTube video page, click "Share" - be sure to select "Long Link".

2) Copy the link and paste it into your Notepad program.

http://www.youtube.com/watch?v=ABCdefGHik

3) Add "&sns=fb" to the end of the link.

http://www.youtube.com/watch?ABCdefGHik&sns=fb 

4) Copy your new link and paste it into your Facebook status.

5) Cross your fingers.



Another  solution:

Go here and enter the URL https://developers.facebook.com/tools/debug
It will force it to refresh the cache for the given URL.

Tuesday, October 30, 2012

How to select and generate locales on Ubuntu

For those of you who are used to running "dpkg-reconfigure locales" on Debian to select and generate locales you may be a bit disappointed at the seemingly broken way it is done under Ubuntu.

When I say broken "dpkg-reconfigure locales" does not yield an interface that allows you to select and deselect locales. It simply generates the locales mentioned in "/var/lib/locales/supported.d/local" file.

Therefore if you want to generate a bunch of locales you will need to add them to this file and re-run:

dpkg-reconfigure locales

NOTE: One locale per line.


For a list of valid locales you can search through "/usr/share/i18n/SUPPORTED".

Source: Here

Monday, October 29, 2012

TYPO3 - Lock file could not be created

Create the directory ./typo3temp/locks/ and make it writable for the user your Apache is running with.

Wednesday, October 24, 2012

Setup curl to permanently use a proxy

Curl will look for a .curlrc file in your home folder when it starts.


You can create (or edit) this file and add this line:

proxy = yourproxy.com:8080

Setting HTTP Proxy for SVN

Edit the servers file

/etc/.subversion/servers

and set the proxy server and port.

Uncomment and change the lines necessary:

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
http-proxy-host = yourproxy.server.com
http-proxy-port = 8080

# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
# http-compression = no
# http-auth-types = basic;digest;negotiate
# No http-timeout, so just use the builtin default.
# No neon-debug-mask, so neon debugging is disabled.
# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem


If you get some error like this:

svn: /etc/.subversion/servers: 148: Option expected

then it means that you have a space at the start of the property which you have un-commented. Make sure that there is no space in the beginning of the property in the servers file.

Tuesday, September 11, 2012

Update mysql table records, which contain umlaut

Use your database and run this MySQL command for your desired Table:

UPDATE YOUR_TABLE SET YOUR_FIELD = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(YOUR_FIELD,'ä','ae'),'Ä','Ae'),'ö','oe'),'Ö','Oe'),'ü','ue'),'Ü','Ue');

Rename files- & directories-name which contains umlaut

I would like to change the file name, which contains umlaut, with normal characters:

For example: ü with ue or Ä with Ae.

Here is my commands:

for i in `find -name '*ü*'`; do mv $i `echo $i | sed 's/ü/ue/'`; done
or
for i in `find -name '*Ä*'`; do mv $i `echo $i | sed 's/Ä/Ae/'`; done

and the following command for the directories:
for i in `find -type d -name '*Ä*'`; do mv $i `echo $i | sed 's/Ä/Ae/'`; done


Wednesday, September 5, 2012

Bash script - Delete characters before or after a pettern from string

I have this string:

MyString="This is a Test. Isn't it? Yes, it is."

I want to delete all characters after "?":

echo $MyString | sed -e 's/?.*//g'

the result is: This is a Test. Isn't it

now I want to delete all characters before "a":

echo $MyString | sed -e 's/.*a//g'

Resut: Test. Isn't it? Yes, it is.




Bash script - Removing duplicated lines from file

Run this command:

awk '!x[$0]++' source.txt > target.txt

Wednesday, August 22, 2012

Using PHP/oci8 to Connect to Oracle Remote DB

With this short PHP script, you can see how I connect to a remote Oracle DB:



<?php

//Connect String
$db="(DESCRIPTION=

     (ADDRESS_LIST=

       (ADDRESS=(PROTOCOL=TCP)

         (HOST=REMOTE_DB_IP)(PORT=XXXX)

       )

     )

       (CONNECT_DATA=(SID=ORACLE_SID))

 )";

//Connect to DB
$conn = oci_connect('USERNAME','PASSWORD',$db); 


//Run a sample query
$s = oci_parse($conn, 'select * from DB_TABLE');

oci_execute($s);

oci_fetch_all($s, $res);

echo "<pre>\n";

var_dump($res);

echo "</pre>\n";


//Close DB Connection
oci_close($conn);


?>


Installing OCI8 On Debian

OCI8 is an extension for providing APIs to Oracle database management system. You need Apache, PHP and Oracle Instant Client.

Register and Download Oracle Instant Client. Choose your platform compatibility (in my case x64), if the package not compatible with your platform then installation process will failed. At least, we just need Basic and SDK. Then put on /opt/oracle or whatever directory did you liked:

mkdir /oracle_client
mkdir /opt/oracle
cd /opt/oracle


 unzip instantclient-basic-linux.x64-11.2.0.3.0.zip
 unzip instantclient-sdk-linux.x64-11.2.0.3.0.zip
 mv /opt/instantclient_11_2/* /oracle_client/

 Create symbolic links for dinamic library and Add instant client to system ld:

cd /oracle_client
ln -s libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so

Compiling OCI8 and enter instantclient,/oracle_client when you are prompted:

pecl install oci8

Enable oci8 extension on php.ini or add it to php Conf:

vim /etc/php5/conf.d/oci8.ini 

and add this line to file:

extension=oci8.so

then restart apache2 web server.

/etc/init.d/apache2 restart

Then check phpinfo() and the successfull installation should be :



When you get this error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/oci8.so' - libaio.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

you should install libaio:

apt-get install libaio1