Arda Basoglu
  • Home
  • Blog
  • Links
  • Contact

Hashmap Data Structure in Javascript, Example with Node.js 

1/21/2013

0 Comments

 
  1. // Author: Arda Basoglu, ardabasoglu@gmail.com
  2. // This example demonstrates the use of map like (like hash map in Java and dictionary in C#) data structure
  3. // The code is tested with a machine Node.js installed
  4. // If you have Node.js installed on your machine run the script by writing "node map.example.js" on the console
  5.  
  6. // create a map
  7. var map = {};
  8.  
  9. // Add key, value pairs into the map with random strings
  10. for (var i = 0; i < 500; i++) {
  11.     var item =generateRandomString();
  12.     var value = generateRandomString();
  13.     map[item] = value;
  14. };
  15.  
  16. // Output every key, value pair onto the screen
  17. for (var i in map) {
  18.     console.log("Key: " + i + ", Value: " + map[i]);
  19. }
  20.  
  21. // The function required for generating random strings
  22. function generateRandomString()
  23. {
  24.     var randomString = "";
  25.     var randomStringSource = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  26.  
  27.     for( var i=0; i < 5; i++ ){
  28.         randomString += randomStringSource.charAt(Math.floor(Math.random() * randomStringSource.length));
  29.     }
  30.    
  31.     return randomString;
  32. }
0 Comments

error: The program ['pg_config'] is required

5/31/2012

0 Comments

 

How to fix the installation problem of the module "pg" for Node in Mac OS X

Problem

When you issue npm install pg command to instal pg package for Node on your Mac OS X, you might get an error like this

        "...error: The program ['pg_config'] is required"

Error simply implies that pg installation cannot find pg_config file.

Solution

1. First make sure you installed PostgreSQL.
2. Find the path to your pg_config file. In my case it is /Library/PostreSQL/8.4/bin/pg_config
3. Open the Terminal and enter the following commands one by one    
    
    PG_CONFIG=/Library/PostreSQL/8.4/bin/pg_config
    export PG_CONFIG
    npm install pg
0 Comments

    Author

    Arda Basoglu is a digital marketing agency owner, software engineer/developer, musician. Worked for several companies: TWB, BNB Software, PINC Solutions,  hakia, Nurol,  NTV. 

    Archives

    October 2021
    August 2021
    June 2020
    April 2020
    September 2017
    July 2017
    April 2017
    February 2017
    September 2015
    October 2014
    March 2014
    February 2014
    January 2013
    June 2012
    May 2012
    July 2011
    December 2010
    November 2010
    October 2010
    August 2010
    July 2010
    June 2010
    March 2010
    February 2010
    January 2010
    December 2009
    November 2009
    October 2009
    August 2009
    June 2009
    May 2009

    Categories

    All
    Açık Kaynak
    Algorithms
    Avşa
    Big O Notation
    Certbot
    Database
    Ekmek
    Ekonomi
    Encrypting Settings
    Enflasyon
    Google Maps
    Heroku
    Heroku Rake Fixture Yaml Error
    JavaScript
    Mac Os X
    Magento
    .net
    .net Forms Login Progress Bar
    Node
    Node.js
    Node-postgres
    Personal
    Peynir
    Postgresql
    Rack 1.2.1 Utils.rb Error Heroku
    Ruby On Rails
    Windows 7
    Windows Froms
    Windsurfing
    Wordpress
    Yankoltuk

    RSS Feed

Powered by Create your own unique website with customizable templates.