How to: Juniper Networks VPN on 64-bit Ubuntu

After spending many hours doing the necessary research and hacking, I was finally able to get the Juniper Networks VPN to work on my fresh 64 bit Ubuntu VM.

  1. Go to System -> Software Sources -> Other Software and enable the parter sources.  E.g. for Lucid 10.04:
    • http://archive.canonical.com/ubuntu lucid partner
    • http://archive.canonical.com/ubuntu lucid partner (Source Code)
  2. Execute sudo aptitude install sun-java6-plugin sun-java6-jdk sun-java6-jre ia32-sun- java6-bin icedtea6-plugin
  3. Execute sudo update-alternatives –config java and select /usr/lib/jvm/ia32-java-6-sun/jre/bin/java
  4. Open the client’s Juniper Networks VPN site
  5. Allow for “Network Connect” ncLinuxApp.jar to be downloaded, installed, and executed (check .juniper_networks/ in your home directory)
  6. Type your password at the prompt
  7. Execute wget http://mad-scientist.net/junipernc; chmod 755 junipernc; sudo cp junipernc /usr/bin/
  8. Run junipernc, and input the appropriate credentials

For additional information or for the source of the junipernc script, visit a more detailed explanation at the Mad Scientist.

Posted in Uncategorized | Leave a comment

Weather Forecasters

As a rule of thumb, I generally don’t take on professions where I don’t understand their craft. That said, I’m making an exception for the scientists we call weathermen. Have a look at my example below:

Let me state some certainties science knows:

  1. temperature is the measure of energy, this is a fundamental to a field called thermodynamics.
  2. energy can take many forms, such as heat, or radio waves, and can be converted between mediums by a process called work.
  3. because work is a function, energy transfer too is a function. (yes, we have approximate instantaneous spikes — delta functions — but they’re just approximations). remember pre-algebra? a function can’t have two points on the same line… that’s why a circle isn’t a function… anyone?

Now that we’ve established the fundamentals (that even a seventh grader knows), let’s discuss the forecast above. At 11:59, the temperature was the same as it was at the time of this screenshot, -5ºF. How then, do they error and presume the temperature will rebound 7ºF to a sweltering +2ºF instantaneously at the stroke of midnight? Do weathermen fail to observe what a 5 year old knows to be true? Do weathermen not realize that the current temperature – by definition – cannot be lower than the day’s low?

Look weathermen, we don’t really care what your prediction is when we have actual results to see. We insist that your daily predictions be reasonable, that they take into account current conditions. Look, it’s not like you’ll get accused of doctoring your weather report if you update your locality in real time. If you must publicly maintain your guess throughout the day, how about doing it as such:

We can still see how wrong you are, if that’s what you care about, but we can also see what the high and low has been. This is called transparency and accountability. Welcome to 2011.

p.s. yes, we know you reuse access to previous days weather. can you please give us that, too?

Posted in Uncategorized | Leave a comment

pthread kill and cancel

Today, I was wandering through the land of operating systems. Specifically, I was reviewing the intricacies of threading. I came across something I didn’t really remember from college (it was probably briefly mentioned or brushed under the carpet (as it’s a bit more of an advanced topic).

I came across the question on how pthread_kill() differs from pthread_cancel(). here and here

For background purposes let’s consider pthread_cancel(). If you want to kill a POSIX thread, you really have two choices, asynchronously (consider this a “forced” kill – abruptly stopping the thread at any hardware instruction) or deferred (flagged for cancellation at cancellation point). Assuming the pthread is cancelable (which by default it is, and is type: deferred) then you should use the pthread_cancel() function to halt the thread at a predetermined cancellation point (sleep, sigsuspend, close, creat, pause and more… click the link above).

If you’ve overridden the default with PTHREAD_CANCEL_ASYNCHRONOUS, you have empowered yourself with significantly more control on when the thread will die. This should only be used in instances where the thread is cancel-safe, i.e. when you’re not holding resources, and it’s fine for your thread to die at any moment. IBM has a nice writeup about this under Async-Cancel Safety, here.

To address the third topic, and draw comparisons, let’s consider pthread_kill(). This function is really quite different than the cancelation function above, as pthread_kill() can deliver a variety of signals that may not halt the thread at all. If performed correctly, you can pass an interrupt signal (SIGINT) to a thread and achieve the same outcome as a pthread_cancel(), but you can also provide any other signal notifications to the thread.

In short, if you want a specific thread to handle a specific signal, use pthread_kill() to pass the signal. Otherwise, if you want to kill a thread, you should generally use pthread_cancel().

The description of pthread_kill() in it’s man pages declares:

The pthread_kill() function sends a signal, specified by sig, to a thread, specified by thread. If sig is 0, error checking is performed, but no signal is actually sent.

Some Side-Notes on Cancellation
Cancelability may be defined on a thread using the following functions:
pthread_setcancelstate() – to enable/disable cancelability
pthread_setcanceltype()) – to set thread to asynchronous/deffered cancelability

Also, please play nicely and make sure you restore invariants and release resources upon exiting a thread (returning from the entry function, pthread_exit, or cancelation) by adding cleanup handlers to the cleanup stack.

Posted in Uncategorized | Tagged , | Leave a comment

Pyramid web framework

So a few days ago I started on Pyramid, leaving Pylons. Why? Because this is the future of the Pylons community and it’s the future of the repoze.bfg community.

Two weeks ago the heads of both states met in Las Vegas to decide the fate of their frameworks. The conclusion is both communities have merged into one to take on Rails. Pyramid provides a 100% unit tested framework, and is structured more like repoze.bfg.

For more information on the union, read the following Google groups method from pylons-devel: Pylons & repoze.bfg Merger – or – Where’d Pylons 2.0 go?

As someone who’s relatively new to Pyramid, here is my largest suggestion. Enable interactive web debugging. You get a live python terminals when an error occurs. (I’m not sure why this isn’t enabled by default.)

from weberror.evalexception import EvalException
 
def app(global_config, **settings):
    # all that fun stuff setting up the app
    # & getting the configurator setup goes here
    config.end()
    return EvalException(config.make_wsgi_app())
Posted in Uncategorized | Leave a comment

MongoDB w/ Pylons (Proper Initiation)

This is a quick how-to, but it’s probably worth something to people new to Pylons & MongoDB. There are many resources out there for using SQLAlchemy and other SQL-ORMs with Pylons, but little is said about modern day NoSQL (not only sql) solutions such as MongoDB/CouchDB/Cassandra, et al.
The model you want to follow is this:

  1. In your development, production, and test.ini files specify dbtype.db
  2. In config/environment.py, setup the engine (what speaks with the DB daemon) by calling the appropriate function.  Note, you can access set variables in the .ini files by making dictionary requests from the global variable config after the config.init_app() occurs in config/environment.py.

development.ini example:

[app:main]
use = egg:your_app_here
full_stack = true
static_files = true

# *** database ***
mongo.db = yourapp_development

cache_dir = %(here)s/data
beaker.session.key = yourapp
beaker.session.secret = somesecret

Similarly, set mongo.db in test.ini to yourapp_test, and production.ini’s mongo.db = yourapp.

environment.py example:

Now, when you run your functional tests w/ the nosetests command, your database engine will be connected and ready to run. During development, you’ll be able to demo the app, and during production, all will be cherry. Now, go out there and #doit.

Posted in Uncategorized | Tagged , , | Leave a comment