Adding startpage.com search engine to thunderbird

While I was quick to make use of the startpage.com “add search engine” button there isn’t really such a friendly method to add a search engine to thunderbird.

Long(ish) story short thunderbird and firefox use very similar methods to store your profile information, the startpage.com configuration for firefox is stored in

/home/<your user name>/.mozilla/firefox/<a random string>.default/searchplugins

I noticed one article talked about adding google as a custom search engine and mentioned creating a searchplugins directory in your thunderbird profile

/home/<your user name>/.thunderbird/<a random string>.default/searchplugins

So I copied the file startpage-https—uk.xml from the firefox profile into the thunderbird profile.

It was just then a matter of searching for something in thunderbird using the current default, clicking the searchpage icon on the left and then setting it as the default (heart icon at the bottom left)

 

Posted in Uncategorized | Leave a comment

Gentoo, portage cheat sheet.

While there is a perfectly good cheat sheet here to be honest I tend to blog as much as an aide-mémoire for myself so I’ve made my own notes and condensed it down to what I find most useful, hopefully it should be also useful for others!

Update the package db

emerge --sync

This will update all the meta information allowing the system to see if there are updated packages available compared to what you have installed

Actually updating the system

emerge --ask --update --deep --with-bdeps=y --newuse @world

Almost every occasion you use emerge always use the ––ask parameter this will do a dry run and ask if this is what’s intended, take for example this

emerge --ask glut

This would go ahead and install a load of haskel packages (something you might not have intended) as glut appears as part of dev-haskell section of packages, contrast this with

emerge --ask freeglut

and you see a different picture – and this is a minor foobar compared to what you could do by blindly running emerge

back to the update command, all the stuff you ask to be installed is recorded in the “world package set”, so updating this with a deep dependency check while also including any new USE flags, should comprehensibly update your system…

 

clean up after an update

emerge --depclean --ask

You should notice after updating your system it mentions to do this but its worth mentioning!

Find config’s needing attention

find /etc/ -name "._cfg*"

I’ll admit I couldn’t find those _cfg files for a while till realising they were hidden (dot) files – a simple find command will list them for you, its then just a case of using diff or meld to check out the differences.

Exploring dependencies

installing gentoolkit allows finding out why a package got installed.  For example what packages need to have bash installed

equery d bash

Probably more useful, to find out what packages are needed by bash

equery g bash

Although you might find you want to restrict it to a version number and changing the depth to unlimited probably isn’t a good idea…

Uninstalling

There isn’t really an automated way to uninstall a package and its dependent packages as you could potentially gut your system, however a useful command is:

emerge --ask --depclean --verbose libsdl2

in this example you’ll get a list of all the dependent sdl libs like for example sdl2-image, you can then check all these and uninstall them, eventually you can then uninstall the original package too, another alternative after you’ve checked the dependent packages is to just use  ––unmerge followed up by a depclean on its own.  Be warned you still need to use ––ask when specifying a package for depclean, as it will uninstall stuff that doesn’t have dependent packages.

Of course I’ve not even touched on USE flags – that’s a whole other minefield ballgame and depends upon what you’re doing and to a certain extent taste, so maybe something for another post.

Posted in Uncategorized | Leave a comment

Gentoo my new distro of choice

While it seems to me that as much as Devuan would be a nice solution its going to be a long time coming.  As far as I can make out (and there in lies another issue!) they are after 1:1 binary compatibility, for me that’s just not enough, to do a fork properly they need to be building everything from sources and becoming a separate distro in their own right, in future this lock step could take more work than they can manage.

So all the while I was experimenting with removing systemd from Jessie (its possible but leaves a less than ideal system) I was also experimenting with Gentoo.

I must explain at this point about my previous exposure to Gentoo, it was quite some time ago, when multiple cores where unheard, and on top of that I’m sure that the turn over of package updates was much greater.  It’s more than possible (even with a multi core compile) to just continue on with what you’re doing and mostly not notice much slowdown. But you are by no means taking all your time compiling!

This responsiveness is one points where Gentoo really excels I thought that Debian (especially with a SSD) was responsive but Gentoo is really very responsive and fast.

Another thing I’ve noticed is that the dependencies are far more freer, where a Debian package will mandate certain other dependencies its actually quite possible to configure a package with a degree of flexibility that allows you a great deal more freedom.

Now there is a cost to this… (Isn’t there always !) the flexibility is achieved through a little more complexity (there is a learning curve (hill?!)) But for sure its not impossible and once you grok the basics of portage its a powerful piece of kit.

One thing I was sure was going to be a real nightmare was Steam, and I’m fairly sure that I ended up installing a boat load more 32 bit libs than I strictly needed to… that said its working just fine, save for some of the videos in the store being NaN in length, but that an issue I had with Debian too, so I’m not over troubled.

I’ve now gone as far as using Gentoo to install and maintain grub2 which I was previously doing from Debian, so I know which is my “main” distribution now.

While getting to grips with portage may initially seem like a daunting issue when its unfamiliar, but for the system you get, its more than well worth putting in the time to learn….

…and its certainly takes less time that wrestling systemd away from Jessie….

 

 

Posted in Uncategorized | Leave a comment

A slightly longer look at Lwjgl3

While I’m waiting for Lwjgl’s GLES binding, I thought I’d put together some code using shaders that could be easily ported to GLES later (As such it uses a subset of what’s usually available)

I’ll quickly run through how the shader is implemented.  Lets look at the main body of the vertex shader, which couldn’t be simpler…

               gl_Position = modelviewProjection * pos;
               v_color = color;
               v_frag_uv = uv_attrib;

We’ll see shortly that our vertices have the following attributes position, colour, and UV or texture coordinate.  Each time we render we once per frame set the MVP matrix, this is a combination of the model matrix (position and orientation of the model) the view matrix (the view or “camera” position and orientation) and the projection matrix (which simply put makes distant objects smaller).  The vertex position is combined (multiplied) by this matrix, its this magic black box of a matrix that makes our 2d screen look like a 3d view.  The colour and texture coordinate are passed to the fragment shader (which does the actual drawing now it knows where everything is…)

So this means we need some data to feed the shader you can see a large array of data in the code, this is used to “load” the vertex array buffer

float verts[] = {
   // vert                     // colour               // UV
   -0.5f, -0.5f, -0.5f,        1.0f, 0.0f, 0.0f,       0.0f, 0.0f,

As you can see there are three floats for the vertex position (x,y,z) followed by three floats for the colour (red, green, blue) and finally two floats for the texture coordinate.  This is repeated for each vertex of the model.

I should mention that including a colour component for each vertex possibly isn’t that useful, something rather more useful would be vertex normals, which is typically used for lighting (and potentially physics too).  But including lighting would make the shader more complex, but I may well make a sample for that when Lwjgl gets a GLES binding.

One point that I’ve seen causing people no end of problem is the glVertexAttribPointer command, lets look at how its used

// attrib, number items, type, normalised, byte stride, byte offset
glVertexAttribPointer( attr_pos, 3, GL_FLOAT, false, 32, 0 );
glVertexAttribPointer( attr_color, 3, GL_FLOAT, false, 32, 12 );
glVertexAttribPointer( attr_uv, 2, GL_FLOAT, false, 32, 24 );

one point to remember is the unlike second parameter size (or number of items) the last two parameters are not expressed in number of items, but rather as a number of bytes.

To get from any one point in the array to the same point in the next vertex is the stride, which in this case is 32 because…

3 pos (x,y,z) + 3 colour (rgb) + 2 UV = 8 * 4 bytes per float = 32

from this you should be able to see how the offset works…

Looking at the comments in the code and reading up on the individual OpenGL commands you should see how it all works.

The demo has some simple controls they are normally inactive while the cube auto rotates.

the controls are toggled with the space bar, here’s a run down on what they do:

Q/W    Rotate round the models X axis
A/S            ""    ""        Y axis
Z/X            ""    ""        Z axis

R/T    Move along the world X axis
F/G          ""    ""       Y axis
V/B          ""    ""       Z axis

You can download the source here, enjoy!

Posted in Uncategorized | Leave a comment

lwjgl 3 (yes 3!) a quick look

If all you’d ever done was look at the front page of LWJGL’s website you could (almost) be forgiven for thinking it was a dead project!  This is solely because over the last year or so they have been hard at work with the all new and shiny version 3.

While it’s out – its still early days really and I’m really waiting for the GLES bindings as I like to restrict myself to GLES 2.0 for the sake of easy porting (its everywhere now from embedded hardware to webGL) That said I decided to take it out for a quick spin, just to see how it was shaping up.

With it being such early days there is not much in the way of documentation, I did have to wrestle a little bit with making a build script that would compile and also run a small demo.

I decided to isolate and adapt the GLFW event demo and add the obligatory textured triangle to it…

For the sake of laziness speed I “borrowed” the demo’s IOUtils class – however it has been pointed out to me that this drags in the whole of AWT so you should use something else for loading an image into a bytebuffer.  There are a number of utility jars for this kicking around, you could even just stick to a very tiny PNG only one or take something that you can throw any image at and it will convert the data to your choice of GL data format – as ever with LWJGL the choice is yours.

I’ve targeted GL 1.0 and its evil calls to glVertex and glTexCoord2f, however I just wanted a tiny chunk of code to show it working with rather more than just a blank window.  When the GLES binding is in release, I’ll mess around with various buffers, shaders and so forth but that will obviously be a larger example.

The demo’s where all static code (nothing wrong with that) but I wanted to break all the event handling out of anonymous methods – as at a later date the event handling could be its own class (mainly just for the sake of manageability)  I don’t mind the odd single anonymous method, but I personally find great chunks of them make code less readable and sometimes harder to manage.

With the inclusion of GLFW3 the native window handling code is all abstracted away in a nice simple cross platform way, I often think that EGL didn’t quite go far enough but there are good reasons for stopping where they did…

I do like the way the demo’s use static imports as now (for example) GL10.glColor becomes just glColor and you could be looking at C code as easily as Java, its a small thing but its less typing and more readable which I’m all for.

One thing that did have me almost tearing what hair I have out, was the infamous library path! I could only get it working with an absolute path, and for the sake of a distributed launcher script it would have been nice to be able to get it to work relative.

  <jvmarg value="-Dorg.lwjgl.librarypath=${basedir}/native" />
  <jvmarg value="-Dorg.lwjgl.librarypath=native" />

seemed to do the trick, notice ${basedir} this gives you ant’s working directory (the one ant was run from)

I’m not sure what’s the best solution just yet for an end user (of your product), in a Linux script you can always back tick pwd but not being a windows user I wouldn’t have a clue about doing that from a bat file…

Looks like this is was a bug that was fixed hours after I did my pull from git! relative paths do work with library path.

I’ve included the quick and dirty project with this article, you’ll need to make and populate a jar folder and a native folder – I’ll leave that as an exercise for the reader.

One thing I did notice was that with everything included (all binaries and cross platform native libs) a compressed archive was only a little over 3mb (thankfully) no bloat there then!

Enjoy!

Posted in Uncategorized | Leave a comment

Taming the Lapdock 100 (for a Raspberry Pi)

You can pick up a Lapdock 100 for around £50 – which for a mouse, keyboard, screen and battery combination is hard to beat.  Naturally as its not a solution specifically for the Pi its not just plug and play.  The Lapdock connectors consist of a HDMI micro plug and micro USB plug, so you’ll need to buy some adaptors and for best results be prepared to do some soldering.  There are guides for building a Y cable all over the place many of varying quality from mediocre to poor (I did loose one that was really good – if I find it I’ll edit it in here!)

Apparently with later models of the Pi its a moot point but I found that any USB plugged into the (non power) USB sockets of the Pi would light the power led but not boot the Pi.  Basically your Y cable should pass data +/- and GND to a usb DATA port and just GND and +5v to the Pi’s usb micro socket.

I found a great deal of conflicting information about the Lapdock 100 some people seemingly with the belief it simply could not be used with the Pi.

While there are some caveats I have found it to work just fine.

Make sure the config.txt is set correctly to make the HDMI active all the time.

You are better powering down without the mains lead in and in fact to get the Lapdock into a state where it will boot your Pi with the screen active (or at all) you must disconnect the Pi’s power connector and also the Lapdocks power.

Assuming both are disconnected or you were just running from battery (with the Pi’s power disconnected),  you need to wait for the LED in on the Lapdocks “power button” to flash.   If you’ve forgotten to unplug the power lead before shutting down (do it now) it could take 30 seconds or more after everything is disconnected.  Running with just the battery when unplugging the Pi’s power it usually only takes 5 or 6 seconds to flash the LED (but sometimes longer)

Now the Lapdock is in the “post LED flash” condition one of two things will make the Lapdock power up the Pi and its display, either press the Lapdocks power button or plug in the Lapdocks power lead.

I’ll be adding a switch to the power side of the Y cable and be looking for a shorter HDMI cable – then with the addition of some velcro I should have quite a nice Pi Laptop.

As for the Lapdock itself the screen is really nice very clear and steady, the mouse is okay with the exception of the right mouse button (but I might have just got unlucky) – the keyboard itself is not the worlds best, especially the space bar which is quite poor sometimes registering two hits and sometimes none.  Generally the feedback from the keys is not great, but it works!

So if its a dodgy low res LCD from Hong Kong or the Lapdock, I’d have to say the Lapdock has it.

Posted in Uncategorized | 2 Comments

Debian Jessie – without systemd

Update: It looks like with Jessie now “frozen” that for the time being your freedom not to install systemd is fairly safe… In addition you can seemingly get rid of most of pol/console kit cruft too.  While the so called lightdm and slim are ruled out by this, at least xdm is still lightweight…

Debian has caved into systemd and if it was “just” a sysv replacement I’d be just all: Meh – get on with it…

There are *lots* of reasons why systemd is broken by design which I won’t bother reiterating (see here) by far the worse is lack of choice (choice being my main motivation for using Linux!) – before long you won’t be able to use anything else…

The poor way systemd developers are reacting to bug reports and criticism is like a nightmare redux of pulse audio (remind me what problems I never had is that bloatware actually solving) Could there be a connection?  Maybe this sabotaging Microsoft employee knows.

I wondered if it were still possible to run a Debian (specifically Jessie) system without systemd – I’m glad to say for the moment at least its possible!

I uninstalled as much as I could (after installing sysv first!) I had to reboot to finally uninstall systemd but ended up leaving libsystemd installed as Blender (and a bunch of other stuff) seems to have a dependency on it. Its a pernicious dependency chain (especially dbus – no alternative for that either), which is what systemd is using to gain its domineering position.

I did end up loosing some gnome junk which I’m really not sorry to loose.

There is no discernible difference to my 6 second or so boot time, so I guess systemd is another piece of junk solving a problem just for the sake of it, that really isn’t an actual problem.

One minor irritation is that you loose policykit (really is it impossible to provide policykit functionality without systemd) these means no pkexec, really no great loss but it is used by the .desktop files for gparted and synaptic. The simple hack is just to use gksudo in the desktop files – these will get overwritten by updates probably but then I have launchers on my Desktop.  I really, really can live without policykit!

So hopefully this will hold me until I’ve learnt how to set up FreeBSD Gentoo how I like it…

 

Posted in Uncategorized | Leave a comment

Papillio Pro – Introducing Schematic Capture

(Arrgh them damn bus taps!)

schmatic-intro

After a lengthy break from electronics (blame the wife!) I decided to get back into working with FPGA’s and the world of pain that are their woeful accompanying tools…

You can see from my earlier posts that my introduction to VHDL allowed me to produce (from scratch!) a VGA signal generator, I was left feeling that (for me personally) VHDL was not the most intuitive way of designing a circuit and I promised myself that I would have a good look at using schematic capture (basically its turning a diagram of logic blocks into VHDL).

For my first trial – and that’s what it was! I decided I’d make a simple circuit just to flash the Papilio Pro’s onboard LED a couple of times a second.  I still don’t know what it was that was holding me up for quite some time, but temporarily replacing one of the counters with a larger one fixed the problem.  Once I swapped the counter back it was still working – like it should have been all along! (I’m guessing I might have to get used to the odd bit of random behaviour)

Anyhow the basic design was simple, count the boards 32mhz clock pulses with a large enough counter and use a fairly high bit of the counters output as a driver for the LED.

Take a quick click at the image above it might help follow whats going on. A 32mhz clock has a period of 31.25ns my first guess at how many bits I’d need was spot on, the high bit of an eight bit counter driven by the high bit of a sixteen bit counter…

According to WolframAlpha 31.25ns * (2^24) comes out at just over half a second which puts us in the ballpark of perceivable flashing.

Now you’d have thought that a really very basic circuit like this could have been implemented even by a newbie in what 10 minutes? I wish!  Aside from the circuit behaving badly in real life and simulation then the same circuit partly rebuilt working – there is the little *gem* of bus taps….

Bus taps are should be a simple a way of getting (in this case) just one signal from a bus of say sixteen signals.  The big gottcha is making sure that “automatically add a bus tap between the bus and wire” is set in the add wire options.  It doesn’t actually seem to do anything when you create the bus, but it does mean that it will allow taps to be added to it, if you’ve not selected this option who knows if you can do it without destroying and recreating the bus first!  Actually placing the tap isn’t particularly intuitive either, first you have to click with the centre of the bus tap to select the bus, then you have to move the head of the bus tap exactly onto the bus and click again.  Basically the whole process is a needless ball ache (and I’m being polite here!!!)

But wait there’s more! (pain)

It took me further time and frustration to discover that the bus name and the outgoing wire (net) both have to have the same name ie:

COUNT_2_OUT(7:0) –> (the tap) –> COUNT_2_OUT(7)

It took me a while for this to dawn on me sadly… (the warnings showed a problem but could have been a LOT more useful) this seems to mean that if you want to keep an output named for example LED1 (in your constraints for example) you seem to need to put a buffer between the wire coming out of the tap and into the output marker.

I wish that were all the frustrations with their bad advert, but Xilinx’s tools are far from eXcillent with a wide range of glitches and really awkward interface design choices.

There was some good news mind, after I got my flashing LED, I decided to tie TX and RX of the USB serial channel together, just to see if I’d get anything back over USB.  To be honest between Xilinx tools and potential configuration issues with the laptops ttyUSB I wasn’t over hopeful! but get this – it work first time - no really, I was so shocked I had to throw an inverter into the mix to check I got rubbish back for fear it was just a local echo!

So my conclusions – well I think you know my thoughts on Xilinx’s tools – its a shame they don’t grok the advantages of open source, it would improve their tools and make them a bunch more money, but ah well I digress – I definitely do see the advantage of using schematic capture (for me personally its a lot more intuitive) and my next task I’m going to set myself is converting a VHDL snippet into a working library symbol (I’m thinking UART here) – Wish me luck! :)

 

Posted in Uncategorized | Leave a comment

GreaseMonkey gottcha – script not triggering ?

In the unlikely event you haven’t discovered GreaseMonkey it’s ideal for tweaking the presentation of a website to suit your own taste.

A good example of this would be the ad sponsored block of links typically at the top of the list of search results.  These are often presented in a box with a subtly different background colour, alas this colour is usually so subtle that especially on a laptop screen you can’t see it! (if I was suspicious I’d think it was done that way on purpose!)

Doing a quick hack for this rather than searching for someone else’s script is probably quicker and certainly good practice.

My search engine of choice is startpage and I was scratching my head trying to figure out why the script wasn’t being triggered – then I looked again at the URL (check the page info when right clicking on the page with firefox)

https://startpage.com/do/metasearch.pl

The thing here is the second slash after the domain name I’d assumed that the filter https://startpage.com/* would basically capture everything – turns out this isn’t sufficient and https://startpage.com/*/* is what’s required.

Just one more minor irritation is that ID attributes are *supposed* to be unique within a document, however the div at the bottom of the results also shares the same ID.  While there are facilities to get arrays of all tags with shared class attributes, as far as I’m aware this is not the case with ID’s.  I decided to just brute force through all the div tags in a document searching for the same target ID, there may well be a more elegant way to do this but what the hey it works!

I’ve included the script here for anyone who’s not used GreaseMonkey but fancies a play…

// ==UserScript==
// @name        startpage ad
// @namespace   codifies@bedroomcoders.co.uk
// @description makes the background for the ad links actually visible
// @include     https://startpage.com/*/*
// @version     1
// @grant       none
// ==/UserScript==

//var el = document.getElementById("sponsored_container");
//el.style.backgroundColor = '#8080ff';

// *sigh* all id's *should* be unique

var all = document.getElementsByTagName("div");

for (var i=0, max=all.length; i < max; i++) {
     if (all[i].id=="sponsored_container") {
       all[i].style.backgroundColor = '#a0a0ff';
     }
}

 

 

Posted in Uncategorized | Leave a comment

SpritePlacer get physics

SpritePlacer

While far from complete, SpritePlacer now has physics.  Each sprite can have multiple physics shapes added to it.  This allows you to have sprites that aren’t rectangular.  You can see an example of this on the left (click to enlarge), the dumbbell shapes each have three physics shapes.  Two spheres and a rectangle are sufficient to make the collision shape for the sprite.  In addition to the collision shapes (and properties like restitution friction and density) its also possible to have different body types, as well as static and dynamic bodies you can have kinematic bodies.  While there isn’t much use for kinematic bodies at the moment they might be quite useful once I’ve implemented scripting.

There is a bunch of stuff still to implement physics wise and I’ll be resetting sprite positions once the editor is put back into edit mode after “running” the physics.

While I initially just wanted a way to place a bunch of sprites in a “level”, by the time I’ve added physics and scripting I’ll have in effect a 2d game creator.  I’m not sure just yet what events to support (collision, level loaded etc) but its funny how a simple project can gradually evolve into something else altogether!

Posted in Uncategorized | Leave a comment