Skip to main content

Generating partner.jar for Salesforce API Integration

I ran into a small issue recently when setting up a Java project to use the Salesforce APIs.

Basically, you need to download a WSDL file from Salesforce, then use a tool made by them to generate a jar that you then include in your Java program.

They instruct you to download force-wsc.jar and then run it, but when you run it you realize they didn't pack the dependencies within the jar!

To solve this problem, you need to download the following jars:

And then run force-wsc.jar, including the dependencies in the classpath:

$ java -classpath force-wsc-32.1.1.jar:js-1.7R2.jar:ST-4.0.7.jar \
  com.sforce.ws.tools.wsdlc partner.wsdl partner-32.1.1.jar

Please note these were the versions that worked for me. If your force-wsc.jar is a different version, check if you need to include other version of its dependencies.

How to use the Youtube JS API to play music in the background

The Youtube JavaScript API allows you to embed YouTube videos and interact with them programatically. To use it, first you need to embed this script into your page:

<script src="http://www.youtube.com/player_api"></script>.

If you just want the audio, you can hide the element that contains the video:

<div id="player" style="position: absolute; top: -9999px; left: -9999px;"></div>

Here we use absolute positioning with negative coordinates because using display: none; will prevent the onReady handler from the Youtube player from triggering on Firefox. I ran across this problem when making this.

Finally, here's a full example that will wait for the video to load and automatically play it:

Learning a Programming Language

I've heard that if you're a good programmer, you should be able to pick up a new language in a few days. And I've done this myself, I learned the basics of Go a few months ago. Built some command line programs and a web app with it, all in a few days.

Yet, what does it take to really learn a new language? To master it? Sure, there are some concepts that translate well from language to language, but some languages have their own thing going on. It usually takes a little longer to even learn the basics of those languages.

To go beyond the basic concepts, you have to invest a lot of time into the language. You have to learn how to program idiomatically in it. I wouldn't go as far as saying that you have to spend 10,000 hours practicing a language, but I do think you have to spend at least a thousand hours to know it really well.

On top of that, most languages have a whole ecosystem of associated tools that you have to leverage in order to be productive. For example, JavaScript has Grunt (Gulp seems to follow), Bower, and NPM (and Yeoman most recently). You can't really say you have mastered JavaScript if you don't know how to use these tools.

So after learning the language and learning all these tools, you must be a master in this language, right? Well, you're wrong. You see, most languages (even the unpopular ones) have something else associated with it: a community. Sometimes the community is really visible (for example, the Python community).

If you want to truly master a language, you should be part of its community. The community influences the language in many ways. Usually, the community influences the tools, new language features, libraries, frameworks, and so on. So if you have invested yourself into a language, you should also become part of the community.

Now you have accomplished all of the above: you have spent quite a few hours programming in the language, you have a broad knowledge of all its tools, and you're part of the community. Is that enough? No! You have to keep up to date, learning (or proposing) new features, tools, learning new libraries and frameworks. You could even build some of those yourself!

Finally, note that you don't have to do all this. If you really like a language, go ahead. I believe it is worth the effort. Yet, I don't consider myself a master of any language. There's just way too much to learn and to do. I prefer having enough knowledge in a few languages and getting things done in them, than to be a PHP Guru or JavaScript Wizard. I advise you do the same.

Go Learn

Today I decided to try out Go.

What is Go?

Go is a programming language designed and developed at Google. It was designed by really smart people: Robert Griesemer, Rob Pike, and Ken Thompson.

Syntax-wise, it looks a lot like C, except the ending semicolons are optional, and parentheses for if, for, etc are not required.

Here's a gist showing some syntax: It's a fibonacci calculator made using a closure, caching previously calculated numbers.

Features

  • Statically typed (but types can be inferred).
  • Concurrency baked in (goroutines, channels).
  • Garbage collection.
  • Fast compile times.
  • No classes (you attach functions to structs instead).
  • No inheritance (Go makes heavy use of interfaces).
  • No overloading.
  • No pointer arithmetic.

Coding in Go

To learn Go, I first did a quick read of Learn X in Y Minutes to get a grip of the syntax.

Then, I went over to their official website and took the tour.

Afterwards, I wanted to get a working application. Go includes an http server in their official packages, so I decided to make a web application.

After a little searching, I found they had a tutorial aimed at web applications, so I decided to use exactly that. Go documentation rocks!

I followed the tutorial along and was able to get a wiki type of website up and running in about 20 minutes. After that, I decided I wanted to add markdown support to it, and a few more features, like creating new pages and deleting pages.

One thing I really liked about Go is that it comes with a lot of useful packages so you can start working right away. For example, I thought I would have to write some sort of templating system, but Go already comes with one. And it's context aware! So you don't have to worry about escaping things!

Packages

Go's packaging system allows you to get packages from VCS repositories. For example, to add markdown support to my wiki, I added knieriem's markdown package as a git submodule in my project.

A screenshot of my development process. Click to see the gallery.

As usual, my project is on Github.

Trying out Ruby on Rails

I've heard a lot of stuff about RoR for a while, so I decided to finally try it out and see what all the fuss is about.

What is Ruby on Rails? A web framework that runs on the Ruby programming language.

First impressions: too much magic going on. It seems like a good thing for quick development, but I prefer knowing exactly what is going on in case anything goes wrong so the problem can be fixed easily. For this reason, I probably will not use RoR on any on my projects until I understand more about it.

Things I liked about RoR: the ActiveRecord ORM, and the built-in REST support. I also liked that it is very easy to deploy once you know what you're doing.

Thinks I dislike so far: using SCSS and Coffeescript by default. These could add to the cognitive load of beginner, and they have to wrap their head around how RoR first has to process these files into what the browser can understand (CSS y JavaScript, respectively).

I've never been a big fan of Coffeescript. I think it's annoying to debug and I would rather write plain JavaScript, but that's just my opinion. However, I do think it has a nice syntax.

I had heard of SCSS, but I had never used it. It's very enjoyable to use, since you can nest CSS definitions, and it has some neat features that make it a lot easier to maintain stylesheets, such as variables and functions.

When learning a new framework, I try to follow the official tutorial, but tweaking the steps a bit in order to create a different application.

To learn RoR, I decided to make a small contacts application, where you can add contacts to a list and edit/delete them. It's on a repo at Github, in case you wanna take a look.

A screenshot of my development process. Click to see the gallery.

Now I'm also learning Django (a python web framework), and everything seems a lot less magical, so I will probably use it instead of RoR. Both of them seem to solve the same problem (CRUD apps).