Nodejs : Simple get call using http node module

var http = require('http');

var options = {
  host: 'example.com',
  port: 80,
  path: '/foo.html'
};

http.get(options, function(resp){
  resp.on('data', function(chunk){
    //do something with chunk
  });
}).on("error", function(e){
  console.log("Got error: " + e.message);
});
Advertisements

MongoDb : Case in-sensative search using pymongo

As we all know Json is case sensitive and so is MongoDB, hence searching same name which got save in different case might not return any result. The solution is to do case in-sensative search.

Below is the example of pymongo

db.users.find_one({'name': re.compile(username, re.IGNORECASE)})

Links to Online Guided Meditations

🦋 Links to Online Guided Meditations 🦋
1. Power Meditation 7 minute

2. Om Meditation- 10 minutes

3. Transforming Emotions

4. Journey Within

5. Sound to Silence

6. “Hara Hara” Meditation

7. Breath of Relaxation

8. Shiv- Shakti Meditation

9. Yoga Nidra ( Hindi)

10. Morning Meditation

11. Meditation for Peace ( Hindi)

12. Rudram (Taking shower with Mantra) Mantra Snanam

How to open idea injelliJ from command line

Hi Friends,

It becomes very handy to open project in your IDE without wasting time in navigation from UI. To accomplish the same here is simple way. Run below commands and you are done 😉

curl -L "https://gist.githubusercontent.com/chrisdarroch/7018927/raw/9a6d663fd7a52aa76a943fe8a9bc6091ad06b18d/idea" -o /usr/local/bin/idea
chmod +x /usr/local/bin/idea

usage: open terminal and navigate to your project

idea .

Tested on Mac OS X

Note: If you get a “Permission denied” error, your /usr/local/bin directory probably isn’t writable and you’ll need to install script as the superuser. Run sudo -i, then the two commands above, then exit.

Golang : Pass by Value Vs Pass by Refere

By default every thing in go is pass by value, which means if you pass any argument to a function, it would copy the values passed in another variable and make changes to it in function scope only (with in function block) and does not modify the original value.

Which means whatever you pass to a function in Golang remains immutable and does not get modified. However, if you use pointer then changes would impact the original value.

Try to read below program and understand it:

package main

import "fmt"

type Person struct {
       firstName string
       lastName  string
}

func changeName(p Person) {
       p.firstName = "Bad"
       fmt.Print("inside method with local scope on copy")
       fmt.Println(p)
}

func changeNameWithPointer(p *Person) {
       p.firstName = "Bad"
       fmt.Print("inside method with local scope on pointer")
       fmt.Println(p)
}

func main() {
       person := Person{
              firstName: "Good",
              lastName:  "person",
       }
       fmt.Println("Original value of person", person)
       changeName(person)
       fmt.Print("Outside method with original variable passed as copy")
       fmt.Println(person)

       fmt.Println("\n\n========Pass by pointer will modify values =======")

       fmt.Println("Outside method with original variable", person)
       changeNameWithPointer(&person)
       fmt.Println("Outside method with original variable passed as reference (which is now changed )")
       fmt.Println(person)
}

 

Sample output :

➜ passByValue git:(master) ✗ go run ValueVsReference.go
Original value of person {Good person}
inside method with local scope on copy{Bad person}
Outside method with original variable passed as copy{Good person}
========Pass by pointer will modify values =======
Outside method with original variable {Good person}
inside method with local scope on pointer&{Bad person}
Outside method with original variable passed as reference (which is now changed )
{Bad person}