Archive for category Code Snippets

Simple bash countdown timer

Here is a simple bash countdown timer, to run you just enter the minutes you want this to run for, i.e “./count.sh 10” will run countdown for 10 minutes.
Read the rest of this entry »

, , , , ,

No Comments

Ruby On Rails, dynamic table’s & add button using nested_attributes

So here’s the problem, you want to create several items that belong to one item, normally you would just the the has_many and belongs_to (OneToMany) relation in rails. Using this model you create the primary model (such as purchase order) then create several sub items (such as item) and attach them to the primary model. The problem with this is its time consuming and does not always make sense to do things this way, take the Purchase order and Items scenario, it makes much more sense to create the Purchase order and assciated Items in the same form. This is possible in rails uing nested_attributes.

Read the rest of this entry »

, , , , ,

No Comments

Developing Wesbites For iPhones

So I’ve been developing a few websites mainly to be viewed on iPhones and iPods and this has raised several issues. Obviously you have to develop for mobile browsers such as safari which runs on iPhones or iPods and develop accordingly for this browser and the unique screen resolutions used on mobile devices. In this article I’m going to look at, what I feel, are the most important code snippets you’ll need to get started developing for iPhones or iPods. Read the rest of this entry »

, , , , , , , , ,

No Comments

Simple C++ IRC Bot Template

IRC Funny CartoonI searched the Internet, for quit a while, and I couldn’t find the source for a simple IRC bot in C plus plus, so I decided to write one using a TCP Stream Socket in C++. It works by setting up a simple TCP Socket to a IRC server on port 6667. The IRC Bot then assigns a NICK to the connection and connects to a IRC Channel. From here you can code you own commands and replies. I originally developed this to monitor IRC channels, however I came across a problem, PING. IRC servers periodically ping all clients to see if they are connected, so I added some more code to reply to these ping’s so that the bot stays connected. Read the rest of this entry »

, , , , , , , ,

No Comments

C++ Simple Stream Socket Client Class

So I’ve been working on this project that heavily uses Sockets in C++, for the base of this project I’ve created a TCP Socket class so I concentrate on the protocol I’m using rather than worrying about the socket itself and I thought I would share this class with your. Read the rest of this entry »

, , , , , , , , ,

No Comments