## Saturday, October 27, 2012

### functional programming using map with python

Let's say you have a list of strings that ends with '\n' in python.

The simple way to remove '\n' or '\n\r' is string#rstrip() method. You can use readlines() method to read all the contents of file in a string. The problem is all the strings are appended by '\n'.

The issue is how to remove the '\n' for all the elements. From:
['STRING\n',
'\n',
'STRING\n']

To:
['STRING',
'',
'STRING']

Using functional programming, you can do it just one line.
lines = map(lambda x: x.rstrip(), lines)


### embed swf file into blogger

You need to video capture from any tool. I used Jing for it.

Then, you need to store it into somewhere in the cloud, I used google sites.
<embed src="https://sites.google.com/site/csmgroup/files/2012-10-27_2026.swf"
quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" height="300pt" width="500pt">


### Change the name of label in the blogger's new interface

Let's say you want to change the blogger label with bloodspot.

## Add a new label, and set the posts with the new label

Then select them all.

Then, add bloodspot as a new label

Actually they are nothing but a web page that you can make a link. For my case, I use label to get the posts with the label. For example, with the Python tab, I link http://prosseek.blogspot.com/search/label/python, and so on.
Then you can visit blogger.com to select your blogs.

Click Pages to add the page you want. Don't forget to set the "Show pages as" to "Top tabs".

You can change the configuration

### css programming

css code is more like a declarative language with C flavor. C flavor means it has open and closing bracket, and it separates elements with ';' just like C does.
Declarative in the sense that it starts with name and then directives what should be done.
This is an example for having blue 15pt for h2 heading, and drop some shadow on image.
h2 {
color: blue;
font-size: 15pt;
}

img {
}

For box-shadow, refer to this post.

You can dynamically modify the setup using class or ID.
.noborder{box-shadow: none;}


## References

### SyntaxHighlighter brushes

This is a list what kind of brushes that SyntaxHighlighter provides. From http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/.

### Changing font size for headers

Some of the default font size in blogger template does not setup accordingly. This is my rendered output with h2 tag.

In order to change this, one needs to edit the css file. The first step is click the design button.

Then Customize the layout.

Add the necessary code in the editor.

Now you have larger font.

## Reference

### Syntax highlighter issue with google chrome

The code with SyntaxHighlighter shows wrong line formatting in google chrome.
I found that this is a known issue with of line formatting, check this site.

The http://alexgorbatchev.com/pub/sh/current/styles/shCore.css source has the line that causes this problem.

There are easy two solutions.

## Solution 1

Modify the shCore.css : replace this line.
.syntaxhighlighter table td.gutter .line {
text-align: right !important;
padding: 0 0.5em 0 1em !important; <-- Replace this line
}

.syntaxhighlighter table td.gutter .line {
text-align: right !important;
}

Or make it point to where the bug is fixed. : http://codeoncloud.co.cc/shCore.css

## Solution 2

Add following line after Configure HTML/JavaScript edit.


.syntaxhighlighter table td.gutter .line {