Shallow Thoughts : : Mar
Akkana's Musings on Open Source Computing and Technology, Science, and Nature.
Fri, 27 Mar 2015
Lately, Google is wasting space at the top of every search with a
begging plea to be my default search engine.
Google already is
my default search engine -- that's how I got to that page.
But if you don't have persistent Google cookies set,
you have to see this begging every time you do a search.
(Why they think pestering users is the way to get people to switch to
them is beyond me.)
Fortunately, in Firefox you can hide the begging with a userContent trick.
Find the chrome directory inside your Firefox profile, and
edit userContent.css in that directory. (Create a new file
with that name if you don't already have one.) Then add this:
#taw { display: none !important; }
Restart Firefox, do a Google search and the begs should be gone.
In case you have any similar pages where there's pointless content
getting in the way and you want to hide it:
what I did was to right-click inside
the begging box and choose Inspect element. That brings up
Firefox's DOM inspector. Mouse over various lines in the inspector
and watch what gets highlighted in the browser window. Find the
element that highlights everything you want to remove -- in this
case, it's a div with id="taw". Then you can write CSS to address
that: hide it, change its style or whatever you're trying to do.
You can even use Inspect element to remove elements immediately.
That won't help you prevent them from showing up later, but it can be
wonderful if you need to use a page that has an annoying blinking ad
on it, or a mis-designed page that has images covering the content
you're trying to read.
Tags: web, firefox, google
[
08:17 Mar 27, 2015
More tech/web |
permalink to this entry |
]
Thu, 19 Mar 2015
Google Code
is shutting
down. They've sent out notices to all project owners suggesting
they migrate projects to other hosting services.
I moved all my personal projects to GitHub years ago, back when
Google Code still didn't support git. But I'm co-owner on another
project that was still hosted there, and I volunteered to migrate it.
I remembered that being very easy back when I moved my personal projects:
GitHub had a one-click option to import from Google Code. I assumed
(I'm sure you know what that stands for) that it would be just as easy now.
Nope. Turns out GitHub no longer has any way to import from Google Code:
it tells you it can't find a repository there when you give it the
address to Google's SVN repository.
Google's announcement said they were providing an exporter to GitHub.
So I tried that next. I had the new repository ready on GitHub --
under the owner's account, not mine -- and I expected Google's
exporter to ask me for the repository.
Not so. As soon as I gave it my OAuth credentials, it immediately
created a new repository on GitHub under my name, using the name
we had used on Google Code (not the right name, since Google Code
project names have to be globally unique while GitHub projects don't).
So I had to wait for the export to finish; then, on GitHub, I went
to our real repository, and did an import there from the new
repository Google had created under my name. I have no idea how
long that took: GitHub's importer said it would email me when the
import was finished, but it didn't, so I waited several hours and
decided it was probably finished. Then I deleted the intermediate repository.
That worked fine, despite being a bit circuitous, and we're up and
running on GitHub now.
If you want to move your Google Code repository to GitHub without the
intermediate step of making a temporary repository, or if you don't
want to give Google OAuth access to your GitHub account,
here are some instructions (which I haven't tested) on how to do
the import via a local copy of the repo on your own machine, rather
than going directly from Google to GitHub:
krishnanand's
steps for migrating Google code to GitHub
Tags: github, programming
[
13:11 Mar 19, 2015
More programming |
permalink to this entry |
]
Sat, 14 Mar 2015
It's getting so that I dread Firefox's roughly weekly "There's a new
version -- do you want to upgrade?" With every new upgrade, another new
crucial feature I use every day disappears and I have to spend hours
looking for a workaround.
Last week, upgrading to Firefox 36.0.1, it was keyword search: the
feature where, if I type something in the location bar that isn't a
URL, Firefox would instead search using the search URL specified in
the "keyword.URL" preference.
In my case, I use Google but I try to turn off the autocomplete feature,
which I find it distracting and unhelpful when typing new search terms.
(I say "try to" because complete=0 only works sporadically.)
I also add the prefix allintext: to tell Google that I only
want to see pages that contain my search term. (Why that isn't the
default is anybody's guess.) So I set keyword.URL to:
http://www.google.com/search?complete=0&q=allintext%3A+
(%3A is URL code for the colon character).
But after "up"grading to 36.0.1, search terms I typed in the location
bar took me to Yahoo search. I guess Yahoo is paying Mozilla more than
Google is now.
Now, Firefox has a Search tab under Edit->Preferences
-- but that just gives you a list of standard
search engines' default searches. It would let me use Google, but
not with my preferred options.
If you follow the long discussions in bugzilla, there are a lot of
people patting each other on the back about how much easier the
preferences window is, with no discussion of how to specify custom searches
except vague references to "search plugins".
So how do these search plugins work, and how do you make one?
Fortunately a friend had a plugin installed, acquired from who knows
where. It turns out that what you need is an XML file inside a
directory called searchplugins in your profile directory.
(If you're not sure where your profile lives, see
Profiles - Where Firefox stores your bookmarks, passwords and other user data,
or do a systemwide search for "prefs.js" or "search.json" or "cookies.sqlite"
and it should lead you to your profile.)
Once you have one plugin installed, it's easy to edit it and modify it
to do anything you want. The XML file looks roughly like this:
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
<os:ShortName>MySearchPlugin</os:ShortName>
<os:Description>The search engine I prefer to use</os:Description>
<os:InputEncoding>UTF-8</os:InputEncoding>
<os:Image width="16" height="16">data:image/x-icon;base64,ICON GOES HERE</os:Image>
<SearchForm>http://www.google.com/</SearchForm>
<os:Url type="text/html" method="GET" template="https://www.google.com/search">
<os:Param name="complete" value="0"/>
<os:Param name="q" value="allintext: {searchTerms}"/>
<!--os:Param name="hl" value="en"/-->
</os:Url>
</SearchPlugin>
There are four things you'll want to modify. First, and most
important, os:Url and os:Param control the base URL
of the search engine and the list of parameters it takes.
{searchTerms} in one of those Param arguments will be replaced
by whatever terms you're searching for. So
<os:Param name="q" value="allintext: {searchTerms}"/>
gives me that allintext: parameter I wanted.
(The other parameter I'm specifying,
<os:Param name="complete" value="0"/>, used to
make Google stop the irritating autocomplete every time you try to
modify your search terms. Unfortunately, this has somehow stopped
working at exactly the same time that I upgraded Firefox. I don't
see how Firefox could be causing it, but the timing is suspicious.
I haven't been able to figure out another way of getting rid of the
autocomplete.)
Next, you'll want to give your plugin a ShortName and
Description so you'll be able to recognize it and choose it
in the preferences window.
Finally, you may want to modify the icon: I'll tell you how to do that
in a moment.
Using your new search plugin
You've made all your modifications and saved the file to something inside
the searchplugins folder in your Firefox profile. How do you
make it your default?
I restarted firefox to make sure it saw the new plugin, though that
may not have been necessary. Then Edit->Preferences and
click on the Search icon at the top. The menu near the top
under Default search engine is what you want: your new plugin
should show up there.
Modifying the icon
Finally, what about that icon?
In the plugin XML file I was copying, the icon line looked like:
<os:Image width="16"
height="16">data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAA
... many more lines like this then ... ==</os:Image>
So how do I take that and make an image I can customize in GIMP?
I tried copying everything after "base64," and pasting it into a file,
then opening it in GIMP. No luck. I tried base64 decoding it (you do
this with base64 -d filename >outfilename
) and reading it
in with GIMP. Still no luck: "Unknown file type".
The method I found is roundabout, but works:
- Copy everything inside the tag: data:image/x-icon;base64,AA ... ==
- Paste that into Firefox's location bar and hit return. You'll see
the icon from the search plugin you're modifying.
- Right-click on the image and choose Save image as...
- Save it to a file with the extension .ico -- GIMP won't
open it without that extension.
- Open it in GIMP -- a 16x16 image -- and edit to your heart's content.
- File->Export as...
- Use the type "Microsoft Windows icon (*.ico)"
- Base64 encode the file you just saved, like this:
base64 yourfile.ico >newfile
- Copy the contents of newfile and paste that into your
os:Image line, replacing everything after
data:image/x-icon;base64,
and before </os:Image>
Whew! Lots of steps, but none of them are difficult. (Though if you're
not on Linux and don't have the base64 command, you'll have to
find some other way of encoding and decoding base64.)
But if you don't want to go through all the steps, you can download
mine, with its lame yellow smiley icon, as a starting point:
Google-clean
plug-in.
Happy searching! See you when Firefox 36.0.2 comes out and they
break some other important feature.
Tags: firefox, web
[
12:35 Mar 14, 2015
More tech/web |
permalink to this entry |
]
Sat, 07 Mar 2015
I needed to turn some small black-on-white icons to blue-on-white.
Simple task, right? Except, not really. If there are intermediate
colors that are not pure white or pure black -- which you can see
if you magnify the image a lot, like this 800% view of a 20x20 icon --
it gets trickier.
You can't use anything like
Color to Alpha or Bucket Fill, because all those grey antialiased
pixels will stay grey, as you see in the image at left.
And the Hue-Saturation dialog, so handy for changing the hue of a sky,
a car or a dress, does nothing at all -- because changing hue
has no effect when saturation is zero, as for black, grey or white.
So what can you do?
I fiddled with several options, but the best way I've found is the
Screen layer mode. It works like this:
In the Layers dialog, click the New Layer button and accept the
defaults. You'll get a new, empty layer.
Set the foreground color to your chosen color.
Drag the foreground color into the image, or do Edit->Fill with
FG Color.
Now it looks like your whole image is the new color. But don't panic!
Use the menu at the top of the Layers dialog to change the top layer's
mode to Screen.
Layer modes specify how to combine two layers. (For a lot more information,
see my book, Beginning GIMP).
Multiply mode, for example, multiplies each pixel in the two layers,
which makes light colors a lot more intense while not changing dark
colors very much.
Screen mode is sort of the opposite of Multiply mode: GIMP inverts
each of the layers, multiplies them together, then inverts them again.
All those white pixels in the image, when inverted, are black (a value
of zero), so multiplying them doesn't change anything. They'll still be
white when they're inverted back. But black pixels, in Screen mode,
take on the color of the other layer -- exactly what I needed here.
Intensify the effect with contrast
One place I use this Screen mode trick is with pencil sketches.
For example, I've made a lot of
sketches of Mars
over the years, like this sketch of Lacus Solis, the "Eye of Mars".
But it's always a little frustrating: Mars is all shades
of reddish orange and brown, not grey like a graphite pencil.
Adding an orange layer in Screen mode helps, but it has another problem:
it washes out the image. What I need is to intensify the image underneath:
increase the contrast, make the lights lighter and the darks darker.
Fortunately, all you need to do is bump up the contrast of the sketch
layer -- and you can do that while keeping the orange Screen layer in
place.
Just click on the sketch layer in the Layers dialog, then run
Colors->Brightness/Contrast...
This sketch needed the brightness reduced a lot, plus a little more
contrast, but every image will be different. Experiment!
Tags: gimp, layer modes
[
18:22 Mar 07, 2015
More gimp |
permalink to this entry |
]