find ./ -type f -name "*.jar" -print -exec jar tvf {} \; | less
Sunday, July 27, 2008
Find a class in a lot of JAR files
Where did that class come from? Which JAR do I need to import to resolve this compilation error? Arrgh.
Thursday, July 10, 2008
Example Java code for posting to blogger.com using labels/tags
So I really can't believe how long it took to get this right, but here is some example code for posting to blogger.com with the ability to add some tags or categories or labels.
You just try searching for some code example on how to "post to a blog using tags". Jeez, it took about 45 minutes of searching to find an actual post that WASN'T a blog post that had a tag.
You just try searching for some code example on how to "post to a blog using tags". Jeez, it took about 45 minutes of searching to find an actual post that WASN'T a blog post that had a tag.
public class GoogleBlogPostTest extends TestCase { public void testBlogPost() throws Exception { GoogleService myService = new GoogleService("blogger", "company-xampleApp-1"); myService.setUserCredentials("googleusername", "googlepassword"); String title = "This is my title " + (new Date()).toString(); String blogID = "blognumber"; String contentStr = "This is a test of the emergency blogging system"; String authorName = "Test Author"; String userName = "author@email.com"; String summary = "This is the summary"; ArrayListtags = new ArrayList (); tags.add("News"); tags.add("Alerts"); Entry myEntry = new Entry(); for(String tag : tags) { Category category = new Category(); category.setScheme("http://www.blogger.com/atom/ns#"); category.setTerm(tag); myEntry.getCategories().add(category); } Content content = new TextContent(new PlainTextConstruct(contentStr)); myEntry.setTitle(new PlainTextConstruct(title)); myEntry.setContent(content); Person author = new Person(authorName, "http://flatebo.org", userName); myEntry.getAuthors().add(author); myEntry.setSummary(new PlainTextConstruct(summary)); URL postUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default"); Entry newEntry = myService.insert(postUrl, myEntry); assertEquals(title, newEntry.getTitle().getPlainText()); } }
Labels:
blogger,
blogger.com,
categories,
frustrating,
gdata,
google,
google API,
java,
labels,
tags
Tuesday, June 3, 2008
Using microsoft VPN on ubuntu hardy in KDE
In the newest ubuntu, there is a package for kde to use network-manager in the tray to connect to microsoft VPN (PPTP).
Then just use the network manager app in the tray to define your VPN connections. When you are ready to connect, just right click and connect.
sudo apt-get install network-manager-pptp network-manager-vpnc \
network-manager-openvpn network-manager-kde
Then just use the network manager app in the tray to define your VPN connections. When you are ready to connect, just right click and connect.
How to reset IIS
c:\> iisreset
This also resets the exchange services on a Small Business Server install.
Monday, June 2, 2008
How to unzip 'encrypted' zip files in linux
sudo apt-get install p7zip-full p7zip p7zip-rar
bash$ 7z e filename.zip
(it will prompt you for the password)
Friday, May 30, 2008
Managing IMAP accounts on Sprint blackberry devices
I forgot how to add an IMAP email account to my Sprint Blackberry 8830. I found the direct line to Sprint's blackberry support:
1-877-654-9111
He was able to tell me my username and reset my password. What I really needed was this web address:
http://sprint.blackberry.com
which is where you manage your email accounts.
1-877-654-9111
He was able to tell me my username and reset my password. What I really needed was this web address:
http://sprint.blackberry.com
which is where you manage your email accounts.
Actually getting lpr to work with cups
Yes, it should 'just work', but it doesn't. After installing cupsys-bsd to provide lpr, you also have to set the printer's name in your environment.
After setting up the printer in cups, list out the printer's names like this:
Then pick the one you want and set the environment variable PRINTER:
Now you can use lpq:
As a follow up, you can also use the '-P' switch like this:
After setting up the printer in cups, list out the printer's names like this:
bash$ lpadmin -p
printer PDF is idle. enabled since Fri 25 Apr 2008 02:37:51 PM CDT
printer Savin is idle. enabled since Tue 20 Nov 2007 06:03:36 PM CST
Then pick the one you want and set the environment variable PRINTER:
export PRINTER=Savin
Now you can use lpq:
bash$ lpq
Savin is ready
no entries
As a follow up, you can also use the '-P' switch like this:
lpq -P Savin
Savin is ready
no entries
Thursday, May 29, 2008
Oracle open transactions
Here is another neat Oracle query you can run that will give you any open transactions:
With this query, you can track down any open transactions to their Oracle subprocess PID on the operating system. Any transaction that has been running for longer than five minutes will show up with this query.
Now if you wanted to create an alert (I love alerts) that will tell you when you have an open transaction for more than five minutes:
Thanks to Ted for this query.
SELECT
s.osuser, vp.spid as os_pid, S.BLOCKING_SESSION blocker,
S.SID, S.SERIAL#, S.USERNAME, S.MACHINE,
Q.SQL_FULLTEXT cur_sql, PQ.SQL_FULLTEXT prev_sql,
vt.used_urec, vt.start_date
FROM
v$session S
LEFT JOIN v$sqlarea Q on S.SQL_ID = Q.SQL_ID
LEFT JOIN v$sqlarea PQ on S.PREV_SQL_ID = PQ.SQL_ID
LEFT JOIN v$process vp on s.paddr = vp.addr
LEFT JOIN v$transaction vt on s.saddr = vt.ses_addr
WHERE
vt.start_date < SYSDATE - (5/1440)
-- AND
-- s.machine = 'machine.name'
ORDER BY
S.SID
;
With this query, you can track down any open transactions to their Oracle subprocess PID on the operating system. Any transaction that has been running for longer than five minutes will show up with this query.
Now if you wanted to create an alert (I love alerts) that will tell you when you have an open transaction for more than five minutes:
select
LTRIM(COUNT(1))
from
v$transaction
where
start_date < SYSDATE - (5/1440)
;
Thanks to Ted for this query.
Oracle longops
Oracle has so many amazing features, and one of them I learned about yesterday was longops. It keeps track of all long operations within a database. You can view them like this (with the associated SQL):
Now if you want to create an alert to let you know when there are current long operations in your system you can do something like this:
This will tell you if you have any current long operations that have been going for longer than 30 seconds, and have more than 30 seconds left to go.
You will likely want to use the vl.username where statement to filter out system events.
Thanks to Russ for this query.
select
vl.*, vsql.sql_fulltext
from
v$session_longops vl,
v$sqlarea vsql
where
vl.sql_id = vsql.sql_id
AND
vl.sql_id = vsql.sql_id
ORDER BY
vl.elapsed_seconds desc
;
Now if you want to create an alert to let you know when there are current long operations in your system you can do something like this:
select
vl.*, vsql.sql_fulltext
from
v$session_longops vl,
v$sqlarea vsql
where
vl.sql_id = vsql.sql_id
AND
vl.username = 'SOMEUSER'
AND
vl.time_remaining > 30
AND
vl.elapsed_seconds > 30
;
This will tell you if you have any current long operations that have been going for longer than 30 seconds, and have more than 30 seconds left to go.
You will likely want to use the vl.username where statement to filter out system events.
Thanks to Russ for this query.
dia cannot export to PDF
The great dia program for linux cannot export to linux. Also, if you have not setup lpr properly to work with cups, you cannot print from dia.
Dammit. So now I have to export to a png file (which is at the wrong dpi, so the picture is very small). The drawing I did to scale when printed out is nowhere near the correct size.
Lesson learned?
Use a program that can export to PDF. EPS is fine, but people expect PDF.
Dammit. So now I have to export to a png file (which is at the wrong dpi, so the picture is very small). The drawing I did to scale when printed out is nowhere near the correct size.
Lesson learned?
Use a program that can export to PDF. EPS is fine, but people expect PDF.
Subscribe to:
Posts (Atom)