Thursday, January 31, 2013

Extracting the string between two patterns in a file

Supose the file contains this phrase: That is just a test for you

I need to extract the patterns between the words is and test:


 sed -e 's/.*is//' -e 's/test.*$//' /Path-To-Your-File/yourfile.txt

and the result is:

  just a

Tuesday, January 22, 2013

Find out MySQL Time & Zone

for global and session time zone run this query:


mysql> SELECT @@global.time_zone, @@session.time_zone;


for get current time from MySQL Server run this query:

mysql> select now() ;

Monday, December 17, 2012

Find Files By Date

If you need a specific date range, than consider using the find command.

In this example find files modified between 15 December 2012 and 16 December 2012, in /var directory:
 
touch --date "2012-12-15" /tmp/start
touch --date "2012-12-16" /tmp/end
find /var -type f -newer /tmp/start -not -newer /tmp/end

Thursday, December 13, 2012

Forcing qmail to process the queue

Run this command:

kill -ALRM `ps ax | grep qmail-send | grep -v grep | awk '{print $1}'`

Adjusting qmail queue time / lifetime

if you want to adjust how long e-mails will spend in the qmail queue before they're bounced, simple set the queuelifetime:

# echo "86400" > /var/qmail/control/queuelifetime
# /etc/init.d/qmail restart


The above example is for 1 day (qmail needs the time length in seconds). Just take the days and multiply by 86,400 seconds to get your result.

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');