I have been trying to show pretty code snippets on blogspot.com/blogger.com. I found for larger files github.com displays code nicely but not very handy for short inline examples. Today I discovered prettify by google
This post describes setting up code.google prettify on blogger.com
Originally explained here:
http://lukabloga.blogspot.com
Include this before the head tag in the blogger template.
I have made a modified version of the css file suitable for displaying code on darkbackgrounds, I use this instead:
Then change the body tag to:
Then use the prettyprint class when using pre tags around code:
Twitter Updates
Tuesday, 28 April 2009
Monday, 27 April 2009
Scite bash script config
in Scite the config for bash/shell scripts are handled by the perl.properties by default.
I believe this is the section of the config file which applies it to .sh file by default.
file.patterns.perl=*.pl;*.pm;*.cgi;*.pod
file.patterns.bash=*.sh;*.bsh;configure
shbang.perl=pl
shbang.sh=sh
filter.perl=Perl (pl pm)|$(file.patterns.perl)|
filter.bash=Bash (sh bsh)|$(file.patterns.bash)|
lexer.$(file.patterns.perl)=perl
lexer.$(file.patterns.bash)=bash
I believe this is the section of the config file which applies it to .sh file by default.
file.patterns.perl=*.pl;*.pm;*.cgi;*.pod
file.patterns.bash=*.sh;*.bsh;configure
shbang.perl=pl
shbang.sh=sh
filter.perl=Perl (pl pm)|$(file.patterns.perl)|
filter.bash=Bash (sh bsh)|$(file.patterns.bash)|
lexer.$(file.patterns.perl)=perl
lexer.$(file.patterns.bash)=bash
Ruby Shoes, Get full path of current application
After reading this post [1] I though that [2] would return the full path, as the url suggest it is only a relative path. For Ruby scripts executing under Shoes the current dir can change so it is always best to refer to a full path. The short script at [3] should give just that.
[1] http://stackoverflow.com/questions/757455/relative-file-paths
[2] File.dirname($PROGRAM_NAME)
[3]:
[1] http://stackoverflow.com/questions/757455/relative-file-paths
[2] File.dirname($PROGRAM_NAME)
[3]:
def getFullPath
modulepath = File.expand_path($PROGRAM_NAME)
modulepath = $modulepath.gsub($PROGRAM_NAME,"")
return modulepath
end
Friday, 24 April 2009
Create new Repository on Github
github.com repositories are setup through the web page:
http://github.com/repositories/new
Which then forwrds you to these instructions (some of which can been done before setting up the repo):
http://github.com/repositories/new
Which then forwrds you to these instructions (some of which can been done before setting up the repo):
Global setup:
Download and install Git
git config --global user.name "Registerd githubname"
git config --global user.email yourgithub@emailaddress.com
Next steps:
mkdir shoesexamples
cd shoesexamples
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:git_hub_username/shoesexamples.git
git push origin master
Existing Git Repo?
cd existing_git_repo
git remote add origin git@github.com:git_hub_username/shoesexamples.git
git push origin master
Google Apps to host your Domain mail server
A mini howto forward you domain emails to google and get a gmail interface for your emails using use google apps.
Register at http://www.google.com/apps/
The standard edition is free and can have upto 50 users.
Now Configure Mail
https://www.google.com/a/cpanel/yourdomain.com/Dashboard
click "Activate Mail"
Follow Instructions for setting MX records
which are :
Priority Address TTL
1 aspmx.l.google.com 1week
5 alt1.aspmx.l.google.com 1week
5 alt2.aspmx.l.google.com 1week
10 aspmx2.googlemail.com 1week
10 aspmx3.googlemail.com 1week
The login page should be:
https://mail.google.com/a/yourdomain.com
or you can set up mail.yourdomain.com [instructions]
https://www.google.com/a/cpanel/yourdomain.com/DomainSettingsDomains
select "Service Settings" -> "Email"
Tell google what you want the domain to be.
Update your dns records by adding a cname with alias mail (should match the google setup), points to host name should be ghs.google.com ttl 1 week
It may take a few hours for google and world wide dns caches to update making it functional, just wait a and and at some point your new mail.yourdomain.com should spring to life.
Register at http://www.google.com/apps/
The standard edition is free and can have upto 50 users.
Now Configure Mail
https://www.google.com/a/cpanel/yourdomain.com/Dashboard
click "Activate Mail"
Follow Instructions for setting MX records
which are :
Priority Address TTL
1 aspmx.l.google.com 1week
5 alt1.aspmx.l.google.com 1week
5 alt2.aspmx.l.google.com 1week
10 aspmx2.googlemail.com 1week
10 aspmx3.googlemail.com 1week
The login page should be:
https://mail.google.com/a/yourdomain.com
or you can set up mail.yourdomain.com [instructions]
https://www.google.com/a/cpanel/yourdomain.com/DomainSettingsDomains
select "Service Settings" -> "Email"
Tell google what you want the domain to be.
Update your dns records by adding a cname with alias mail (should match the google setup), points to host name should be ghs.google.com ttl 1 week
It may take a few hours for google and world wide dns caches to update making it functional, just wait a and and at some point your new mail.yourdomain.com should spring to life.
Thursday, 23 April 2009
New file and directory permissions on unix
Unix and Linux based sytems define default file permissions with umask.
$ man umask
To see you current permissions just run:
$ umask
>0022
For a more user friendly format:
$ umask -S
>u=rwx,g=rx,o=rx
Person is User, Group and Other.
Properties are Read, Write and eXecute.
umask subtracts from the normal properties set by chmod.
Folder and file are the same, except files will never be set executable by default.
(the -- are just to allign the tables, the numbers are the decimal equivalent for a 1 set in that position)
--421,--421,--421
u=rwx,g=rwx,o=rwx
Say you (User) want full access to a file but not allow Group or Other access.
you want:
--421,--000,-000 ie 700
The mask would be
--000,--421,--421 => 077
to set this just run (and may be add to your ~/.bashrc file) :
$ umask 077
You (User) want full access, Group has read and execute and Other none
--421,--401,--000 ie 750
the mask would be:
--000,--020,--421 => $ umask 027
You (User) have full access and Group and other have read and execute.
--421,--401,--401 ie 755
mask would be:
--000,--020,--020 => $ umask 022
NB:
Q) How do i set umask to make files executable by default?
A) You can not create exectuable file by default using umask, it is thought to be a security issue.
$ man umask
To see you current permissions just run:
$ umask
>0022
For a more user friendly format:
$ umask -S
>u=rwx,g=rx,o=rx
Person is User, Group and Other.
Properties are Read, Write and eXecute.
umask subtracts from the normal properties set by chmod.
Folder and file are the same, except files will never be set executable by default.
(the -- are just to allign the tables, the numbers are the decimal equivalent for a 1 set in that position)
--421,--421,--421
u=rwx,g=rwx,o=rwx
Say you (User) want full access to a file but not allow Group or Other access.
you want:
--421,--000,-000 ie 700
The mask would be
--000,--421,--421 => 077
to set this just run (and may be add to your ~/.bashrc file) :
$ umask 077
You (User) want full access, Group has read and execute and Other none
--421,--401,--000 ie 750
the mask would be:
--000,--020,--421 => $ umask 027
You (User) have full access and Group and other have read and execute.
--421,--401,--401 ie 755
mask would be:
--000,--020,--020 => $ umask 022
NB:
Q) How do i set umask to make files executable by default?
A) You can not create exectuable file by default using umask, it is thought to be a security issue.
Labels:
Bash,
Debian,
Filesystem,
Leopard,
Linux,
Mac,
OS X,
Programming
Perl Variables
#Perl comments use #hash
Some general perl variables:
Some general perl variables:
$scalar = 1 ; #String, integers, floats
print $scalar ;
@array = ("apple", "pair");
print $array[0];
print $array[1];
%hash = ();
$hash{"apple"} = 100;
$hash{"pair"} = 200;
print "Cost is $hash{"apple"} \n";
Subscribe to:
Posts (Atom)
