Unique Marketing, Guaranteed Results.

Setting PowerDNS To Ignore Records For Downed Web Sites

June 10th, 2009 by Aaron Murphy

If you are using PowerDNS for round robin on multiple websites, you can set it up so that it will return only the records for sites that are up. I set up a Ruby daemon to monitor sites and connect to the PowerDNS MySQL table used by PowerDNS on Rails. You can use any language or system you like. It just needs to be able to access your PowerDNS database. Read the rest of this entry »

Regular Expression Lookahead

June 10th, 2009 by Aaron Murphy

Using standard regular expressions is pretty easy for most tasks. However, there is one task that requires lookaheads. I am referring to using negative lookahead to check for strings that do not follow a desired match. The syntax is

(?!someregexp)

where “someregexp” is a regular expression to match. The negative lookahead will reverse the logic for you. Read the rest of this entry »

Chain Blogging – Internal Link Building and Usability

June 10th, 2009 by Brandon Buttars

Chain BloggingSo some of you may have seen the term chain blogging and probably started to think about chain emails and chain mail. That’s not what this article is about. It’s not about putting a curse on someone that doesn’t fulfill their forwarding quota. I’m talking about blogging just like a chain smoker lights the next cigarette with the previous cigarette, and continues this on and on and on. I recommend igniting your next blog post by the previous blog post. Confused yet? OK, I’ll try to illustrate and explain the idea of “Chain Blogging”.

Read the rest of this entry »

Why Test?

June 10th, 2009 by fugufish

I come to PMA from a large corporation over 40,000 employees strong, including an entire army of QA Engineers testing every change and release we made, something we took full advantage of. At first, I was of the opinion (as many BDD converts) that the process of defining the and testing the code before actually writing the code would slow me down. As I moved more and more to BDD however, I found that I was completing tasks faster. The time saved comes from the ability to define how you expect your application to work. By doing this you will find that your actual code requires much less debugging. Things just seem to work. It continuously surprises me using BDD that things just work, so instead of spending hours looking for a mistyped association, I can spend those hours in actually coding.

Even with an army of QA Engineers, some bugs will sneak through. QA time on untested code takes longer, and debugging the code even longer than that. The release process can go from a day to several days, or even weeks.

With BDD, when new features are added to the application, it as easy as running your spec or test suite to ensure that the original functionality is undamaged. It of course seems like a no brainer to me now. It’s like looking back and remembering when you thought the world was flat, and seeing how narrow minded you were. The moral of the story? Test before you code! You fill find yourself with more time, and less headaches.

Ruby, what I’ve learned

June 9th, 2009 by Narshlob

Being a beginner at Ruby, I’ve found the language to be extremely easy to learn and use. Being used to, and fond of, the object oriented design pattern has made it fun for me to learn Ruby. The fact that everything in Ruby can be seen as an object makes it more intuitive for one that thinks that way.

The only thing that makes it somewhat difficult to program correctly would be the conventions that need to be learned. There is a lot of help out there to ease this burden though, so it’s not too big of a deal. Another thing about the language is the amount of functions available to do different tasks. There might be five different functions that do essentially the same thing. Using RDoc Documentation (http://www.ruby-doc.org/core/) or ri helps tremendously in learning what these functions are and how to use them.

Coming from a background in Java, it’s easy to expect that Ruby would be stringent about how things are to be done. This is not the case, however. The language seems to balance strict coding enforcement with an almost scripting language like syntax. This gives a fair amount of freedom in the style of coding a user can implement, instead of being tied down to one way of doing things. At the same time, one does not get a jumbled mess of code to sift through every time a bug appears (assuming the coding conventions and good coding practices in general are implemented).

I used to work for a company (which shall remain nameless ;) that used PHP for all of their projects. The one thing I’ve noticed in Ruby, and thoroughly enjoyed, is that you can take an array and instead of doing this

foreach($array as $key => $val)
{
    $$key = $val
    #or do something else with the key/value pair
}

it would be something as simple as this in Ruby,

array.each do |arr|
    #blah blah we do something
end

Much easier to read and much cleaner than PHP’s implementation, imo.

Good luck to everyone learning Ruby. You’re definitely in for a treat

As far as PMA Media group goes, what a company, I tell you what. These guys are awesome. They treat their employees in a way that encourages good work ethic without using negative reinforcement. So far, I have been looking forward to going to work since I’ve started here. Thanks guys :) cheapest college essays

Culerity and Celerity, JavaScript enabled testing in Cucumber

June 8th, 2009 by fugufish

As you may know, testing JavaScript inesnsive applications using Cucumber can be a pain. There are several ways to handle this; Selenium, Watir and the like. The easiest way I have found however is by using Celerity a jRuby API for htmlUnit, a fully functional headless browser that completely supports JavaScript, and you don’t have to serve your application on jRuby to use it!. I was able to get Celerity to play nice duruing Cucumber tests by doing the following: First, you will need of course jRuby. The Culerity gem will start up Celerity in the jRuby environment, and proxy the actual browser through it. Download jRuby and extract it to wherever you want it located. In my case I put it in /opt, and set your PATH accordingly.

export PATH=$HOME/jruby/bin:$PATH

Next install the Celerity gem in jRuby (we are using the github version rather than the ruby forge version, as it provides a later version):

jruby -S gem install jarib-celerity --source=http://gems.github.com

Now install the Culerity gem. This provides the interface between Celerity and your environment without forcing you to run in jRuby

 gem install langalex-culerity --source http://gems.github.com

Place this in your test environment:

# config/environments/test.rb

config.gem "langalex-culerity", :lib => false

I call :lib => false here to avoid loading the gem. This is done in the file generated by culerity. Finally remove features/steps/webrat_steps.rb as it will conflict with Culerity, and run:

script/generate culerity

Enjoy! Culerity should have very similar syntax to webrat, however keep in mind you may see some differences that you may need to adjust. essay writing service

Smarter Sequencing in Factory Girl

May 29th, 2009 by Brett Rasmussen

Hal Shearer and I monkey-patched Factory Girl’s sequencing capabilities to allow for pre-defined enumerations to loop through, instead of just infinitely incrementing numbers.

So instead of doing this:

  Factory.sequence :email do |n|
    "person#{n}@example.com"
  end

you could do something like this:

  Factory.sequence(:email, ['angela', 'brett', 'alec']) do |name|
    "#{name}@example.com"
  end

It will start over at the beginning when it’s gone through all of them:

>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"

You can also hand it a range (the internal implementation on this is none too efficient, so don’t give it billions at a time):

Factory.sequence(:email, 50..60) do |n|
  "user_#{n}@example.com"
end

>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"

The infinitely incrementing counter is still available if you want it:

Factory.sequence(:email, %w[angela brett alec]) do |name,i|
  "#{name}_#{i}@example.com"
end

>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"
>> Factory.next :email
=> "[email protected]"

This sort of thing is useful when you want two different factories to use the same sequence and have some overlap between the two groups. For example, we need a bunch of email addresses to test on, many of which share the same domain:

Factory.sequence(:name, %w[angela brett alec hal debbie tracey jared]) do |name,i|
  "#{name}_#{i}"
end

Factory.sequence(:domain, %w[something.com example.com mydomain.com]) do |domain|
  domain
end

Factory.define(:email_address) do |f|
  f.address { "#{Factory.next(:name)}@#{Factory.next(:domain)}" }
end

>> 20.times { ea = Factory.build :email_address; puts ea.address }
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

For our last trick, the reset method returns both the looping index and the infinite counter back to zero:

>> Factory.reset :name
>> Factory.next :name
=> "angela_0"

Here’s the code to make it happen:

class Factory
  def self.sequence(sequence_name, enum = nil, &blk)
    @@sequences ||= {}

    enum = enum.to_a

    @@sequences[sequence_name] = {
      :enum => enum,
      :index => 0,
      :infinite_counter => 0,
      :template  => blk
    }
  end

  def self.next(sequence_name)
    seq = @@sequences[sequence_name]

    retval = case seq[:template].arity
      when 1
        seq[:template].call(seq[:enum][seq[:index]])
      when 2
        seq[:template].call(seq[:enum][seq[:index]], seq[:infinite_counter])
    end

    seq[:index] = (seq[:index]+1 == seq[:enum].size) ? 0 : seq[:index]+1
    seq[:infinite_counter] += 1
    @@sequences[sequence_name] = seq
    retval
  end

  def self.reset(sequence_name)
    @@sequences[sequence_name][:index] = 0
    @@sequences[sequence_name][:infinite_counter] = 0
  end
end

Just put that into some file–perhaps in your rails lib directory–and make sure that file gets required–probably in your rails config/environment.rb. When doing it by hand like this, you’ll want to make sure your library file is loaded after the factory_girl gem is loaded, or you’ll get weirdness like methods you’ve overridden acting in non-overridden ways and the like; config.after_initialize in your environment.rb’s Rails::Initializer block is your friend.

You can also now use the gem BrettRasmussen-factory_girl from gems.github.com. I mean to submit it as a patch back to the original factory_girl, which I’m sure I’ll have time to do Any Day Now.

Chuck’s Ruby Indexer

May 22nd, 2009 by Chuck Wood

I was messing around with ruby a little and decided to write a little indexer that would tell me what the most common words were in my files. It’s really kind of a dumb program, but it was interesting what it turned out when I ran it against my code. The most common word was frequently the word ‘the.’ ‘the’ is not a commonly used variable or function in Ruby. So I looked at my code and realized that it was heavily commented, yielding frequent ‘the’s.

That being said, I’m curious to see what other people find running the indexer against their code. You can get it at http://github.com/woody2shoes/indexer/tree/master. Please comment and let me know what your code looks like.
Read the rest of this entry »

Using IMEEM to Social Network in Business

May 21st, 2009 by Brandon Buttars
IMEEM Profile

I am a big IMEEM fan and I know there are tons of different music social networks out there that can be used, but I just like the way that IMEEM is. I was doing some searching through IMEEM for a good playlist and the first one I ran into was one put together by a user by the name of kiasoul. I went to the playlist and as you would expect, it was a playlist put together by Kia promoting their new Kia Soul vehicle. Genius I thought. I know I may be a little slow because everyone else probably already thought to do this, but I thought I would jump on the same band wagon and let people that hadn’t thought to do it see how I did it.

Read the rest of this entry »

How to do Benchmarking with Ruby

May 21st, 2009 by Alan Carl Mitchell

Benchmarking with Ruby is super easy. There is already a built in class–Benchmark–that will do all of the heavy lifting for you.

If you want to do basic benchmarking, Benchmark.bm is the easiest way to go. Take a look below. Here we are going to test three ways to do looping in Ruby and see which one we like best.

require 'benchmark'

n = 5000000

Benchmark.bm do |x|
  x.report("for loop:")   { for i in 1..n; a = "1"; end }
  x.report("times:")      { n.times do   ; a = "1"; end }
  x.report("upto:")       { 1.upto(n) do ; a = "1"; end }
end

This will produce output something like this:

               user     system      total        real
for loop:  0.727000   0.000000   0.727000 (  0.727030)
times:     0.571000   0.000000   0.571000 (  0.571588)
upto:      0.523000   0.000000   0.523000 (  0.522947)

If we use Benchmark.bmbm, then it will do a ‘rehearsal’ run first in order to better equalize the garbage collection environment of the code inside the block so that hopefully we get more realistic timings.

require 'benchmark'

n = 5000000

Benchmark.bmbm do |x|
  x.report("for loop:")   { for i in 1..n; a = "1"; end }
  x.report("times:")      { n.times do   ; a = "1"; end }
  x.report("upto:")       { 1.upto(n) do ; a = "1"; end }
end

This will produce output something like this:

Rehearsal ---------------------------------------------
for loop:   0.756000   0.000000   0.756000 (  0.756298)
times:      0.477000   0.000000   0.477000 (  0.476855)
upto:       0.527000   0.000000   0.527000 (  0.526522)
------------------------------------ total: 1.760000sec

                user     system      total        real
for loop:   0.751000   0.000000   0.751000 (  0.751067)
times:      0.516000   0.000000   0.516000 (  0.515874)
upto:       0.581000   0.000000   0.581000 (  0.581254)

Alternately, you can use the Benchmark.realtime method like this:

puts "for loop: #{Benchmark.realtime {for i in 1..n ; a = "1" ; end}}"

and get something like this:

for loop: 0.682438850402832

??????? ???????? ?????? ?????? ?????? ?? ??????? ??????? ????????????? ?? ????? ???? ?????????? ????????. ??? ???????? ?? ???????, ??????? ???????????? ???????, ??? ???, ??? ????? ???? ??? ?????????, ????????? ???? ? ?????????? ???????????? ???? ?????? ?????????? ?????????? ????????? ?????. ??????? ???????? ?????? ?????? ?????? ?? ????? ???? ?????????? . http://igrat-avtomaty-vulkan.com/igrovye-apparaty/ ??????? ???????? ?????? ????? ?????? ????????? ????????? ?????? ?????????? ?????? ???????? ????, ??? ??????????? ? ???????? ?????????????? ???????? ?? ?????. ??? ???? ? ?????? ?????? ?????? ?? ????? ???? ?????????? ????????. ??? ???? ? ?????? ?????? ?????? ?? ????? ???? ?????????? ????????. ??? ???????? ?? ???????, .

Copyright © 2005-2016 PMA Media Group. All Rights Reserved &nbsp