Montag, 15. Oktober 2012

Solr Commands

This is just a notepad for Solr curl commands. Solr is a search engine. Wiki can be found here.

Add a binary document
curl "http://localhost:8983/solr/update/extract?literal.id=doc1&commit=true" -F "mydocument=@your_document.pdf"

Add a CSV file
curl 
"http://localhost:8983/solr/update/csv?stream.file=exampledocs/document.csv&separator=;&commit=true&optimze=true&stream.contentType=text/plain;charset=utf-8"
Keep in mind, that you need to specify fields in you CSV file in schema.xml.
Delete entire index
# query to delete index
curl http://localhost:8983/solr/update --data '*:*' -H 'Content-type:text/xml; charset=utf-8'
# commit changes
curl http://localhost:8983/solr/update --data '' -H 'Content-type:text/xml; charset=utf-8'

Sonntag, 7. Oktober 2012

How to list old files on Windows

Today just a quick one. Following command outputs all files that are older than 57 days. Quite handy for many stuff :)

forfiles /p k:\ /d -57 /c "cmd /c echo @FILE:@FDATE"

Sonntag, 18. März 2012

Monty Pyhton's Meaning of Life

Here is something to refelct on a rainy sunday afternoon :)

There's everything in this movie, everything that fits.
From the Meaning of Life in the universe, To girls with great big tits.

We've got movie stars and foreign cars, Explosions and the lot
Filmed as only we know how, On the budget that we've got.

We spent a fortune on locations And quite a bit on drink
And there's ever the odd philosophical joke, Just to make you buggers think.

Yet some parts are as serious And as deep as you could wish
But largely it's all tits and ass And quite a bit of fish.

Other bits are fairly childish And some are frankly rude
But at least we've got a lot of nice girls All banging around in the nude.

So take your seats, enjoy yourselves And let's just hope it's funny
Because it's not only done to make you laugh But to make us lots of money.

So sit back and have a good time With your boyfriend or your wife
Relax and just enjoy yourself For this is the Meaning of Life

Sonntag, 18. Dezember 2011

Autowire Jira

When developing plugins for Jira (4.x) you may encountered auto wiring problems in modules with non trivial constructors. For example if you want to enhance time sheet plugin (link) with some custom functions and you want to inject UserManager from shared access layer (link). So you need to let Jira inject UserManager. It will not work via setters/getters if you have a complex constructor (i.e. one with parameters).
So you need to add to injected interface to your constructor - but you have to take care that this doesn't break anything else in your plugin. So overloading existing constructor is the only way to bypass this problem.
As Jira is based on Spring, if someone knows how to solve this problem more elegantly please let me know!

Mittwoch, 30. November 2011

Install Vmware Tools

Installing VMware Tools on CentOS

I don't remember ho often I installed CentOS on VMware and yet I always need to google how this tool installation works. So first of all you need to mount cdrom with vmware tools (image is inserted by player automatically). This can be done by:
mount /dev/cdrom /media/cdrom
Make sure cdrom folder exists. You can chose of course any existing folder. After that just copy VMware package to e.g. /tmp and extract it with:
tar -xzvf WMwareTools-...tar.gz
After that you can enter newly created folder with extracted tools and run vmware-install.pl

Mittwoch, 9. November 2011

Cygwin and telnet

If you are looking for small network tools like telnet, you may found it difficult to find via package search in cygwin's setup tool. That's because it is part of package inetutils. Thought that might save some folks out there google time :)

Mittwoch, 3. August 2011

Starbuck's Unix Tricks

This is just a collection of small tricks I found useful when working on a Unix shell

Rename multiple files
Following bash snippet solves a very common task. You have a list of files or folders and want to add a prefix or suffix. Please note that this little for loop do not differentiate folders and files. Found it nevertheless quite useful:

for f in `ls`;do mv "$f" "$(echo $f"_mysuffix")"; done

Recursive grep on Solaris
On Solaris you usually don't have a recursive grep so you need to work with find and grep.
find . -name *.conf | xargs grep -i 'PATTERN'

Creating folder structures
Following snippet shows how to create based on a list of base folder how to create a common deep folder structure. Things to notice here is -p switch for mkdir and how to iterate over comma separated lists.
#!/bin/bash

IFS=","
FOLDERS="a,b,c"
#cd /yourbasefolder
for i in $FOLDERS
do
   mkdir -p $i/your/folder/structure
done


Count frequencies
Below snippets extracts from an access logfile (apache, application server, etc) column with requester's IP address and compute frequencies. It is piping logfile content to awk to extract on column (separator configured with FS). Next pipe sorts IP addresses, couting step is then done with uniq another nice UNIX tool. Last not least couting is sorted to have a nice chartlist.

cat logs/access.log | awk '{FS = "\t"}; {print $5}' | sort | uniq -c | sort

Freitag, 3. Juni 2011

SQL Server Tools

This post contains some Powershell scripts to quick check some things on a running SQL Server instance. Imagine you got a SQL server delivered by a data centre team and now you are responsible for installing a software that shall use this server.
Before looking in all the various bugs in your delivered software, it is a good idea to check if SQL server was installed and prepared properly. Usually you have some credentials and a server address. So a little tool that checks if instance can be reached with this data would be nice.
Script you can find at [1] does exactly that. Just replace vars with your server's data (hostname, port, credentials). It also retrieves exact version with which you can check if correct patch level was installed (see Microsoft's info at [3]).
Another fancy thing would be to check which databases or roles are available with your user. This can be done using a nice object called Microsoft.SqlServer.Management.SMO.Server . Just google for this object to learn more. A script that retrieves databases, roles and some other interesting infos can be found at [4]. A much more extense example can be found at [5])


References
[1] UserConnectionTest.ps1
https://connectionteste.svn.sourceforge.net/svnroot/connectionteste/SQLTools/UserConnectionTest.ps1
[2] SQL Server Connection String Parameter
http://www.connectionstrings.com/Articles/Show/all-sql-server-connection-string-keywords
[3] SQL Version
http://support.microsoft.com/kb/321185
[4] GetSQLUserRoles.ps1
https://connectionteste.svn.sourceforge.net/svnroot/connectionteste/SQLTools/GetSQLUserRoles.ps1
[5] Lots of SQL Server instance details
http://mspowershell.blogspot.com/2009/12/most-dbas-have-had-to-examine-unknown.html