Browsing the archives for the Coding tag.

New layout for main site

News, Web developing

I just published new layout for main site: www.pelikoira.net

I build it with awesome css framework called 960 grid system. If you code websites I recommend to try 960 gs, because it makes developing lots of easier and faster.

This site also contains my first JQuery effect that I have used. It is simple “tab” system on project page that allows to change project without reloading page. It also makes it easier to me to control the site, because now it has only 3 files. If every project is on it’s own file, I would have something like 10 .php files. Yes, I don’t have any cms system, because I don’t need them. If I need to change something I take ssh connection and modify files remotely with vim.

I build this site on Debian system with Konsole -> Bash -> Vim system.

And of course all the code (xhtml/css/rss/js) is valid. ;)

No Comments

Ruby on Rails pastebin

Applications, Coding, Projects, Web developing

I have tried Ruby on Rails many times, but this time I managed to create something useful that works. I created a simple pastebin. Actually I didn’t write any code. I just executed couple of scripts and then removed unnecessary parts from ruby code and edited the views.

To host the pastebin I used Heroku. Heroku is very simple platform to host Ruby on Rails apps. It is also very easy to deploy a app to it. Heroku offers free hosting, but it also offers very big plans. Biggest hosting packages can be over 2000$. I recommend to try heroku.

My pastebin runs at pastebin.heroku.com

No Comments

Mantis bug tracker

Applications, Coding

When you code something bigger than Hello World, it will have bugs. You can’t create any project without bugs. Bug tracker makes its easier to manage bugs. Especially when there is many developer and there is lots of bugs.

Some developers wants something like Bugzilla, but it may be little hard to install and configure. If you want something simple and quick to install, try Mantis. Its PHP/MySQL based bug tracker.

Mantis has many features and it works well with almost any kind of project you are working on. One feature I like a lot is ability to have many projects under one bug tracker. So I can do one install of  Mantis and then manage all of my bugs in one place.

So if you need simple bug tracker, PHP based bug tracker or just a good bug tracker, try Mantis.

1 Comment

Create simple twitter bot using python

Internet, Tutorial

In this tutorial you will learn how to do very simple twitter bot. Requirements is Linux/Mac system, but it should be possible to get this on windows.

Install python-twitter

First, you need to install python-twitter package. Installion is simple. Just download package from python-twitter’s website and follow instructions.

Lets get started

In this code we import libraries needed to get this working. First library is the twitter-python package and another is time-library for creating simple timer. We need timer for doing a loop. Commands library is needed to get output from external command. (In this case, uptime)

#!/usr/bin/python
import twitter
import time
import commands

Intializing api


api = twitter.Api(username='username', password='password')

This will intialize twitter api and create new class, api. Change username and password to your accounts details.

Tweeting something


while 1 == 1:
api.PostUpdate(getoutput('uptime'))
print(getoutput('uptime'))
time.sleep(3600)

This will generate infinite loop that will send twitter update every hour. Tweet contains output of uptime command. This also prints output to console so its easier to see what is tweeted.

I run this command inside screen, so it will run 24/7 tweeting uptime of my vps.

If you want to learn more about python-twitter I recommend to read docs on python-twitters website.

Download source code of this tutorial: twitter_bot.py

No Comments

Git, simple source control system

Applications, Linux, Tutorial

If you project is bigger than 20 lines or it has over 1 user, you need source controlling system. If you are doing something very complex or you have many users it’s good to choose services like Google code or Beanstalk. (or something else)

But if you only need a source control system for your self, it’s not so clever to take remote source reporisity, because you can have your own source control system on your local machine!

Setting up svn server is much more difficult than setting up local git repository. I recommend to use git for every small local projects, because it is extremely easy to set up and it doesn’t require server to run.

So, install git (apt-get install git git-core) and then go to your projects directory and type:
Git init
Git add .

First command initializes git repository on .git folder and second command adds every file to new repository. In future when you add more files to project, just use “git add “.

Then do the first commit to get it working.

Git commit -a

Commit command opens default editor on your system. If you want to change it to another editor, add next line to your .bashrc file. (and reload bash to get it working :) )

export EDITOR=vim

Then just continue coding your project. When you want to commit more, just use previous command to do it. After you have done couple of commits you may want to see what you have done. Use “git log” to view latest commits.

When you type just “git” you will get list of sample commands that you will need later. More documentations can be found from gits website.

I recommend to try graphical git application: giggle. It makes it easier to understand branches.

Happy coding :)

No Comments