Today, I was asked a question that Does Java pass by reference or pass by value?
A popular mistake is that when we pass primitives like int, char, etc. it pass by value, and when we pass objects, it pass by reference.
SY -> CS -> LA -> SEA
Today, I was asked a question that Does Java pass by reference or pass by value?
A popular mistake is that when we pass primitives like int, char, etc. it pass by value, and when we pass objects, it pass by reference.
I am studying mongoDB with python, I met this problem.
When I tried to open a url by python, I copied some code from internet like following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import json import urllib2 import pymongo # connect to mongo connection = pymongo.MongoClient("mongodb://localhost") # get a handle to the reddit database db = connection.reddit stories = db.stories # drop existing collection stories.drop() # get the reddit home page reddit_page = urllib2.urlopen("https://www.reddit.com/r/technology/.json") # parse the json into python objects parsed = json.loads(reddit_page.read()) # iterate through every news item on the page for item in parsed['data']['children']: # put it in mongo stories.insert_one(item['data']) |
and met this error:
NameError: name urllib2 is not defined
Then I found that ‘urllib2’ is a lib for python2 while I use python3
Solution is easy by changing import lib
1 2 3 |
import urllib.request reddit_page = urllib.request.urlopen("https://www.reddit.com/r/technology/.json") |
At first, you need a sign up for the Google Cloud Platform
https://console.cloud.google.com/freetrial?pli=1&page=0
With this url, you can get two month free trial with a $300 credit for one year.
Continue reading “Running Hadoop program on google cloud platform”
While using crawler4j to crawl some data, I met errors as following:
1 2 3 4 |
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. |
Based on the official document I found solution:
https://www.slf4j.org/codes.html#StaticLoggerBinder
Then I downloadedlogback and import logback-classic.jar
.
Perfect!
These days, I changed one of my Node.js Application from AWS to Azure. However, some functions do not work after migrating.