Wednesday, October 20, 2010
Wednesday, October 13, 2010
Drop down menus live from mySQL using CSS
I was preparing to entire the hazy horrible world of Java script to provide
event links from the navigation toolbar. And then! Bing! Why not use CSS? And it
works. Super. Click on the annoying advert below to take a gander …
--
My Emacs Files At GitHub
Monday, October 11, 2010
Finally : a good pop up translator for FireFox
I can't believe I missed this bad boy before.
Babel Translator will pop up word translations, select translations etc. Highly
customisable. Superb.
--
My Emacs Files At GitHub
Monday, October 4, 2010
Google Sitemap Generator
SiteMaps seems to be another way to optimsie google ratings. The link talks about googles own sitempa generator.
A site which claims to generate free sitemaps is XMLSiteMaps.
--
My Emacs Files At GitHub
Emacs 23, the emacs daemon and emacsclient
A recent entry to planetemacsen reminded me of a wiki entry added a good while
back which complements, or even supercedes, other methods of starting the emacs
daemon. There are a lot of solutions for running the emacs daemon when not
already running and/or using the emacsclient. I find the following solution
most convenient since there is no need to specifically start the server yourself
at any stage - it makes use of the alternate-editor option. Create a small
script and place it somewhere on your path.
#!/bin/bash
# edit
exec emacsclient --alternate-editor="" -c "$@"
The ="" is the key. This tells the emacsclient code to start the daemon and then
call itself if its not already running.
The wiki entry tells you more and describes the use of the EDITOR env variable.
--
My Emacs Files At GitHub
Sunday, October 3, 2010
Fuzzy Search In Emacs
fuzzy.el provides a super fuzzy search capacity. Save the code linked below to somewhere on your elisp path, add the two lines below to your .emacs and now C-s (isearch-forward) will become "fuzzy" after the first miss for the item you are searching for. You can customise the "fuzzy" group to change the fuzziness. This module is part of the superb auto-complete suite - recommended.
(require 'fuzzy)
(turn-on-fuzzy-isearch)
--
My Emacs Files At GitHub
Saturday, October 2, 2010
Steve Fairway Web up and running
The css opacity commands are pretty nice.
Anyway, pleae visit here Mr Google!
--
My Emacs Files At GitHub
Thursday, September 30, 2010
Emacs Session Management
(desktop-save-mode t) ; remember which files were open
(require 'midnight) ; Clear up unimportant buffers
(require 'savehist-20+)
(savehist-mode 1)
--
My Emacs Files At GitHub
Add command line option to use nognus instead of gnus
(add-to-list
'command-switch-alist
'("nognus" . (lambda (&rest ignore)
(add-to-list 'load-path "~/.emacs.d/nognus/lisp")
(message "NoGnus loaded")
(load "gnus-load") ;; Needed if using nognus.
;; Start Gnus when Emacs starts
(setq email-instance t))))
--
My Emacs Files At GitHub
Monday, September 27, 2010
Keep something called shush quiet
Resyncing my little network including the Pub machine, I realised that my ssh logins were too noisy. eg. I would
>ssh $PUB
to see the following unnecessary chatter
Linux thinkpadt60 2.6.32-5-686 #1 SMP Sat Sep 18 02:14:45 UTC 2010 i686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
No mail.
Last login: Mon Sep 27 19:16:11 2010 from development
The solution is very simple. On the remote machine simply create a .hushlogin file.
>touch ~/.hushlogin
If it doesnt work then check your /etc/login.defs file for the hush settings. Mine are like this:
# If defined, file which inhibits all the usual chatter during the login
# sequence. If a full pathname, then hushed mode will be enabled if the
# user's name or shell are found in the file. If not a full pathname, then
# hushed mode will be enabled if the file exists in the user's home directory.
#
HUSHLOGIN_FILE .hushlogin
#HUSHLOGIN_FILE /etc/hushlogins
--
My Emacs Files At GitHub
Sunday, September 26, 2010
NoGnus takes Gnus to the next level.
A popular objection to using Gnus was that its IMAP performance was
poor and its article counting simply rubbish. Not any more. Lars has
written pretty much a totally new back end for the imap portion of
gnus. Following an exchange of emails today it now works with my
dovecot set up which uses virtual users on the same dovecot server to
seperate different gmail accounts I sync with my local dovecot using
the excellent offlineimap. e.g The select name is passed as the server
name and each one has a corresponding .authinfo "machine" entry. e.g
(add-to-list 'gnus-secondary-select-methods
`(nnimap "riley"
(nnimap-address "offlineimap")
(nnir-search-engine imap)
(nnimap-stream network)
))
(add-to-list 'gnus-secondary-select-methods
`(nnimap "shamrockpub"
(nnimap-address "offlineimap")
(nnir-search-engine imap)
(nnimap-stream network)
))
(add-to-list 'gnus-secondary-select-methods
`(nnimap "friends"
(nnimap-address "offlineimap")
(nnir-search-engine imap)
(nnimap-stream network)
))
riley, friends and shamrockpub all have entries in .authinfo.gpg e.g
machine riley login riley password pass1
machine friends login friends password pass2
machine shamrockpub login shamrockpub password pass3
and these then, in turn, correspond to dovecot virtual users.
Group refresh is almost instant now. And article counts appear to be spot on.
You can grap nognus from here. Be sure to add it to you path and remember you need to
(load "gnus-load")
Grab it while its hot - I'm sure he would sooner get bug reports now
rather than months down the road when his mojo is depleted!
You can get nognus here.
My Emacs Files At GitHub
Thursday, September 23, 2010
Getting the repaired web server working.
Fun, fun, fun. So following the demise of Hermes I took him into the
local shop for a checkout. The motherboard had gone too. My face
showed my pain. The techy there suggested he could try and dig out a
new main board. a day later I get a call : he's up and running. Ok, a
bit of a Frankenstein but running. Then the fun begins. How tricky
would it be to get Hermes back online, Transfer all the mysql data and
web stuff I had worked on the past few days for some friends?
Surprisingly easy as it turned out. Firtly Hermes nest doesn't have a
monitor or keyboard so I took him over to my main desktop and borrowed
the monitor and keyboard. I booted Hermes into Debian Lenny without a
glitch. Damn no network. I had been expecting that. So
#ifconfig -a
shows me that it was eth2 I needed to configure. Then a quick edit of /etc/network/interfaces as follows
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth2
# The primary network interface
allow-hotplug eth2
iface eth2 inet static
address 192.168.0.101
gateway 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
dns-nameservers 192.168.0.1
Oh but wait. Hermes used to be a bind9 dns. It's hell to configure. Error prone and total overkill so ….
#sudo aptitude purge bind9
For my uses /etc/hosts will suffice. The its a case of seeing if we can obtain an ip address
#/etc/init.d/networking restart
#ifconfig -a
Success! So I shutdown Hermes, trundled him back to his nest, minus
keyboard and monitor, plugged him in, turned on the power and shazam!
A fully functional Debian Lenny apache/mysql server is up and
running. Total cost of repait including new second hand mainboard with
associated psul? 60 euro. Bargain.
For the rest of the configuration it was simply a case of using ssh login and scp.
--
My Emacs Files At GitHub
Trying gmap link type
Sebastian rose shows how to use google maps or open maps as link types.
Let see how it renders in a blog?
Subject: Yet another way to use maps --- the light way
From: Sebastian Rose <sebastian_rose@gmx.de>
Date: Thu, 23 Sep 2010 10:17:14 +0200
Hi,
there is a light and easy way to use google and openstreetmap.org maps
if you define them as a custom link type:
(setq org-link-abbrev-alist
'(("gmap"
. "http://maps.google.com/maps?q=%s")
("omap"
. "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")))
Now
[[gmap:Falkenstr 10, Hannover, Germany][Falkenstraße]]
and
[[omap:Falkenstr 10, Hannover, Germany]]
show a map in your browser. LaTeX and HTML export works out the box
with the advantage, that this export can legally be published on the
internet without any additional action (API license key). Even on
commercial sites, as it's just a link to google. OSM is no problem
anyway.
This way it's possible to show a certain place on earth, but not a track
or route.
There's a (known) bug in the LaTeX eporter:
[[Falkenstraße 10, Hannover, Germany]]
will _not_ work, because the german Umlaut will be distorted somehow
(unless fixed already....)
Sebastian
--
My Emacs Files At GitHub
Wednesday, September 22, 2010
Gaming Excellence
Every now and again you play a game which makes you sit up and gawk. Uncharted 2, along with Red Dead Redemption, is one such. The attention to detail, the physics, the texures, the sound, the story line and the mind boggingly massive length of the game make this a must have. You can watch a playthrough here. Finishing this game leaves with an aching desire for more. Not one time did I feel "been there done that". Astonishing.
--
My Emacs Files At GitHub
Monday, September 20, 2010
Disaster. It doesn't get worse.
The server is now at the doctors hopefully getting a new PSU. The outlook is bleak. Oh yes. Contempt? Yup. I hadn't checked the server cron jobs were correctly backing up things like the individial web servers mysql dbs. They weren't. Cron had decided to give up the ghost about a month ago it seems - mea culpa - I need to discipline myself to not trust this stuff as much as I have been.
The feeling of helplessness when booting a trusted debian desktop machine only to get the "X not loaded" BSOD and then having to wait 10 seconds after every bash command because of name resolution issues is really quite accute.
Fingers crossed that Hermes responds to treatment and that the good doctors at Level 1 can graft on a new PSU. It's an old P4 machine. A rock. A workhorse. And broken.
Sunday, September 19, 2010
If a setting is function call that else if true call a hardcoded default
(defun callSettingFunc (&rest t)
(when f
(let ((f (if (functionp f) ; check if its a valid function name.
f
'message))) ; use built in message function if not set to a function name
(apply f t))))
--
My Emacs Files At GitHub
Insert or split babel src block
2010-09-19 Sun
(define-key org-mode-map (kbd "C-c C-b") 'rgr/org-split-src)
(defun rgr/org-split-src(&optional arg)
(interactive "P")
(beginning-of-line)
((lambda(info)
(if info
(let ((pos (point))
(lang (nth 0 info))
(stars (make-string (org-current-level) ?*)))
(insert
(format
"%s\n%s \n#+begin_src %s\n%s#+end_src\n%s \n#+begin_src %s\n"
"#+end_src"
stars
lang
(if (region-active-p)
(delete-and-extract-region (region-beginning) (region-end)) "\n")
stars
lang))
(org-back-to-heading))
(insert
(format
"\n#+begin_src\n%s\n#+end_src\n"
(if (region-active-p)
(delete-and-extract-region (region-beginning) (region-end)) "")))))
(org-babel-get-src-block-info)))
--
My Emacs Files At GitHub
Saturday, September 18, 2010
Altering the style of source code snippets at blogspot
When editing your blog go to "design" and then edit your template. Add
the following to the end of CSS section.
pre.src {border: 1px solid rgb(187, 187, 187);
margin: 15px 5px;
padding: 5px;
background: rgb(238}\, 238, 238) none repeat scroll 0% 0%;
overflow: auto;
font-size: 130%;
-moz-background-clip: border;
-moz-background-origin: padding;
-moz-background-inline-policy: continuous;
}
Also see http://emacs-fu.blogspot.com/2010/05/using-zenburn-for-org-mode-generated.html
--
My Emacs Files At GitHub
Mark region as src code. If prefix used then create new org entry with the region marked as src.
(define-key org-mode-map (kbd "C-c C-b") '
(lambda()(interactive)
(let ((stars (make-string (org-current-level) ?*)))
(insert
(format
"%s%s \n#+begin_src emacs-lisp\n%s#+end_src\n%s"
(if current-prefix-arg "#+end_src\n\n") stars (delete-and-extract-region (region-beginning) (region-end)) (if current-prefix-arg (concat "\n" stars " \n#+begin_src emacs-lisp")))))))
--
My Emacs Files At GitHub
Reopen a buffer as root prompting for password if necessary
(defun find-alternative-file-with-sudo ()
"Open current buffer as root!"
(interactive)
(when buffer-file-name
(find-alternate-file
(concat "/sudo:root@localhost:"
buffer-file-name))))
(global-set-key (kbd "C-x C-r") 'find-alternative-file-with-sudo)
--
My Emacs Files At GitHub