Archive for category The Net

Using JSON between Javascript and Python

JavaScript can’t access local files; this makes it troublesome to work with databases and files without including someone’s “black box” and risking all manner of compatibility and security issues you have no control over.

Required Skillsets

You need to be familiar with both Javascript and Python, and their typical execution environments, for this information to be useful to you. Both are easy languages to learn, and the web is replete with tutorial sources aimed at providing that familiarity. Database use with Python can be with SqLite, or PostgreSQL, or MySql. Again, plenty of resources out there to help with learning SQL.

Python, on the other hand, has no such problems. It can handle files and databases directly, and you have every opportunity to keep things safe and secure. Python is readily available on your typical server; Javascript is built into most browsers.

So here is a skeletal example of how to get data from JavaScript to Python and back again that doesn’t require any extra JavaScript components, and therefore puts you in complete control of whatever risks you face, including resolving any bugs without having to depend on anyone else.

You can use this to build your own communications, adding all the security and reliability tweaks you desire, or none, for private, off-net use.

If, in pursuit of the kind of inter-language linking I demonstrate here, you’re thinking “Database!”, then I would also point you to my SqLite simplifier and PostgreSQL simplifier projects.
Read the rest of this entry »

Tags: , ,

Some OS X DHCP Esoterica

Because I develop Software Defined Radio (SDR) software, I have occasion to connect, and disconnect, various network devices to my wired network in order to test them all day long. Most of the SDRs are designed to configure using DHCP, or can be convinced to do so. That saves some fooling around, and is a good thing. However, my network is extensive, devices are always being moved around, WiFi devices arriving and leaving, and so once the SDRs are assigned an IP, I have to go hunt them down. It was annoying that they’re always showing up somewhere different.

However, my Mac Pro had an unused second ethernet port sitting. right. there. Hmmm. So…
Read the rest of this entry »

Tags: , , , , , , , , , , , , , — awesome and easy web pages with Python

I do a lot of generating web pages using Python. Python because I think Python 2.7 is awesome, and web pages because I do lots of work with various web sites that require dynamic results. Python is a very useful tool for me to get those dynamic results. It’s server-side (at least, the way I use it, it is, because I really try not to embed client-side resource usurping things), it is fast and efficient, and it is what I am comfortable with.

The thing is, web pages — generally speaking — aren’t all that simple if you really do them right. You can’t just throw a few tags together, test them on one browser, and hope you’re golden. Because you won’t be, I can pretty much promise you.
Read the rest of this entry »

Tags: , , , , , , , , ,

Colored reports for text and HTML in Python

One of the things that I face regularly is report generation. Often they’re free form, by which I mean not tables full of tabulated data.

Output from my htmlAnsii() class

Output from my .htmlAnsii() class

Just “is this ok, is that ok, 27 of the other happened”, that sort of thing. I like to use color — green if everything is ok, red if it isn’t and so on.

I’m often out where I want the report in a web browser. But then again, I’m often at my desk, signed in to a console and I want it there. The environments couldn’t be much more different; HTML tags on the one hand, within the wrapper of a page, and ANSII escape sequences on the other. And they’re both kind of annoying and error-prone to write out explicitly, especially when you’re doing it a lot.

What to do?
Read the rest of this entry »

Tags: , , , , , , , , , ,

New Version of SdrDx (Mac / OS X version of CuteSDR)

Please see this post for the latest details on v1.07.

Tags: , , , ,

Python, TkInter, OSX (OS X) and making it all behave

I use Python a lot. Python 2.5.1 to be specific. And inside Python is TkInter, which, with a little work, will give you a handy way to put a GUI together. But there are problems. To say that TkInter is poorly supported and poorly documented under OSX is to understate the case rather dramatically. So you’re left to Google for answers, and mostly, they aren’t to be found — or if they are, they aren’t obvious or easily found. So I’m going to provide some answers here that have taken me quite some time to collect, and hopefully keyword and title them so that a Google search will actually get you to the solution you need sooner rather than as much later as it did me!
Read the rest of this entry »

Tags: , , , , , , , , , , , , , , , , , , , ,

Starting Out – priorities and pratfalls

It occurred to me in a moment of introspection that I, probably like many others, had my priorities set entirely wrong when I populated my very first apartment with… well, with stuff. And later on, my first home. If I knew then, what I know now. Sigh. Well, can’t fix that, but I can sure issue some good advice that others can benefit from if they so choose.
Read the rest of this entry »

Tags: , , , , , , , , , , ,