Programming: Tips and Tricks

Internet: Javascript Techniques

Developers and designers are using more and more JavaScript in modern designs. Sometimes this can be a hindrance to the user and take away from the simplicity of the design, and other times it can add greatly to the user’s experience. The key is a) adding the right amount of JavaScript, and b) using the right JavaScript techniques.

More: continued here

Posted by Johan Bakker on Sep 12, 2008

Programming: Regular Expressions tips and tricks

I knew it from the first glance, that regular expressions were very very beautiful. As of today, I feel that I have a pretty good grasp of regular expressions.

More: continued here

Posted by Johan Bakker on Sep 10, 2008

Rotating Rails Log Files

taken from: NullIsLove

One of the chores I dislike most is cleaning up and clearing out the log files in my Rails applications. On some of my higher profile sites, I get a lot of spiders probing my applications for security holes. They don’t succeed (knock on wood) but they do fill up my log files with errors.

I finally decided to get smart and get lazy (the two best traits a programmer can have), and I set up automatic log rotation on all of my Rails applications. The idea behind log rotation is simple: make a back up of the current log file, continue logging into a new or cleared log file, and discard log files that are older than a certain date.

Your webserver probably already rotates its own log files. For Apache, they are probably located in /etc/httpd/logs and they are probably rotated weekly. These logs store everything Apache does. Simple webserver stats and traffic analysis tools make use of these log files to show who visits a site when and what pages are viewed.

While it is possible to configure your Rails application to log to your Apache log files, I do not think it is a good practice. It’s much better to give each Rails application its own log file—it will be easier to find important Rails errors, it will keep your Apache logs cleaner and Rails is set up to keep its own logs by default. Fortunately, on a Linux server the built-in logrotate program will make the process super-easy. After the jump, I’ll walk you through the steps to get it set up.

Continue Reading…

Posted by Administrator on Nov 28, 2007

Subversion + Rails In Five Minutes

This is a quick set of subversion commands to create a repository for your Rails application. The repository is dedicated to your Rails app so the head of your source will be in the trunk, version releases will be in tags, and branches for you code base will be in branches.

Posted by Administrator on Aug 20, 2007

Backing up an entire hard drive under UNIX

This article walks you through the process needed to create an identical copy of an entire disk under UNIX. It is useful to create a system image for installation or backup purposes. You will need a second hard drive of the same or larger size as a destination for the backup. The disk created will be full bootable; in the event of a drive failure, this backup drive can be swapped in for the previous drive and the system will boot and be in the same state that it was in when the backup was made. While booting off a drive that believes that it is a powered-on system is not ideal, it can get you back into operation quickly. In addition, the backup disk can be used as a perfect copy of the file structure, in case of permissions problems or data corruption.

Continue Reading…

Posted by Administrator on Mar 29, 2007

Compile DB_File from Perl5.8 on FreeBSD with a different version of Berkley DB

I still like SquidGuard as a squid redirector and I use a couple of perl scripts to maintain the proxy blacklists from Urlblacklist.com. But in order to get the perl DB_File module working with the same version of BerkleyDB (3) that SquidGuard requires it is needed to change the default make file from the FreeBSD portstree

Continue Reading…

Posted by Administrator on Dec 16, 2006

OpenVPN with FreeBSD, PF and Windows XP

This describes howto use a OpenVPN client installed on windows to connect to a VPN concentrator installed on a FreeBSD box protected by PF.

Continue Reading…

Posted by Administrator on Dec 08, 2006

Building a High-performance Computing Cluster Using FreeBSD

Abstract

In this paper we discuss the design and implementation of Fellowship, a 300+ CPU, general use computing cluster based on FreeBSD. We address the design features including configuration management, network booting of nodes, and scheduling which make this cluster unique and how FreeBSD helped (and hindered) our efforts to make this design a reality.

Continue Reading…

Posted by Administrator on Nov 23, 2006

Programming: Upload Validate CSS using Ruby

n an application where a user is given the ability to upload or edit a CSS file, you may want to allow them to validate it against the better known CSS validation standards. This ruby script can do just that, although it should be mentioned that it depends on curl and thus is only going to run under windows if you use something akin to CYGWIN.

Continue Reading…

Posted by Administrator on Nov 15, 2006

Programming: Build a Web spider on Linux

Using common scripting languages and their collection of Web modules, you can easily develop Web spiders.

Web spiders are software agents that traverse the Internet gathering, filtering, and potentially aggregating information for a user. Using common scripting languages and their collection of Web modules, you can easily develop Web spiders.

A spider is a program that crawls the Internet in a specific way for a specific purpose. The purpose could be to gather information or to understand the structure and validity of a Web site. Spiders are the basis for modern search engines, such as Google and AltaVista. These spiders automatically retrieve data from the Web and pass it on to other applications that index the contents of the Web site for the best set of search terms.

Similar to a spider, but with more interesting legal questions, is the Web scraper. A scraper is a type of spider that targets specific content from the Web, such as the cost of products or services. One use of the scraper is for competitive pricing, to identify the price of a given product to tailor your price or advertise it accordingly. A scraper can also aggregate data from a number of Web sources and provide that information to a user.

Continue Reading…

Posted by Administrator on Nov 15, 2006

Web 2.0: For the User, By the User

I still remember the thrill of my father bringing home our first VCR. The features were dizzying would it really record television shows in the middle of the night when we were fast asleep Finally, just what we needed! Or did we Sadly, we only mastered the art of renting and playing movies. Confusion from unclear directions overrode our interest level in learning the finer points of our VCRs features. Dad rightly claimed that corporate design labs and family dens have different standards for what might pass as user-friendly. We used the VCR as it suited our needs while disregarding its more complex features. Some years and many technologies later user friendly is back defining, in digital terms, what is loosely referred to as Web 2.0. Web 2.0 is the latest generation Internet. Its the perfect market for users and advertisers alike: now it’s Adsense, not DoubleClick; live blogs, as opposed to static webpages.

Continue Reading…

Posted by Administrator on Nov 03, 2006

Firefox: Live Bookmarks Refresh Rate

The default livebook mark refresh in Firefox is set to 30 minutes. It is possible to change this default by changing the following parameter:

browser.bookmarks.livemark_refresh_seconds

Continue Reading…

Posted by Administrator on Nov 01, 2006

Ruby blocks, Procs and methods

Ruby provides the programmer with a set of very powerful features borrowed from the domain of functional programming, namely closures, high–order functions and first–class functions [1]. These features are implemented in Ruby by means of code blocks, Proc objects and methods (that are also objects) – concepts that are closely related and yet differ in subtle ways. In fact I found myself quite confused about this topic, having a difficulty to understand the difference between blocks, procs and methods and unsure about the best practices of using them. Additionally, having some background in Lisp and years of Perl experience, I was unsure of how the Ruby concepts map to similar idioms from other programming languages, like Lisp’s functions and Perl’s subroutines. Sifting through hundreds of newsgroup posts, I saw that I’m not the only one with this problem, and in fact quite a lot of ”Ruby Nubies” struggle with the same ideas.

Continue Reading…

Posted by Administrator on Nov 01, 2006

Ajax, ruby, html, css cheatsheets

Whether you’ve forgotten the name of a function or the property of a cascading style sheet – handy cheat sheets deliver the information you are looking for – immediately. Most cheat sheets are available as .pdf or .png-files, so you can print them and use them every day for whatever projects you’re currently working on.

On this website you find a list of several cheatsheets including perl, ruby, xml, css, ajax, html, photoshop, mysql, ..., ...

Continue Reading…

Posted by Administrator on Nov 01, 2006

Internet: Getting Started in Rails

Really Getting Started in Rails

The Review

It’s actually a pretty good article, the one with the most depth and breadth that I’ve seen at this point, and I used it to explore Rails last night. If you already know and understand programming concepts like database connectivity, object orientation, variables, loops, etc., then it’s a good place to start to get your hands dirty. After having actually produced some code, even if it was guided, I now have a better grounded understanding of Rails and that makes it easier to read the dry (not DRY, alas) documentation.

The only thing is, like all tutorials, it doesn’t always explain why. Why is that the syntax? What does that line mean, exactly? Why is the application designed so it fits together that way? Me, I like to know why–in reality, because of my designer brain, I have to know why to really grok it and retain it.

Continue Reading…

Posted by Administrator on Oct 29, 2006

Save 90% of diskspace on your FreeBSD jails by using a shared /usr.

You can save 90% of the disk-usage (aprx. 16MB only instead of 180MB) of a plain jail by sharing the /usr from the jail-host:

cd /opt/jails/192.168.0.100; rm -rf /usr; mkdir usr
mount -t null -o ro /usr /opt/jails/192.168.0.100/usr

and you need to change the /etc/rc.conf of the jail(s) with shared /usr slightly:

local_startup=”“

So the jails do not search startup in the /usr/local/etc/rc.d (of the jail-host).

jail_install takes the argument -light which does all the steps described above, then jail_start and jail_stop mount and umount /usr for you.

Important Note: The jail_root (defined in /usr/local/etc/jail.conf) must lie outside /usr (not /usr/jails) but /opt or something else, otherwise mount -t null won’t work as distinct paths (paths which are not part of each other) required.

I created a dedicated slice (/opt/) on my jail-host which only hosts the jails:

/dev/ad0s1a on / (ufs, local) /dev/ad0s1e on /var (ufs, local, soft-updates) /dev/ad0s1f on /tmp (ufs, local, soft-updates) /dev/ad0s1g on /usr (ufs, local, soft-updates) /dev/ad0s1h on /opt (ufs, NFS exported, local, soft-updates)

Continue Reading…

Posted by Administrator on Oct 22, 2006

Internet: Create clean w3 compliant html code with tidy integration in Vi(m)

If you want to stick to vim as you favorite (html) editor just like me I found the following tip to integrate tidy into vim to be able to check your html code if it clean and w3 compliant.

Add the following file type plugin for html files.

Continue Reading…

Posted by Administrator on Oct 22, 2006

Linux: Using hdparm to speed up your harddisk performance

Speeding up your hard drive

Get faster file transfer by using 32-bit transfers on your hard drive

Just add the line:

hdparm -c3 /dev/hdX

to a bootup script.

If you use SuSE or other distros based on SYS V,

/sbin/init.d/boot.local

should work for you.

This enables 32-bit transfer on your hard drive. On some systems it can improve transfer performance by 75%.

To test your performance gain, type:

hdparm -t -T /dev/hdX
Continue Reading…

Posted by Administrator on Oct 20, 2006

A Guide To Website Promotion Part Two

Now that you are familiar with the most important search engines and linking strategies, you should not ignore other promotion tools that will enhance your website promotion efforts.

3. Traditional Media Strategies

Website promotion should be a mix of online and offline strategies. Traditional media tools apply successfully to increase traffic and get more visitors.

Promote your website URL on business cards, stationery and company documents.

Dont ignore the importance of the traditional media. Include your URL in any display in newspapers, magazines and so on. Many people do use the yellow and white pages to search for services. Make sure your company is listed and provide the URL along your listing as well.

Send your clients business greeting cards on proper occasions. These will act as reminders and help maintain good communication channels between you and your customers.

Use your local TV and Radio to promote your website. Advertisements on national TV are really expensive, but do use them if you have the money.

Print informational brochures and periodicals. For periodicals dont just ramble about a topic: make them worth reading. Send them free to business partners, clients, journalists and research centers.

Develop a free service (related to your business field) to attract clients to your website: a free online insurance calculator, a free e-book, free software, etc.

4. Email Strategies

Emails are virtual corporate letters. Email can be used to send out answers to inquiries, news, offers, advice and much more. The first and most important rule when it comes to business email is: DONT SPAM! The rest comes naturally.

No matter what business email you send out, always use a signature: your name, position, company address and phone numbers, website URL. Always include the http: in front of your domain name, as many email software programs fail to convert simple www. into links.

Publish an eNewsletter (ezine): this is a periodical electronic publication with useful information for your clients. You may include in the eNewsletter articles, press releases, news and special offers. But dont forget to include a visible link to your website as well.

Send your clients special offers, discount coupons, product updates and so on. These should be personalized, clear and to the point. Once again: dont spam.

There are email marketing companies that have developed lists of people who have agreed to receive commercial emails. You could use such a service, but if you do, make sure its not a type of pay to read email company. To pay for something like this will do you no good, as people who get paid to read emails dont really care about your message, but just click on the links to get a commission per click.

Up to now youve learned the importance of search engine strategies, how to develop a solid linking strategy, how the traditional media tools boost site popularity and what email strategies work best to promote your website. In the third and last part of this short guide, we will show you how to use paid advertising effectively. We will also take a look at some miscellaneous website promotion tools.

About The AuthorScott Lindsay is a web developer and entrepreneur. He is the founder of HighPowerSites and many other web projects. HighPowerSites is the easiest do-it-yourself website builder on the web. No programming or design skill required. Get your own website online in just 5 minutes with HighPowerSites.com

Continue Reading…

Posted by Administrator on Oct 17, 2006

Windows: Vista - What To Look Foward To

Windows Vista – What To Look Foward To by: Richard Callaby

Perhaps you have heard about the next new version of Microsoft Windows, called Vista The Vista operating system has many promises to one great, stable and dynamic operating system. Not only will this operating system have the .Net framework built into the core of the operating system it will also feature some other key communications, user interface and security breakthroughs.

Continue Reading…

Posted by Administrator on Oct 16, 2006

Windows:Why Do I Still Get Viruses

Why Do I Still Get Viruses by: Darren Miller

Viruses & Anti-Virus Software

Many people have Anti-Virus software installed. Many of the major Anti-Virus software company’s now promote what they call Security Suites or packages. These Security Suites contain everything from Anti-Virus, Firewall Protection, SPAM and Pop-Up blockers, and Ad-ware protection. Quite often, once the software is installed people find out that things they use to be able to do on the Internet are no longer possible. So what happens is portions or all of the software they purchased to protect their computer get disabled. The result, an ineffective software program that you paid good money for! Worst than that, most people have no idea exactly how the Anti-Virus portion of the package should be configured. Leaving it up to the default configuration to defend their computers. Most of the manuals that come with these software packages seem to be written for those who understand the intricate workings of computers along with every computer acronym ever invented!

Continue Reading…

Posted by Administrator on Oct 16, 2006

Windows: 10 Things You Should Do When Your Computer Freeze or Hang-Up

10 Things You Should Do When Your Computer Freeze or Hang-Up by: Pinky Mcbanon

You are in the middle of doing your work, suddenly you realized your computer hang up. But the problem is, you have not saved your work! Dont panic! There is a solution for that! And you can surely save your file!

Heres how:

Continue Reading…

Posted by Administrator on Oct 12, 2006

Internet: 5 Essential SEO Techniques

5 Essential SEO Techniques by: Tan Kok Chuan

Search Engine Optimization is becoming a more and more complicated area especially with the recent updates and data refresh done on the search engines’ index. However, the basic concept for good ranking does not change. The following illustrates five most important SEO techniques as summarized from the Google Webmaster Guidelines that all webmasters should follow.

Continue Reading…

Posted by Administrator on Oct 12, 2006

FreeBSD: Update userland and build a new kernel

cd /usr/src
make buildworld
make buildkernel KERNCONF=MYKERN
make installkernel KERNCONF=MYKERN
reboot
Reboot into single user mode
fsck -p
mount -u /
mount -a
cd /usr/src
adjkerntz -i
mergemaster -p
make installworld
mergemaster
exit
Continue Reading…

Posted by Administrator on Oct 10, 2006

Web Page Speed Analysis and Free Website Performance Tool

Try this free web site speed test to improve website performance. Enter a URL below to calculate page size, composition, and download time. The script calculates the size of individual elements and sums up each type of web page component. Based on these page characteristics the script then offers advice on how to improve page load time.

Continue Reading…

Posted by Administrator on Oct 10, 2006

Recover lost MySQL root password

So I lost my root password for MySQL database. After digging around mysql.com docs (which are just as cryptic as man pages), and searching google, I finally was able to change my root password.

Continue Reading…

Posted by Administrator on Oct 09, 2006

Using OpenBSD's spamd as a greylist mail filter

I have an exchange server that doesn’t do a very good job of filtering spam. The server sits inside the firewall/NAT and is reached through port-forwarding. I wanted to stick a device in between the Exchange server and the firewall to filter spam, so I needed a device that would work as a bridge. Spamd works with the pf firewall to redirect smtp traffic that is passing through the bridge to the spamd process. Once a server’s IP address is added to the whitelist by spamd, traffic from that machine passes through the bridge unfiltered. Outbound SMTP traffic is also unfiltered. The users are unaffected because Microsoft Outlook doesn’t use SMTP to inject mail into the server, and so the only thing that should be talking to port 25 (SMTP) should be other mail servers.

Continue Reading…

Posted by Administrator on Oct 09, 2006