Todays useful tip:
The linux chmod command has two x operands, x (small) and X (big)
Small x means set the execute bit no matter what.
Big X means set the execute bit only on folders (and files where the execute bit is already set, in other words dont break script files)
This means you can do a recursive chmod and set the execute bit correctly.
eg.
chmod -r a+rwX
Its the little things.
*sigh*
26 April 2017
23 July 2015
CSS3 Drop Menu Fade In
The Basics
I have an HTML menu:UL - top menu
LI - first item
A
UL - sub menu
LI - first sub item
A
and some basic CSS:
#menu li ul {
display: none;
}
#menu li:hover > ul {
display: block;
}
So when we hover over the first item, the sub-menu appears. Simples.
Fade-in using transition
I wanted to make the menu fade in using the lovely new css transition attribute, and I thought by adding an opacity attribute it would, appear then fade in.#menu li ul {
display: none;
opacity: 0;
transition: opacity .25s;
}
#menu li:hover > ul {
display: block;
opacity: 1;
}
So in theory when we hover the display is changed to block, and the opacity will fade the menu in a .25 seconds.
It doesn't work however, using the display attribute breaks the transition, no idea why but it does.
CSS animate to the rescue
We can make it work using the animate property and a keyframes block.
@keyframes fadein {
0% { opacity: 0; }
100% { opacity: 1; }
}
#menu li ul {
display: none;
opacity: 0;
animation: fadein .25s;
}
#menu li:hover > ul {
display: block;
opacity: 1;
}
There is one drawback with this method however, we can't do a fadeout, because the display:hidden happens at the start of the animation, not a the end, which is what we want to happen in a fadeout.
display: none;
opacity: 0;
animation: fadein .25s;
}
#menu li:hover > ul {
display: block;
opacity: 1;
}
There is one drawback with this method however, we can't do a fadeout, because the display:hidden happens at the start of the animation, not a the end, which is what we want to happen in a fadeout.
Thanks to Hermann Schwarz for the idea.
20 July 2015
Kerberos SSO for Google Chrome on Mac OS X
Normally Macs are better at doing this stuff, however.
To get Kerberos SSO (SPNEGO) authentication working on chrome you normally have to use command line parameters with the Chrome binary; which while certainly possible on macs can be done by creating a startup script.
A far simpler way is to issue the following commands from the command line:
$ defaults write com.google.Chrome AuthServerWhitelist “*.example.com”
$ defaults write com.google.Chrome AuthNegotiateDelegateWhitelist “*.example.com
Thanks to Jeff Geerling for this one.
To get Kerberos SSO (SPNEGO) authentication working on chrome you normally have to use command line parameters with the Chrome binary; which while certainly possible on macs can be done by creating a startup script.
A far simpler way is to issue the following commands from the command line:
$ defaults write com.google.Chrome AuthServerWhitelist “*.example.com”
$ defaults write com.google.Chrome AuthNegotiateDelegateWhitelist “*.example.com
Thanks to Jeff Geerling for this one.
31 July 2014
Internet Explorer Woes Still!
Microsoft WHY WHY WHY!
I have gone back in time. I am fighting with IE AGAIN.
Internet Explorer Version 11. Its the latest and greatest, and for the most part standards compliant browser. Well done.
SVG
Today I have been using SVG graphics. SVG's are awesome, they are the future, they should have been around 10 years ago, except for IE's failure to support them. Finally now all modern browsers support them (and have done for a while), at least in their basic incarnation.
<img src="mywonderfulgraphic.svg" />
<img onerror="this.onerror=null;this.src='fallback.png'" src="newshiny.svg" />
There are other ways to do this I agree, but this way to me seems the simplest, and most efficient.
I have also added a simple server optimisation. Doing some "evil" browser sniffing, if the browser is MSIE 8 or below, I just serve the PNG, and don't bother with SVG.
<img src="fallback.png" />
So far so good.
Until we come to IE11
IE has an SVG scaling bug, which means the SVG image wont scale correctly: Given a percentage width it wont scale the height appropriately resulting in stretched images. PNG's scale just fine.
I investigated trying to fiddle it, using CSS, but without jumping through a lot of hoops, it becomes just awkward. So my next thought was, it's ok, I can just deliver the PNG instead, I'll just use the browser sniffing to check the IE version.
The IE team have decided to the remove "MSIE" from the User Agent String. I now dont know which browser is talking to the server, because IE pretends to be all of them.
(Update) Actually they have changed the User Agent String, and after a bit of fidding the IE browser version can be detected for any IE version using the following regex:
(Update) Actually they have changed the User Agent String, and after a bit of fidding the IE browser version can be detected for any IE version using the following regex:
\b(?:MSIE\s|Trident\/[0-9.]+;\srv:)([0-9.]+)
It can used like this from PHP:
$version = [false,false];
$isIE = preg_match("/\b(?:MSIE\s|Trident\/[0-9.]+;\srv:)([0-9.]+)/",$_SERVER['HTTP_USER_AGENT'],$version);
return $isIE? $version[1]: false;
Aha!, they say "You should be using feature detection instead of User Agent sniffing".
Well thats all very well if your features worked like they should, then I wouldn't have to deliver browser specific content in the first place. Which, as a matter of fact, is why browser sniffing was needed in the first place!
What about conditional comments you say.
Nope they don't work for IE11 either. The IE team decided to remove them from IE 11.
Rock meet Hard Place.
(Update) There are various sites on the interwebs which give ideas about getting round the SVG issue eg. larrybotha on github
If I make sure the SVG has the viewBox attribute set, I can set the height in CSS to 100%
To target IE 10+ browsers, use the following css media query:
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
/* IE10+ specific styles */
.selector img[src$=".svg"] { height: 100%; }
}
(Update) Safari also suffers from SVG scaling bugs. I was trying to do hovering on scaled images, using image replacement, and every time the image got swapped, it messed up the image aspect or scaling.
Labels:
browser,
bug,
fallback,
IE,
IE11,
image replacement,
internet explorer,
microsoft,
MSIE,
rant,
scaling,
svg,
user agent,
user agent sniffing
22 July 2014
Pasting into a photoshop channel/layer/alpha mask
All I want to do is paste into the channel mask of a layer, this is where GIMP has a big win. Right click, then select create greyscale copy of layer as mask. Yay, exactly what I want to do.
Photoshop has an all or nothing approach, reveal all or reveal none, to create an all black or all white mask, I then have to paste to the mask, but to paste to the mask I have to enable/make it visible first.
The easiest way:
Alt-Click the layer mask. (To enable direct editing of the layer mask)
Ctrl-V to paste into the layer mask.
The slightly more convoluted way:
Click on the channels list, then click on the eye next to mask layer to make it visible/editable.
Ctrl-V to paste into the layer mask.
Further, if you want to automate the paste into mask, you need to use Ctrl-Shift-V.
Photoshop has an all or nothing approach, reveal all or reveal none, to create an all black or all white mask, I then have to paste to the mask, but to paste to the mask I have to enable/make it visible first.
The easiest way:
Alt-Click the layer mask. (To enable direct editing of the layer mask)
Ctrl-V to paste into the layer mask.
The slightly more convoluted way:
Click on the channels list, then click on the eye next to mask layer to make it visible/editable.
Ctrl-V to paste into the layer mask.
Further, if you want to automate the paste into mask, you need to use Ctrl-Shift-V.
Labels:
alpha,
automation,
channels,
gimp,
graphics,
layer mask,
layers,
paste,
photoshop
23 June 2014
Netsupport Mac Client CPU Issue
Netsupport is great. It allows you to remote access, and control other machines on your network. Of course there are other ways to do it eg RDP, and VNC, but netsupport nicely ties it all together and makes it very easy.
I did have an issue however, on the Mac, I just wanted to install the Netsupport Manager, ie I just wanted to control other machines, and not be controlled. During the installation there didn't seem to be any options to not install the client, but as I checked the 'control and manage only' option (or words to that effect) and assumed the client wouldn't be installed.
Not only was the client installed, but when the machine is idle. The Netsupport Client processing is running, and taking up about 8-10% CPU all the time. As I have a reasonably decent machine (OS X 10.9.3, 2.3GHz i7, 16GB RAM) this CPU use is hardly noticeable, but it really bugged me.
Killing the process wont work as it's restarted automatically, so I had to look a little deeper.
The secret is in
/Library/Preferences/NetSupport/NetSupportManager
There are 2 files:
ns-login.sh
ns-logout.sh
In the login file I just commented out the line where the monitoring process is started:
#${SESSIOND} "*" /s &
This stops the client from being started, and restarted. The Netsupport Manger still works, ie connects and Controls other machines, but I dont have the Client eating 10% of my CPU now.
I did have an issue however, on the Mac, I just wanted to install the Netsupport Manager, ie I just wanted to control other machines, and not be controlled. During the installation there didn't seem to be any options to not install the client, but as I checked the 'control and manage only' option (or words to that effect) and assumed the client wouldn't be installed.
Not only was the client installed, but when the machine is idle. The Netsupport Client processing is running, and taking up about 8-10% CPU all the time. As I have a reasonably decent machine (OS X 10.9.3, 2.3GHz i7, 16GB RAM) this CPU use is hardly noticeable, but it really bugged me.
Killing the process wont work as it's restarted automatically, so I had to look a little deeper.
The secret is in
/Library/Preferences/NetSupport/NetSupportManager
There are 2 files:
ns-login.sh
ns-logout.sh
In the login file I just commented out the line where the monitoring process is started:
#${SESSIOND} "*" /s &
This stops the client from being started, and restarted. The Netsupport Manger still works, ie connects and Controls other machines, but I dont have the Client eating 10% of my CPU now.
16 April 2014
MySQL Disable Foreign Key Checks
What and Why
Here are some test results regarding foreign key checks in mysql, and what actually happens to the data, when you change the relation type, eg CASCADE, SET NULL, RESTRICT, and NO ACTION.
I basically want to check whether foreign keys are processed on the table after the key checks are reenabled, or they are ignored completely, or if there is some other vooodoo that happens.
Method
I setup 2 Tables, T1 and T2, T1 has a primary key (id) and T2 has a foreign key (ref) which points to T1.id.
For the test I just did updates to the id in T1, and deleted a row in T1, and watched what happened to the data in T2, for each of the FK relations types.
The code used to disable the foreign key checks is:
SET foreign_key_checks = 0;
-- UPDATE `test1` set id=13 where id = 3;
DELETE FROM `test1` WHERE id = 3;
SET foreign_key_checks = 1;
I commented out the delete or update line as appropriate.
and then reset the tables after each test.
Results
Normal Operation
================
CASCADE on update = both records updated
CASCADE on delete = both records deleted
SET NULL on delete = row deleted and ref set to null
SET NULL on update = row updated and ref set to null
RESTRICT on delete = delete prevented
RESTRICT on update = update prevented
NO ACTION on update = update prevented
NO ACTION on delete = delete prevented
Disable FK Checks
=================
CASCADE on update = row updated and leaves dangling ref
CASCADE on delete = row deleted and leaves dangling ref
SET NULL on update = row updated and leaves dangling ref
SET NULL on delete = row deleted and leaves dangling ref
RESTRICT on update = row updated and leaves dangling ref
RESTRICT on delete = row deleted and leaves dangling ref
NO ACTION on update = row updated and leaves dangling ref
NO ACTION on delete = row deleted and leaves dangling ref
Conclusion
The most obvious conclusion, is that disabling foreign key checks as a part of the update or delete process can leave invalid foreign keys in the database. While there might be good reasons for doing this, the chance that the data will be left in an inconsistent state is very high.
13 June 2012
OpenEMM with SELinux
We have OpenEMM installed on a CentOS 6 VM.
Emails could be sent fine, but bounce management wasn't working, and worse, it was breaking sendmail as no local mails were getting through. ie root@localhost would not be delivered.
Looking in /var/log/maillog I got this error:
Jun 13 12:00:41 news sendmail[7711]: q5DB0fF9007711: Milter (bav): error connecting to filter: Permission denied
Jun 13 12:00:41 news sendmail[7711]: q5DB0fF9007711: Milter (bav): to error state
Jun 13 12:00:41 news sendmail[7711]: q5DB0fF9007711: Milter: initialization failed, temp failing commands
I guessed that the problem was the connection to the bav filter. In the sendmail.mc the input mail filter lines points to the bav.sock file:
INPUT_MAIL_FILTER(`bav', `S=unix:/home/openemm/var/run/bav.sock, F=T')dnl
The permissions on the bav.sock file were 0775, so at first I tried changing this to 777, but that had no effect at all. Then I hit upon the problem.
THE PROBLEM: SE Linux was enabled, and prevented sendmail talking to the bav filter.
This can be seen in the /var/log/audit/audit.log:
type=AVC msg=audit(1339590098.672:140014): avc: denied { connectto } for pid=8178 comm="sendmail" path="/home/openemm/var/run/bav.sock" scontext=unconfined_u:system_r:sendmail_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=unix_stream_socket
type=SYSCALL msg=audit(1339590098.672:140014): arch=c000003e syscall=42 success=no exit=-13 a0=5 a1=7fff2fdcd6d0 a2=6e a3=7fff2fdcd3e0 items=0 ppid=7697 pid=8178 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=51 sgid=51 fsgid=51 tty=(none) ses=10525 comm="sendmail" exe="/usr/sbin/sendmail.sendmail" subj=unconfined_u:system_r:sendmail_t:s0 key=(null)
Sendmail was making a request to the bav.sock unix socket, which was being blocked by SELinux, with the result that all incoming emails were being qeueued up, and never being processed. I proved this by disabling the bav filter in selinux.mc, and I got a flood of incoming mail....
One suggestion I came across was to disable SELinux, which lets face it, really isn't a solution.
THE SOLUTION: I had to create and install an SELinux module to enable this connection.
First I had to install the policycoreutils, this includes the all important audit2allow utility.
yum install policycoreutils-python
Then run the command:
grep sendmail_t /var/log/audit/audit.log | audit2allow -M openemm
This creates 2 files openemm.pp, and openemm.te.
The contents of openemm.te are
module openemm 1.0;
require {
type sendmail_t;
type unconfined_t;
type initrc_t;
class unix_stream_socket connectto;
}
#============= sendmail_t ==============
allow sendmail_t initrc_t:unix_stream_socket connectto;
allow sendmail_t unconfined_t:unix_stream_socket connectto;
This I guess allows sendmail to connect to a unix socket.
Then I ran the following command to install the module. (make sure you add the .pp extension)
semodule -i openemm.pp
After this everything started working as expected
Update Sept 2012:
Everything still doesn't work as expected, such is life. Bounce management requires procmail working, and procmail was having issues running the bav process. I was getting the following error in sendmail:
/home/openemm/bin/scripts/scan_and_unsubscribe: cannot execute binary file
However running the audit2allow again specifying procmail_t, and make sure the output file is procmail2 as procmail already exists as a module.
Useful article on selinux configuration: http://omotech.com/blog/?p=196
Update April 2014:
After another CentOS update SELinux decided to block access to the sendmail folders in the openemm home directory. So we had to jump through the audit hoops to get it working again. This time I combined my previous policy attempts for sendmail/openemm into a single file, compiled the pp file, and upgraded the existing policy.
Here is my latest policy file:
module openemm 4;
require {
type unconfined_t;
type initrc_t;
type sendmail_t;
type setfiles_t;
type ptmx_t;
type home_root_t;
type user_tmp_t;
type user_home_t;
type user_home_dir_t;
class sock_file { getattr read write };
class dir { read write getattr remove_name add_name };
class file { rename open create read write getattr lock unlink };
class lnk_file { read write getattr };
class chr_file { read write getattr };
class unix_stream_socket connectto;
}
#============ setfiles_t ==============
allow setfiles_t ptmx_t:chr_file { read write getattr };
#============= sendmail_t ==============
allow sendmail_t initrc_t:unix_stream_socket connectto;
allow sendmail_t unconfined_t:unix_stream_socket connectto;
allow sendmail_t ptmx_t:chr_file { read write getattr };
allow sendmail_t user_home_dir_t:dir { read write getattr remove_name add_name };
allow sendmail_t user_home_dir_t:file { write getattr read lock unlink open rename create };
allow sendmail_t user_home_dir_t:sock_file { read write getattr };
allow sendmail_t user_home_dir_t:lnk_file { read write getattr };
allow sendmail_t user_home_t:dir { read write getattr remove_name add_name };
allow sendmail_t user_home_t:file { write getattr read lock unlink open rename create };
allow sendmail_t user_home_t:sock_file { read write getattr };
allow sendmail_t user_home_t:lnk_file { read write getattr };
allow sendmail_t user_tmp_t:dir { read write getattr remove_name add_name };
allow sendmail_t user_tmp_t:file { write getattr read lock unlink open rename create };
allow sendmail_t user_tmp_t:sock_file { read write getattr };
I have also created a script file to compile the policy file:
#!/bin/bash
rm openemm.mod
rm openemm.pp
checkmodule -M -m -o openemm.mod openemm.te
semodule_package -m openemm.mod -o openemm.pp
Running the script file creates the openemm.pp file from the openemm.te file. Provided you change the version number at the top of the policy file (the line saying: module openemm 2.1;) rather than installing another policy it is possible to upgrade the existing policy, with the command:
semodule -u openemm.pp
Useful article on compling polices: melikedev.com
semodule command on Fedora: semodule
Update April 2018:
This has now been updated for OpenEMM 2015 R3,
It has also been added to github
Also its worth noting that sometimes the SELinux context of the files can get all messed up, and the module above doesn't work. When I upgraded, I first extracted the files to the /tmp folder, which then gave all the files an SE context of usr_tmp_t:
To show all the file security contexts do:
# ls -Z
If you go to /home, and issue the command:
#restorecon openemm
This will reset the security context of the openemm files, back to what they ought to be, i.e. user_home_t and life will be sweeter again.
30 April 2012
MYSQL update and select at the same time (almost)
How
You have to update to a variable then select the value of the variable.update `datatable` set `rate` := @a := (`rate` + 2);
select @a as `index`;
(Note you have to use the funky := operator, which means this is really definitely an assignment operation)
But why do it like this?
This allows you an atomic operation, updating a column, and returning the value at the same time, without using table locking. Apparently the update operation is atomic, so provided the database connection is not shared @a will not be overwritten.13 March 2012
Apache "AllowOverride None" confusion
Background
We had a situation where, there was a Apache Server with virtual hosts configured, one of the virtual hosts was located at
eg. /var/www/mysite
Under there was another media folder called media.
/var/www/mysite/media
I wanted to serve the media as a separate virtual host. The basic configuration was easy enough, just create a separate symlinked virtual host configuration file in /etc/apache2/sites-enabled for the new media site.
What went wrong
Everything seemed to work fine if the files (jpgs) were found in the media folder they were returned to the client as expected, however if a file was missing the server was generating server redirection errors, instead of 404s.
This was causing me to tear my hair out. Why redirection errors? There was no .htaccess file in the media folder, and in the directory section in the virtual host configuration "AllowOverride None" was set. So I was reasonably expecting that no .htaccess file would be processed for this virtual host, and as there wasn't one in the media folder anyway, I couldn't understand which rules was it processing to end up with redirection errors.
What was really happening
AllowOverride None meant that no .htacces directives in the media folder were being applied, but because there was an .htaccess in the parent folder for the site virtual host, those rules were being applied instead, which is where the redirect rules were located causing the redirect fail.
How to fix
Adding another directory section to the virtual host config did the trick, this prevented the parent .htaccess file from being processed.
*angle brackets changed because of blogger
(If you want to be really restrictive you should add "Deny from all" in there too, just make sure you add "Allow from all" in your home directory section )
Why the fix works
.htaccess files are processed from the current folder to the parent folder and all the way up to the root folder (of the disk!). Setting "AllowOverride None" on /var/www/mysite/media meant that in the media folder and down, no .htacces files are processed, but they still inherit from the parent folders.
Setting the AllowOverride None on the root folder meant that no .htaccess files are processed except those in the folders that I explicitly allow.
We had a situation where, there was a Apache Server with virtual hosts configured, one of the virtual hosts was located at
eg. /var/www/mysite
Under there was another media folder called media.
/var/www/mysite/media
I wanted to serve the media as a separate virtual host. The basic configuration was easy enough, just create a separate symlinked virtual host configuration file in /etc/apache2/sites-enabled for the new media site.
What went wrong
Everything seemed to work fine if the files (jpgs) were found in the media folder they were returned to the client as expected, however if a file was missing the server was generating server redirection errors, instead of 404s.
This was causing me to tear my hair out. Why redirection errors? There was no .htaccess file in the media folder, and in the directory section in the virtual host configuration "AllowOverride None" was set. So I was reasonably expecting that no .htaccess file would be processed for this virtual host, and as there wasn't one in the media folder anyway, I couldn't understand which rules was it processing to end up with redirection errors.
What was really happening
AllowOverride None meant that no .htacces directives in the media folder were being applied, but because there was an .htaccess in the parent folder for the site virtual host, those rules were being applied instead, which is where the redirect rules were located causing the redirect fail.
How to fix
Adding another directory section to the virtual host config did the trick, this prevented the parent .htaccess file from being processed.
[Directory /] AllowOverride None
Options None [/Directory]
*angle brackets changed because of blogger
(If you want to be really restrictive you should add "Deny from all" in there too, just make sure you add "Allow from all" in your home directory section )
Why the fix works
.htaccess files are processed from the current folder to the parent folder and all the way up to the root folder (of the disk!). Setting "AllowOverride None" on /var/www/mysite/media meant that in the media folder and down, no .htacces files are processed, but they still inherit from the parent folders.
Setting the AllowOverride None on the root folder meant that no .htaccess files are processed except those in the folders that I explicitly allow.
01 March 2011
Magento
Some say its a Great CMS for eCommerce applications.
I say it's a complicated, over-engineered, undocumented, stress inducing monster from the pit.
grrr
11 August 2009
I Hate EMACS
EMACS is a text editor, that's about all I know about it. Today I was using subversion source control in OSX. I did a simple commit, and bang, up pops emacs wanting to type a commit message. I didn't know it was emacs at the time, it was just some kind of editor. I didn't need a (useful?) comment, so I just wanted to quit. That's when I got annoyed. I thought that Microsoft had the monopoly on computer annoyance nowadays, but how wrong I was. All I wanted to do was quit, close the program, return to the command line.... How ******** difficult can it be to quit a program. Ctrl-C, Ctrl-X, Ctrl-Z, Escape, Alt-C, Alt-X, Alt-Z, Cmd Q, Cmd C, Cmd Z, F1, F2, F3, etc. Escape, Escape, Escape, aarrrgh.
There is a menu bar, but I cant access any of the options, occasionally the cursor moves, but I don't know why. Finally I somehow hit a random selection of keys that meant the thing quit, but I had to type 'yes' instead of just hitting 'y' to confirm that i didn't care that the text was about to be unsaved and thus heading for damnation.
WTF! Is it still 1978?
I appreciate that emacs has a long and historic pedigree, similar to vi(m). I understand that power users don't want to touch that new fangled mouse aberration that is attached to the machine. I understand that text only interfaces are the true and only way to computer nirvana.
In this day and age, there is NO reason to have SUCH a confusing and impossible to understand interface. Some might say it ain't broke, so there is no need to fix it. I would say it IS broke, very very badly.
It's not that I can't learn to use emacs, or just 'rtfm', it's just the annoyance that when I get into the program by mistake, there are no helpful or easy hints how to get out of the program, and it is inconsistent with most others editor out there.
All it needs to do is when someone hits ctrl-c is to say 'Quit without saving? y/n', I tap 'y', and the program quits. Fast, easy, efficient, and consistent.
/rant over
14 July 2009
Inkscape Drop Shadow Using Filters
I like Inkscape. It's a great free program for vector graphics, but it can be a bit confusing at times to do certain things. Like the ubiquitous drop shadow. It ought to be as easy as clicking a button to apply a drop shadow to an image, but alas things are rarely that simple unless you are using a mac, but thats a post for another day.
So how do we do drop shadows in inkscape?
The easy way is to use a duplicate object. So start by creating an object, I just created some text and coloured it red:

Then duplicate that object, Edit -> Duplicate, or Ctrl-D:

Using the fill and stroke options, change the colour to a nice mid tone grey with a bit of transparency:

Use 'pagedown' or the 'lower' icon, to drop the grey text below the red text, and use the magical gaussian blur slider in the fill and stroke options to give us a nice hazy shadow:

Using a little repositioning we get a nice shadow:

But what happens if we need to change the text or if there is a typo? Its a bit of a pain to go through the whole process again, just to reproduce the same effect.

There is a better way using filters
Start with your text object again, then bring up the filters dialog (Object ->Filter Effects), its a bit weird and confusing at first, so we'll go through it step by step. On the left is a list of filters, in the middle are the effects that make up that filter, and on the right are the possible 'input sources' for the effects. At the bottom are the parameters for a particular effect.

Lets create a new filter, click the new button, a new filter will be created, right click and rename it to something more memorable, e.g 'drop shadow'.

Now select the gaussian blur filter from the effects selection list, and click add effect. That was easy, we created our first filter, but we can achieve the same thing using the blur slider in the fill and stroke options panel, but we can do so much more with filters, because we can combine them to produce better and more complicated effects.

There is a line connecting the gaussian blur effect to the 'source graphic' input. In this tutorial we are only concerned with the source graphic and source alpha inputs. With only one effect the source of the blur cannot be changed.
If the text object is selected, then checking the box next to the drop shadow filter will enable or disable the gaussian blur filter on the text.
Ok, we have blurred text, but thats not what we want, we want a shadow, so from the effects list select the 'merge effect', and click add:

Now we have a blur effect and a merge effect, but the text hasn't changed. This is because we need to 'wire up' the inputs of each effect. Attached to each effect is a little triangle, pointing at the text, if you hover the mouse over this triangle you will see it changes colour, indicating it is selectable. If you click and drag on this triangle, a line is drawn to the mouse cursor. This allows you to link the effect with either a different 'input' or another effect. If you click and drag the triangle on the blur effect and 'drop' the line on the 'source alpha' input column, the text will turn fuzzy black, indicating that the gaussian blur is affecting the alpha channel of the text instead of the text itself.

Now we need to wire up the merge effect. Drag the arrow from the merge effect and drop it on the gaussian blur. A little angled line should link the two effects, and a new triangle should appear on the merge effect, drag this second triangle to the 'Source Graphic' input column on the right.

We should now have some red text with a hazy black shadow! This is much better. We can edit the text and the shadow adjusts with the text as it changes. The shadow can be turned on an off with the checkbox next to the filter name. This same filter can be applied to other objects on the page. So if we have any other text or objects on the page, select them and check the drop shadow filter, and hey presto they have shadows too.
But the drop shadow is still not quite right, it needs to be offset from the text, and I want it to be transparent grey not black. To achieve this we need add more effects into the filter. Moving the shadow is easy.
Select the 'Offset' effect, and click 'add effect'. Change the Delta X and Delta Y parameters to 5 pixels or however much you want to offset the shadow by. The offset effect is added at the bottom of the filter, and takes the merge effect as an input, so the result of the merge, ie. the whole graphic, is offset. This is not what we want, we only want to offset the blur.

First, drag the offset effect from the bottom and drop it just underneath the blur, the order of the effects should now be changed, but the connections are messed up.

Drag the connection that goes from the merge effect to the blur effect, and drop it on the offset effect instead, et voila, just the blur is shifted, giving us a nice offset shadow effect.

The shadow is still the wrong colour though. At this stage it seems logical to add the 'Color Matrix' filter to change the colour of the shadow, unfortunately there a 2 problems with this, the first one is that the color matrix filter doesn't have a colorize with alpha option, and second, I cant understand how to use the matrix option as it's too complicated, and I'm not a maths guru. So instead we can use 2 other filters to make the process easier.
Add the 'Flood Filter' and set its colour and alpha values as required, the input will default to the 'Source Graphic', leave this alone. Next add a 'Composite' filter and set its operator to 'In', select the Flood filter as its first input, then the 'Source Graphic' as its second input, then feed this into the blur then offset effects, then finally merge with the source graphic.

Finally we have a drop shadow that can be enabled by the click of a button, and it doesn't matter if we need to change the text or modify the object shape.
If we have an object on the page which requires a different kind of shadow, the easiest thing is to right click on the filter name to duplicate it, rename it eg 'drop shadow 2', modify the settings as appropriate, then apply the second filter to the new object.
The only drawback with these filters is that it isn't possible to save the filter, which is a shame, as there could be a list of predefined filters which could be reused.
So how do we do drop shadows in inkscape?
The easy way is to use a duplicate object. So start by creating an object, I just created some text and coloured it red:

Then duplicate that object, Edit -> Duplicate, or Ctrl-D:

Using the fill and stroke options, change the colour to a nice mid tone grey with a bit of transparency:

Use 'pagedown' or the 'lower' icon, to drop the grey text below the red text, and use the magical gaussian blur slider in the fill and stroke options to give us a nice hazy shadow:

Using a little repositioning we get a nice shadow:

But what happens if we need to change the text or if there is a typo? Its a bit of a pain to go through the whole process again, just to reproduce the same effect.

There is a better way using filters
Start with your text object again, then bring up the filters dialog (Object ->Filter Effects), its a bit weird and confusing at first, so we'll go through it step by step. On the left is a list of filters, in the middle are the effects that make up that filter, and on the right are the possible 'input sources' for the effects. At the bottom are the parameters for a particular effect.

Lets create a new filter, click the new button, a new filter will be created, right click and rename it to something more memorable, e.g 'drop shadow'.

Now select the gaussian blur filter from the effects selection list, and click add effect. That was easy, we created our first filter, but we can achieve the same thing using the blur slider in the fill and stroke options panel, but we can do so much more with filters, because we can combine them to produce better and more complicated effects.

There is a line connecting the gaussian blur effect to the 'source graphic' input. In this tutorial we are only concerned with the source graphic and source alpha inputs. With only one effect the source of the blur cannot be changed.
If the text object is selected, then checking the box next to the drop shadow filter will enable or disable the gaussian blur filter on the text.
Ok, we have blurred text, but thats not what we want, we want a shadow, so from the effects list select the 'merge effect', and click add:

Now we have a blur effect and a merge effect, but the text hasn't changed. This is because we need to 'wire up' the inputs of each effect. Attached to each effect is a little triangle, pointing at the text, if you hover the mouse over this triangle you will see it changes colour, indicating it is selectable. If you click and drag on this triangle, a line is drawn to the mouse cursor. This allows you to link the effect with either a different 'input' or another effect. If you click and drag the triangle on the blur effect and 'drop' the line on the 'source alpha' input column, the text will turn fuzzy black, indicating that the gaussian blur is affecting the alpha channel of the text instead of the text itself.

Now we need to wire up the merge effect. Drag the arrow from the merge effect and drop it on the gaussian blur. A little angled line should link the two effects, and a new triangle should appear on the merge effect, drag this second triangle to the 'Source Graphic' input column on the right.

We should now have some red text with a hazy black shadow! This is much better. We can edit the text and the shadow adjusts with the text as it changes. The shadow can be turned on an off with the checkbox next to the filter name. This same filter can be applied to other objects on the page. So if we have any other text or objects on the page, select them and check the drop shadow filter, and hey presto they have shadows too.
But the drop shadow is still not quite right, it needs to be offset from the text, and I want it to be transparent grey not black. To achieve this we need add more effects into the filter. Moving the shadow is easy.
Select the 'Offset' effect, and click 'add effect'. Change the Delta X and Delta Y parameters to 5 pixels or however much you want to offset the shadow by. The offset effect is added at the bottom of the filter, and takes the merge effect as an input, so the result of the merge, ie. the whole graphic, is offset. This is not what we want, we only want to offset the blur.

First, drag the offset effect from the bottom and drop it just underneath the blur, the order of the effects should now be changed, but the connections are messed up.

Drag the connection that goes from the merge effect to the blur effect, and drop it on the offset effect instead, et voila, just the blur is shifted, giving us a nice offset shadow effect.

The shadow is still the wrong colour though. At this stage it seems logical to add the 'Color Matrix' filter to change the colour of the shadow, unfortunately there a 2 problems with this, the first one is that the color matrix filter doesn't have a colorize with alpha option, and second, I cant understand how to use the matrix option as it's too complicated, and I'm not a maths guru. So instead we can use 2 other filters to make the process easier.
Add the 'Flood Filter' and set its colour and alpha values as required, the input will default to the 'Source Graphic', leave this alone. Next add a 'Composite' filter and set its operator to 'In', select the Flood filter as its first input, then the 'Source Graphic' as its second input, then feed this into the blur then offset effects, then finally merge with the source graphic.

Finally we have a drop shadow that can be enabled by the click of a button, and it doesn't matter if we need to change the text or modify the object shape.
If we have an object on the page which requires a different kind of shadow, the easiest thing is to right click on the filter name to duplicate it, rename it eg 'drop shadow 2', modify the settings as appropriate, then apply the second filter to the new object.
The only drawback with these filters is that it isn't possible to save the filter, which is a shame, as there could be a list of predefined filters which could be reused.
Update: Actually you can save the filter as a custom one. Check out Elaine's comment below.
08 August 2007
The Manga Bible.
This is just awesome:
The Manga Bible
I saw one of these at Soul Survivour this year, and it was brilliantly done. Bringing the bible to life in a new and exciting way, easily accessible for kids of all ages.
The Manga Bible
I saw one of these at Soul Survivour this year, and it was brilliantly done. Bringing the bible to life in a new and exciting way, easily accessible for kids of all ages.
18 July 2007
Man-Made global warming is now a real again
There is a very interesting film on google video, which is a response to the Great Global Warming Swindle. It takes apart the film, bit by bit, and analyses what is being said, and the data they are using.
Great Global Warming Response
Basically the response states that although the earths climate has fluctuated over the past millenia, with corresponding variations in CO2; Recent human activity in the past 100 Years has created "the greenhouse effect", which has forced temperature change independently of processes which have gone on for the past million years.
Great Global Warming Response
Basically the response states that although the earths climate has fluctuated over the past millenia, with corresponding variations in CO2; Recent human activity in the past 100 Years has created "the greenhouse effect", which has forced temperature change independently of processes which have gone on for the past million years.
10 July 2007
Computers Suck
I love this
http://www.youtube.com/watch?v=Id_kGL3M5Cg
http://www.youtube.com/watch?v=Id_kGL3M5Cg
14 May 2007
Blender 3D
Woohoo, Blender 2.44 has been released with SSS (Sub Surface Scattering). This is just an awesome program, but it isnt for the feint hearted. It does take a while to learn how to use it properly.
To say blender is a 3D modelling program is to demean it by an order of magnitude. Yes it does 3D modelling, and it also does video compositing, and audio editing, video editing and 3D game creation. It is a multimedia powerhouse application. How much does it cost? Nothing. It's free. Just download, install and run it.
It runs on MS OS, Mac OS, and Linux, and it looks the same on all of them. If you can use it on one platform it works on all the others too. So it needs a super-computer to run on then? No, it runs on the humblest of machines, quite adeqately, Although having more horse-power does improve render times.
Its a fine example of how well thought out, well written software does a great job. Compare and contrast with MS Bloatware.
Where can I get it?
Here: Blender 3D Website
To say blender is a 3D modelling program is to demean it by an order of magnitude. Yes it does 3D modelling, and it also does video compositing, and audio editing, video editing and 3D game creation. It is a multimedia powerhouse application. How much does it cost? Nothing. It's free. Just download, install and run it.
It runs on MS OS, Mac OS, and Linux, and it looks the same on all of them. If you can use it on one platform it works on all the others too. So it needs a super-computer to run on then? No, it runs on the humblest of machines, quite adeqately, Although having more horse-power does improve render times.
Its a fine example of how well thought out, well written software does a great job. Compare and contrast with MS Bloatware.
Where can I get it?
Here: Blender 3D Website
03 May 2007
Man-made global warming isnt real apparently
I just watched a programme, first broadcast on Channel 4 (UK), claiming that man-made global warming isnt real. I must admit i'm pretty convinced. It's also available on google video
28 April 2007
Car Thief Keith
Car Thief Keith vidoes produced by Avon and Somerset Police.....
Where can I get an Atomic Plasma Cannon?
Where can I get an Atomic Plasma Cannon?
01 December 2006
God Jockey
While randomly browsing on the internet, as one does I came across an article on a blog which used the term God Jockey, for the guy at the front of church. It made me chuckle it did. Here's an extract:
"So I was rather surprised that the current priest made the hour long service fly-by — at one point I did actually check the clock to see if I’d really been there an hour. The resident GJ (God-Jockey) Fr Manock should be praised for the upbeat manner in which he puts across God’s message, especially his use of song during the service"
The Full Article
"So I was rather surprised that the current priest made the hour long service fly-by — at one point I did actually check the clock to see if I’d really been there an hour. The resident GJ (God-Jockey) Fr Manock should be praised for the upbeat manner in which he puts across God’s message, especially his use of song during the service"
The Full Article
Subscribe to:
Posts (Atom)