the fade anything technique

[problem]

You want to add something flash to your site.
A color loads, which you then want to change

[/problem]

[solution]

Well cool “Fade Anything Technique”!

Really simple implementation, just copy fade anything>%20fade%20anything%20fat.js%20< and then any divs, etc with an id
of fade-xxx will fade from that color. Many more options, check out these highly recommended articles.

[/solution]

[example]


<head>
...
<script type="text/javascript" src="/fat.js">
</head>
...
<div style="width: 600px; border:1px dashed #23932B; padding: 10px;" id="fade-23932B" class="fade-23932B">
...
</div>

[/example]

[reference]

Check out the article hosted by axentric, written by Adam Michela

It was inspired by 37 signals

[/reference]

Troubleshoot Apache Startup

[problem]

Here are a few tips, if you are having problems starting apache.

1. A common problem is trying to start Apache on a restricted port. This is where you configure apache to listen on port 80, changing the default 8080.

2. Another problem can be defining logging into directories that don’t exist.

3. If you get an error like User not allowed, or Group not recognized, etc – this is the User and Group statements within your apache configs.

[/problem]

[solution]

1. On UNIX this is considered restricted and generally only available to the root user. On windows it is also commonly restricted, so requires an admin account.

2. This will generally output an error along those lines, into apache’s top level error log. Failing that you can try running apache with truss (search my site to find syntax) on Solaris, strace on Linux and trace on AIX.

3. You need to change to match the user running the command – or if root, the delegated user and group user is in.

Another tip is to run /etc/init.d/httpd configtest – which will effectively run httpd -t to syntax check the config. You can also perform a -S which checks and prints your virtual hosts.

If you getting compliants about modules, try running httpd -l to see compile in mods.

[/solution]

[example]

Nothing here – please see Solution 🙂

[/example]

[reference]

[tags]apache, Unix Coding School[/tags]

[/reference]

epoch generation and converting

[problem]

You want to generate the current epoch offset for UNIX. The count forward since 8am on 1st Jan 1970.

Or conversely you want to see the date and time, for a given epoch offset.

[/problem]

[solution]

You can use perl’s mktime or localtime – or just use my tools below.

[/solution]

[example]

Either enter epoch:

Or enter the date (plus time)

day month year

— select day —
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

— select month —
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec

— select year —
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049

hr mins secs

— select hour —
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23

— select mins —
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

— select secs —
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

epoch offset or date will appear here

[/example]

[reference]

[tags]epoch, unix, 2038[/tags]

  1. techno park epoch year 2038 problem

[/reference]

Vertical label creation

[problem]

You want to generate a vertical image, with text over the top.

[/problem]

[solution]

Here is some code I wrote, which is used extensively on my sites:

  

[/solution]

[reference]

Give it a blast on this site, like this: http://coding-school.com/common/label-up.php?label=your+text+here

Automatically calculates size required. You can also add font=# – where # is 1 to 5, like this:

http://coding-school.com/common/label-up.php?label=your+text+here&font=3

I’ve now created an online tool, using this code

[/reference]

[tags]Image, PHP[/tags]

libcurl lookup taking long time

[problem]

You notice for some hosts curl and/or libcurl are taking 7 or so secs to lookup the host. But nslookup or dig respond almost immediately.

[/problem]

[solution]

Try doing curl -4 -w “time_namelookup: %{time_namelookup}n” …. and try without the -4. If you see drastic differences, you could be falling foul of the IPV6 bug. To work around this, you can either just use -4 with curl or set CURLOPT_IPRESOLVE with libcurl.

[/solution]

[example]

I spents hours and hours and hours, trying to get this working with libcurl and perl. It turned out I need to upgrade to WWW::Curl::Easy version 3.0 – as opposed to version 2. Do a search on search.cpan.org for Curl and it will tell you how to check your version.

Then if you like me upgrade, you need to also modify all your code from: Curl::easy::setopt($curl, … to $curl->setopt( …

[/example]

[tags]libcurl, resolve, namelookup[/tags]

10 simple techie tips for lazy people

[problem]

Don’t know about you, but I’m generally quite lazy. Why roll the mouse and click the screen,
when with a quick control c I can copy some text. 🙂

[/problem]

[solution]

Learn 10 simple short cuts, which can save you hours.

[/solution]

[example]

1.

Copy some text – select it then control c
Now it is in the clipboard.

2.

Click where you want to paste it and control v to paste it. 😉

You can also right click with your mouse to cut and paste.

3.

Minimise all windows, by holding down the windows key and press m

4.

Kick off explorer, by holding down windows key and press e

5.

Do a find by holding down windows key and press f

6.

Switch between windows by holding down alt and pressing tab

7.

Reverse tab through a HTML form, by holding down the shift key.

8.

Open a web link in a new window, by holding down shift and clicking it

9.

To type in a new web address, hold down alt and press d

10.

Save a document with control s, print it with control p, undo a change with control z – sorry got carry away. 🙂

[/example]

HTTP Basic Auth with HTTP headers and libcurl

[problem]

Came across an interesting problem with curl.

For curl to perform HTTP Basic Authentication, it is easy to pass –user to the curl command, but harder with libcurl.

Suspect there is an attribute that can be set, but I monitor a multitude of web sites through some perl scripts and libcurl. I did n’t want to have to modify my wrapper scripts, which mesh perl hashes with the code that drives curl (via libcurl).

I do allow for headers though, having needed to pass different things through, like HTTP_REFERER, LAST_MODIFIED, etc.

Therefore I just needed to pass the HTTP BASIC Authentication through as a header.

[/problem]

[solution]

First off you need to base64 encode the user and password.

Use Google’s tool

[/solution]

[example]

We then strip out the equals and pass following through to curl or libcurl:

 @myheaders=('Authorization: Basic YWRtaW46YWRtaW4');  Curl::easy::setopt($curl, Curl::easy::CURLOPT_HTTPHEADER, @myheaders); 

Or from the command line:

 curl ... -H'Authorization: Basic YWRtaW46YWRtaW4' 

Obviously you need to put your user, followed by a colon and your password – to obtain the correct base64 encoding back – strip the equals out and away you go.

[/example]

Simple Basic Encryption – Main differences between algorithms

[reference]

Symmetric Algo – one key to encrypt and decrypt.

Asymmetric Algo – separate key to encrypt and decrypt.

Stream ciphers – encrypt each bit in sequence.

Block ciphers – encrypt specific blocks of bits.

Hash/Message Digests – one way ciphers, create fingerprints of data.

[/reference]