Codenone
How to post HTTP request in Python
Once upon a time, I went to attend a conference. The organizer provided wifi access to all attendances which one has to login via web before using this free service. My problem was that I would like to use secure shell. I don't want to browse web. I don't need to start web browser just for logging in. So I wrote a simple and short python script to login automatically.
- sugree's blog
- Add new comment
- Read more
- 2684 reads
How to insert an image into primary links in Drupal
Drupal normally provides powerful and secure menu system to all of us. We are able to manipulate primary links and secondary links seamlessly and easily with little effort. However, sometimes we would like to insert an image instead of text. I found a good snippet but it does not work for me. This snippet is just for menu item but actually, I am talking about primary links or secondary links. Starting in Drupal 5, primary links and secondary links are not formatted by the theme engine, instead, a list of arrays are passed to the theme directly. By default, all menus are passed to check_plain()
to prevent unexpected security holes so we cannot insert HTML tag here include . Fortunately, this is Drupal. We can customize theme to let us insert just only
img
tag.
- sugree's blog
- Add new comment
- Read more
- 4715 reads
How to list the latest 11-20 nodes in Drupal (2)
According to the question and my snippets, the same one asked me again to extend the previous codes to show the author's name besides the node title. In addition, it would be nice to display node title and its author in a table form. Fortunately, this is Drupal. It is very easy.
- sugree's blog
- Add new comment
- Read more
- 1984 reads
How to list the latest 11-20 nodes in Drupal
I found an interesting question regarding Drupal at Codenone. One would like to list the latest 11-20 nodes in a block. He tried to use Views module with no luck. I think so. Listing the latest nodes in a block using Views is very easy but I don't see any clue to get the next 10 nodes. Anyway, it is possible to write a snippet code to fulfill this requirement.
- sugree's blog
- Add new comment
- Read more
- 2644 reads
How to generate combinations in Python
I was asked to help implement a kind of reusable combination generator in Python given the maximum number and the group size. Combination is widely used in high performance computing especially for searching in state space. Note that it means solving problem by brute force technique. So I wrote several codes.
- sugree's blog
- 1 comment
- Read more
- 5957 reads
How to show author's full name in Drupal
I found a good question at Codenone regarding author's full name in Drupal. This is a good question because it clearly shows the power of Drupal. If you notice, all contents in Drupal will show their authors somewhere in the page. An author is identified by his/her username. And there is no full name stored in the database by default. Other CMSs usually store user's full name in its database so you might think Drupal is worse. In fact, you are allowed to add additional metadata using profile module which is included in the core modules. So showing author's full name in each node is very easy.
- sugree's blog
- Add new comment
- Read more
- 2427 reads
Recent comments
3 years 29 weeks ago
3 years 34 weeks ago
3 years 35 weeks ago
3 years 35 weeks ago
3 years 35 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago