Just in case you run into OutOfMemory Exceptions while requesting a large data chunk from the MySQL: the JDBC driver will load ALL (yes, ALL) rows before passing it to your fancy, agile and low-footprint routine. Tweaking the fetchSize property of a statement won't do any good either... well, not without some voodoo. So, here is how you can get the JDBC driver to get you a nice and tight StreamingResultSet:
st.setFetchSize(Integer.MIN_VALUE); // Inter.MIN_VALUE <- and ONLY this value, 1,5 or 100 won't fix your problem.
Reflection and me? Big friends. With all the love and hate a good friendship should have. A few days ago it was all about hate again. I had a bunch of service classes, some of them would implement a generic interface... Let's call it IHasAdorable - so a Service-Implementation could look like this:
public class MarketMerchant : IHasAdorable<CheeseBurger>, IProductSeller { // defined in IHasAdorable CheeseBurger BuyAdorable() { } // defined in IProductSeller IProduct Buy(String eanCode) { if (eanCode.equals("12345")) return this.bigStackOfSmellyFishburgers.Pop(); else } }
Now lets assume we want to browse through ALL market merchants and have a look if they have any adorable products. Let's skip the iteration process and pay attention to the probing of all market merchants in order to buy a adorable product from each of them. First attempt might be to use "is":
IProductSeller merchant; // iteration goes here { // this wont work. We are selling something very special, not just a stupid object! // Casting to IHasAdorable<> won't even compile. }
// `1 means there is 1 Generic parameter Type adorableInterfaceType = merchant.GetType().GetInterface("IHasAdorable`1"); if (adorableInterfaceType != null) { // yay, the merchant has adorable products, what whould those be!? Type adorableProductType = adorableInterfaceType.GetGenericArguments()[0]; // here is the magic we need to get the correct IHasAdorable Type // with "filled in" generic type. Type genericAdorableInterfaceType = MethodInfo mi = genericAdorableInterfaceType.GetMethod("BuyAdorable"); myBagOfAdorableProducts.Add(mi.invoke(merchant,null)); }
If you run into the same issue, disable IPv6 support in Firefox:
about:config -> network.dns.disableIPv6 -> true
Apparently Firefox and Microsoft Internet Information Server do not like to play together nicely on Vista without human intervention.
There you go
#!/bin/sh ######################################################################## ## Scans all jar files within a directory (recursively) for a class ## name ## Usage: findClass /tmp/ MyFunnyClass ######################################################################## black='\E[30;47m' red='\E[31;40m\033[1m' green='\E[32;47m' yellow='\E[33;40m' blue='\E[34;40m\033[1m' magenta='\E[35;47m' cyan='\E[36;47m' white='\E[37;47m' alias Reset="tput sgr0" cecho () { local default_msg=" " message=${1:-$default_msg} # Defaults to default message. color=${2:-$black} # Defaults to black, if not specified. echo -e -n "$color" echo -n "$message" Reset # Reset to normal. return } clsln() { fillLine " "; } fillLine() { let tw=$(tput cols)-1; for (( c=0 ; c < $tw; c++)) do echo -n "$1"; done echo -e -n '\r' } echo echo -n Scanning Folder: cecho "$1" $yellow echo -n for Class: cecho "$2" $yellow echo fillLine "." echo for i in $(find $1 -name '*jar'); do clsln; echo -n -e "Scanning :"; cecho $i $blue echo -n -e '\r'; out=$(jar vft $i | egrep $2); if [ "$out" ] then clsln; fillLine "*" echo echo -n -e 'Possble hit in file:' cecho $i $blue echo echo "$out" $red echo fillLine "*" echo echo fi done; clsln; echo;
This drives me crazy! Every time I debootstrap a debian or ubuntu machine the resulting root system will lack properly set up locales. dpkg-reconfigure locales & derivates won't help since the system does not know what locales it should generate - and for some reason it does not show that nice ncurses UI where you were able to pick the locales you would like to have the support for.
So, there goes another blog entry which should act as my personal notepad for future accidents like this:
root@baracus:# cat /usr/share/i18n/SUPPORTED | egrep en_US > /var/lib/locales/supported.d/en root@baracus:# cat /usr/share/i18n/SUPPORTED | egrep de_DE > /var/lib/locales/supported.d/de root@baracus:# locale-gen Generating locales... de_DE.ISO-8859-1... up-to-date de_DE.UTF-8... up-to-date de_DE.ISO-8859-15@euro... up-to-date en_US.ISO-8859-1... done en_US.UTF-8... done Generation complete.
P.S.
You might need to reinstall the locales package afterwards:
sudo apt-get install --reinstall locales export LANG="de_DE.utf8" YAY!
_pulsar_: did I mention me being in love with soapUI - http://www.soapui.org/? #java #dotnet #webservice
Well, this is rather a note to myself:
for Javascript new Date().getTime() value (miliseconds, hence / 1000)
.AddSeconds(ajaxRequest.RequestDate / 1000)
public static IDictionary<RequestTypeEnum, RequestGroupEnum> { {RequestTypeEnum.RegisterAccount, RequestGroupEnum.Account}, {RequestTypeEnum.UnregisterAccount, RequestGroupEnum.Account}, {RequestTypeEnum.RegisterInetAccess, RequestGroupEnum.InetAccess}, {RequestTypeEnum.UnregisterInetAccess, RequestGroupEnum.InetAccess}, {RequestTypeEnum.RegisterMailbox, RequestGroupEnum.Mailbox}, {RequestTypeEnum.UnregisterMailbox, RequestGroupEnum.Mailbox}, {RequestTypeEnum.RegisterRLA, RequestGroupEnum.RLA}, {RequestTypeEnum.UnregisterRLA, RequestGroupEnum.RLA} };
Atomic RouterThis issue has been puzzling me for some time. I have this Atom based home-brew router sitting on the shelf with a 2TB drive attached to it. So yes, it does also serve as a NAS, Meda-Server etc. All the good stuff. So theoretically it should be also a good place to backup my data to – in case one of the workstation harddrives fails – been there, done that. No IBM drives for me since that incident.
So, where is the catch? Backing up private and sensitive data to that device would be almost insane, this nice piece of hardware is directly connected to the internet and thus exposed to a variety of break in attempts. What if one of these is successful? Riiiite, I would be fu***. Properly.
The solution is very obvious; encrypt your data before you move it onto the server. But how would one do that using a windows client and free software only? There are several ways to achieve that. You could choose to write a batch script, use 7zip or something to compress / password protect that data and copy it over to the other side.
Since I don’t really like batch scripting and prefer doing fancy stunts using bash, I choose cygwin, cron (running as NT service, @see /usr/share/doc/Cygwin/cron-4.1-7.README) and openssl to encrypt that data. So, here is the one-liner doing all the work:
tar cz MyImportantDataDirectory | openssl des3 -salt -pass pass:SECRET | ssh pulsar@router "cat > /mnt/backups/documents-daily.tar.gz.des3"
Go crazy now! Use the week-number to create a series of backups instead of the daily snapshot, remove old backup sets etc. Once you have that script, schedule it using the cron (crontab –e) and watch your sensitive data being backed up automagically. /me likes!
Here is a small application I wrote from pure boredom and curiosity.
It is a pathetic attempt to simulate a dream machine. It is supposed to
provoke hallucinations by stimulating the optical nerves with a specific
frequency. That simulation can alter the brainwaves and make you see
complex patterns of color behind your closed eyelids.
Did not work for me – might work for you.
I’ve read an article on this topic some time ago and got curious. I made this stupid application to give it a try.
Do you? Head over to http://en.wikipedia.org/wiki/Dreamachine