If you are scheduling jobs in Sidekiq (for example: using perform_at
), the jobs are not added to Queue. Sidekiq::Queue only stores the jobs that are picked by Sidekiq for execution.
If you are scheduling jobs in Sidekiq (for example: using perform_at
), the jobs are not added to Queue. Sidekiq::Queue only stores the jobs that are picked by Sidekiq for execution.
Whenever I pick a manual for a new language I often skip the first few chapters that introduce operators, conditional, etc. This is because for the most part these constructs behave the same way for most of the languages that implement them.
More …Some time ago StackOverflow released the results of the 2021 Developer Survey. One of the things that I was interested in was how the Ruby community is doing (at least the one on StackOverflow).
More …When building applications that present information to the user — either via CLI or GUI — we have to write code that formats information so that it is easy to read. Presenter pattern is a simple pattern that separates the “presentation” and business concerns.
More …Just because you can does not mean you should. But, it is still fun!
More …Memoization is an idiom in Ruby that allows developers to avoid performing expensive computations again
and again. For example, suppose you have a method price
on an Item
class that will be called multiple times, but you do
not expect the price to change everytime that you call that method during a session or a request, you can memoize the price.
You are likely already familiar with using the next
and break
keywords in Ruby. You might have already used them in your programs for control flow in loops. Here is a quick refresher
If you are like me, working on multiple Ruby projects with different versions of the same gems installed, you must be familiar with bundle exec
for picking the correct gem version.
There are two ways of making an HTML element transparent: opacity and background color.
More …Rails applications that expect heavy traffic require a scalable database such as Postgres or MySql. However, SQLite might be sufficient for low-traffic applications or apps in the initial development phase, where you do not want to spend the resources and time required to set up and configure a database such as Postgres or MySQL.
More …My Lenovo laptop broke a few months back. I sent it for repairs and needed something cheap and lightweight in the meantime. I always wanted to use a Chromebook for fun but never considered it suitable for my needs as I develop primarily in Java. However, this time I was working on some projects where I was doing front-end web development and visualizations and a Chromebook would would have worked for me. I could still ssh into my Linux box to do some Java development (although I won’t recommend it). I finally bought a Acer Chromebook 13 (CB5-311) and I have been using it regularly for over a month now. I have some good and bad things to say about Chromebooks and a little something about the whole idea of “moving to cloud”.
More …While doing text analytics on a large document collection, the analyst is often looking for relationships between entities like person, organization, location etc. The existing approaches to finding related entities automatically are quite primitive. They are generally some variant of finding relationship by co-citation of entities and bibliographic coupling of documents. According to this scheme, two entities are considered “related” if they are mentioned in the same document. Conversely, two documents are considered related, if they have common entities mentioned in them. A major problem with this scheme of “relatedness” is that the nature of relationship (semantics) between two entities is unknown until the documents mentioning the entities together are not read by the analyst.
More …Eclipse RCP is a great platform for developing nice GUI applications with Java. It provides a wonderful framework to build application with its very useful publish-subscribe event model and annotation based dependency injection. It feels almost like magic when you switch from developing hard-coded Swing applications to Eclipse.
More …Lately, there has been quite a discussion online about changing ways to teach computer programming. Programming is being realized as a very useful tool for practitioners in almost every domain. Yet, the way it is being taught continues become more and more convoluted. As a result, more and more students are frightened of the word “ programming”. We have finally managed to make a beast out of something that is amazingly simple in reality. We have also managed to kill the fun and joy that programming has to offer.
More …Blender is a great free and open-source tool for creating 3D computer graphics. In my knowledge it is the only open-source tool that gives a real competition to its commercial counterparts. I have come across it several times and always wanted to learn it. But, I kept procrastinating. Finally, I got some free time last week and got hands on a very nice video tutorial on YouTube. The tutorial is easy to follow and I was able to learn the Blender interface and was able to replicate the tutorials to produce some really nice graphics that I am really proud of. Here are couple of images that I have created so far.
More …A good programming practice is to make a variable final whenever possible. However, following this principle can sometimes be tricky. One such case is when the variable/field is initialized with return of a function that throws exception. Let me explain using an example. Suppose, you have classes Foo and Bar as follows:
More …In the previous post I briefly wrote about Java annotations and some of their uses. There is plenty of documentation about syntax and features online and hence I don’t want to write about it again.
More …Java 5.0 introduced annotations among many things. Annotations are a way of adding metadata to Java elements such as classes, methods, variables, parameters and packages. An annotation in its simplest form looks something like this:
More …Visualization systems generally consist of several independent visualizations, each allowing exploration of a different aspect of data. Over years, researchers have developed several interaction techniques to allow users to explore data. Two of these several techniques are Brushing and Linking.
More …Until Java 7, developers were not able to use String in switch-case construct. The only option was to write a huge if-else block like this
More …Loom is a game engine that provides live update functionality which makes testing code very easy. It is slowly gaining popularity at least among the newbie game developers and students (ones like me) as it is free and provides normal developers to take a shot a game development. without too much investment.
More …If you are using any Debian-based OS like Ubuntu for some time, it is possible that you might have tried to compile some library or software and encountered the same old error like this
More …Long I have not known about an interesting environment for working on graphics and animation. It is called Processing. I have long been using Java for all my desktop application needs (with occasional also some animation/custom component coding in Swing). So, I know the pains of developing even a simple visualization, animation or even a worthy UI using Java/Swing.
Recently I started working for a visualization group as an RA/Lead Developer. At work, it is often a requirement to prototype some visualization real fast and hence I was introduced to Processing. And to put it in words, it was like “I was given a power that I could not wield”, and this was not because Processing was ugly or complicated. Rather, it is because it is very different from what I have been doing so far with Swing. In this post, I will try to discuss my first reactions to Processing, which do not include any code samples (that is for later).
More …While coding Java for one of my projects, I came across a weird requirement. I had a super class that had a static method and I wanted to know the name of the sub classes of my super class that called the method. Let me explain that by example.
I have a class Super
that contains a static method superStaticMethod()
that prints the name of the class.
package example;
/** Super.java **/
public class Super {
/** prints the name of the calling class **/
public static void aStaticMethod() {
System.err.println("Super static method called from " + getClassName());
}
private static String getClassName() {
return Super.class.getName();
}
}
Now I have another class `Sub` that extends the `Super` class.
package example;
/** Sub.java **/
public class Sub extends Super {
// nothing here.
}
Now, whether I call Super.aStaticMethod()
or Sub.aStaticMethod()
, I will get the same output :
This is precisely because Super
class has no idea of which class actually called the method. Had this been a simple instance method, it was simple. I can just use this.class.getName()
. But achieving the same effect is tricky because there is no instance involved when calling the static method and calling Sub.aStaticMethod()
is same as calling Super.aStaticMethod()
.
However, after battling with reflection, I found some way which I would like to share. Here is how its done. The trick is that you hide inside the Super
class a spy that can tell you who called the method. This spy will actually be a nested static class that will reveal the details of the calling class.
What you need to do is modify the Super
class to this:
package example2;
public class Super {
public static void aStaticMethod() {
System.err.println("Super static method called from "
+ new Spy().revealTheCallingClass());
}
/** This class helps get the class name */
static class Spy extends SecurityManager {
public String revealTheCallingClass() {
Class[] classes = getClassContext();
for (Class cls : classes) {
// check if the class is a sub class and its the Super class
// itself.
if (Super.class.isAssignableFrom(cls) && cls != Super.class) {
return cls.getName();
}
}
return null;
}
}
}
Now if you modify the class for Sub to
package example2;
public class Sub extends Super{
public static void useSuperClassName(){
aStaticMethod();
}
}
Calling Sub.useSuperClassName()
will print example2.Sub. Note however that calling Sub.aStaticMethod() will still print null or the name of the class in which it is called (if that class is a subclass of Super) which is something that I will try to rectify in future, if possible.
There are times when I love to use command-line/terminal (whatever you want to call it). And when I do I like to do something fun with it, and not just putting text to read. This post contains two examples of some fun code that you might wanna use to make something nice of your command-line application.
More …If you happen to be a guy who has spent some time in online forums for software developers, you might be aware of the flame wars that go on between different software such as vim and emacs or netbeans and eclipse, or between different operating systems. I happen to be the guy who just hates these kind of discussions. The problem with these flame wars is that they start as simple comparisons or discussions and evolve into pure blasphemy.
More …