How to read Circuit Schematics

January 4th, 2012 | by | technology

Jan
04

Yesterday, I watched this amazing tutorial from Collin’s Lab (Make Magazine). Collin has some other interesting videos also like: Electronics Tools, Infrared light, PCB Etching, Pulse Width Modulation, etc. Make sure to watch these.

 

No Comments »

Crack password protected zip files in a minute

December 31st, 2011 | by | technology

Dec
31

I never knew, breaking a password protected zip file, would be so easy. Just broke a password protected zip archive of a code base. The code uses some standard code libraries, which are publicly available. Using the known plain text and Eli Biham and Paul Kocher algorithm to get the PKZip keys, it take seconds to break into the encrypted zip archive.

This bring us, into an interesting question, why we still uses zip standard, when 7z format is there for so many years now. Also, why do we have password requirements for WiFi, etc. where password algorithms flaws have already been shown publicly. Also, what is the use of root digital certificate authority, when they can’t guarantee the authenticity of their own root certificate.

2 Comments »

Open Letter to Mozilla Foundation

August 18th, 2011 | by | technology

Aug
18

Dear Mozilla Foundation,

Your imitation of Google Chrome browser from UI to increasing the version numbers so rapidly is no only pissing the corporate world, but also powerful XPCOM add-on developers. The reason I support Mozilla and not Chrome is not speed, standards, blah blah, but the power of extensibility, which gives Firefox an upper hand in comparison to Google Chrome Version Infinity.

But unnecessary waiting for delayed xulrunner SDK, incomplete documentation, and unnecessary re-compilation of code every time is at least wasting my time, which I could have used to support Firefox more. I seriously can’t understand your strategy which changed from Gecko 2.0.

When you already have methods to auto block all add-ons, why not, just allow and load an XPCOM add-on if user wants to run it and is ok with running it. Also when add-on runs as a separate process now, what is the need for not loading them, when Firefox version changes. Why can’t you have a manifest, which tells that this add-on uses these COM interfaces, and its ok to run it with this version of Firefox also.

Hope, someone there is listening.

Your’s Sincerely,
Priyank

No Comments »

Mozilla Firefox to include add-on blocking feature

August 18th, 2011 | by | technology

Aug
18

Mozilla Firefox Add-on blocking feature

Mozilla has provided a new feature to auto block all add-on installed silently by third party. Third party software installers until now, can install add-on for Firefox without user permissions. But now, these add-ons will be disabled until user explicitly enables them.

This new feature will be available in the Mozilla Firefox Aurora channel and will be available in Firefox version 8.

No Comments »

Create an alias in Windows

May 20th, 2011 | by | technology

May
20

Recently, I wanted to create shortcuts for git commands. I can have written aliases inside the git config file, but then also, I had to type git explicitly. So, I just searched the internet and came across this link: http://superuser.com/questions/49170/create-an-alias-in-windows-xp.

And I just wrote few quick aliases using the doskey in a file called ‘a.cmd‘. Now I just type ‘a‘ and press TAB and ENTER in the command prompt and set aliases quickly. I don’t want it to be automatic, so I just manually run the a.cmd whenever needed. Here is how my a.cmd looks like initially:

doskey st=git status
doskey log=git log
doskey +=git add $1
doskey co=git commit
doskey ..=cd ..
doskey bin=cd "D:\Project\Release\"
doskey src=cd "D:\Project\"

No Comments »

Website Customer Visit Count

May 3rd, 2011 | by | technology

May
03

Question: A leading shopping website generates logs everyday of customers visiting their website along with the page number that they visited. Each entry contains the customer unique id and the page id, which the customer visited. Given the logs of 3 days, and the customer id, check whether the customer visited exactly on 2 out of 3 days and also check whether he visited more than 3 different pages?

#include <iostream>
#include <hash_map>
#include <list>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using namespace stdext;

const int PAGE_VIEW_COUNT = 3;
const int DAYS_VISIT_COUNT = 2;

class CustomerData
{
public:
  bitset<PAGE_VIEW_COUNT> days;
  set<int> pages;

  CustomerData(bitset<PAGE_VIEW_COUNT> d, set<int> p) : days(d), pages(p)
  {
  }

  CustomerData() : days(string("000")) //Use days.reset, if PAGE_VIEW_COUNT != 3
  {
  }
};

hash_map<int, CustomerData> entries;
hash_map<int, CustomerData>::const_iterator recordIter;
typedef pair<int, CustomerData> CustomerRecordEntry;

void GenerateCustomerList(const list<pair<int, int>>& cuslist, int logNum);

int main()
{
  list<pair<int, int>> log1, log2, log3;
  log1.push_back(make_pair(1,1));
  log1.push_back(make_pair(2,2));
  log1.push_back(make_pair(4,1));
  log1.push_back(make_pair(1,3));

  log2.push_back(make_pair(2,1));
  log2.push_back(make_pair(2,4));
  log2.push_back(make_pair(4,2));
  log2.push_back(make_pair(1,3));
  log2.push_back(make_pair(1,5));

  log3.push_back(make_pair(3,2));
  log3.push_back(make_pair(4,4));
  log3.push_back(make_pair(5,2));
  log3.push_back(make_pair(5,5));

  GenerateCustomerList(log1, 1);
  GenerateCustomerList(log2, 2);
  GenerateCustomerList(log3, 3);

  int cid = 0;
  cout << "Enter customer ID: " ;
  cin >> cid;

  recordIter = entries.find(cid);
  if(recordIter != entries.end())
  {
    CustomerData data = (CustomerData)recordIter->second;
    if(data.days.count() == DAYS_VISIT_COUNT && data.pages.size() == PAGE_VIEW_COUNT)
    {
      cout << "Customer visited on exactly 2 days and have 3 or more distinct page views."
        << endl;
    }
    else
    {
      cout <<
        "Customer didn't visited on exactly 2 days or have 3 or more distinct page views."
        << endl;
    }
  }
  else
    cerr << "Customer ID not found in logs." << endl;

  cout << endl;
  return 0;
}

void GenerateCustomerList(const list<pair<int, int>>& cuslist, int logNum)
{
  list<pair<int, int>>::const_iterator iter;
  for(iter = cuslist.begin(); iter != cuslist.end(); iter++)
  {
    recordIter = entries.find(iter->first);
    if(recordIter != entries.end())
    {
      CustomerData data = (CustomerData)recordIter->second;
      data.days.set((logNum-1), true);
      //Space optimization
      //Check if already have 3 distinct page view, no need to add more
      if(data.pages.size() < PAGE_VIEW_COUNT)
        data.pages.insert(iter->second);
      entries[recordIter->first] = data;
    }
    else
    {
      bitset<PAGE_VIEW_COUNT> days(string("000"));
      days.set((logNum-1), true);
      set<int> pages;
      pages.insert(iter->second);
      CustomerData data(days, pages);
      entries.insert(CustomerRecordEntry(iter->first, data));
    }
  }
}

Comments Closed

PWM Signal Generation using AVR Timers

June 22nd, 2010 | by | technology

Jun
22

Microcontrollers can only generate a high voltage of +5V and a low voltage of 0V. Let’s say you need a +2.5V for controlling the brightness of LED or the speed of the DC motor. To handle such situations, we use Pulse Width Modulation (PWM). In PWM, we will vary the output voltage between high and low at a very high speed, such that, the effective output voltage is the desired voltage. For example, for +2.5V, we will switch between high and low voltage alternatively, at a very high speed. The output wave is actually square in nature, but at a very high frequency, we can safely assume the average as the output voltage.

PWM

More information about PWM and the code for this example can be found at:

Comments Closed

Bipolar stepper motor controller using AVR microcontroller and L298N motor driver

June 22nd, 2010 | by | technology

Jun
22

In this video, we’ll see how to control the bipolar stepper motor using the AVR ATMega32 microcontroller and L298N motor driver. Both the motors ports A & B are enabled, by connecting the EnableA and EnableB lines to PB0 and PB1 respectively. Both the PB0 and PB1 pins are always at high volatge. The input lines of the L298N motor driver board 1,2,3,4 are connected to Port PB7, PB6, PB5, PB4 respectively. Now, the voltage is varied on the input lines of the L298N motor driver using the ATMega32 microcontroller, causing the change in voltage at the motor input lines, i.e., the L298N motor driver output lines. This causes the stepper motor to rotate.

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
  DDRB=0xFF;
  while(1)
  {
    //Normal Bipolar Stepping
    PORTB = 0b10010011;
    _delay_ms(10);
    PORTB = 0b01010011;
    _delay_ms(10);
    PORTB = 0b01100011;
    _delay_ms(10);
    PORTB = 0b10100011;
    _delay_ms(10);
  }
}

No Comments »

Interfacing DS1307 RTC Chip with AVR Microcontroller

June 19th, 2010 | by | technology

Jun
19

DS1307 is a Real Time Clock Chip, which can manage time without external power, using a +3V lithium cell. It can also store date and year. In the example we will interface DS1307 RTC Chip with ATMega32 microcontroller and create a clock example, that will display the time and date.

This example is based on the sample from:

No Comments »