Skip to content

Instantly share code, notes, and snippets.

String json = ReadUrl.readUrl("https://nid.naver.com/oauth2.0/token?client_id=YOURCLIENTID&client_secret=YOURCLIENTSECRET&grant_type=authorization_code&state=YOURSTATETOKEN&code=AUTHORIZATIONCODE");
JSONObject jsonObj = null;
jsonObj = (JSONObject) JSONValue.parse(json);
AccessToken accessToken = new AccessToken(jsonObj.get("access_token").toString(), jsonObj.get("refresh_token").toString(), jsonObj.get("token_type").toString(), jsonObj.get("expires_in").toString());
HttpTransport transport = new NetHttpTransport();
//google-oauth-java-client
Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken.getAccessToken());
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
httpResponse = requestFactory.buildGetRequest(new GenericUrl("https://apis.naver.com/nidlogin/nid/getUserProfile.xml")).execute();
InputStream is = httpResponse.getContent();
//xml 파싱
DocumentBuilderFactory docbuildFact = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuild = docbuildFact.newDocumentBuilder();
Document doc = docBuild.parse(is);
doc.getDocumentElement().normalize();
//response
NodeList responseNaver = doc.getElementsByTagName("response");
Node responseNode = responseNaver.item(0);
Element responseElement = (Element) responseNode;
//이메일 가져오기
webApp.setWar(warPath.getAbsolutePath());
File warTempDirectory = new File(conf.getString(ConfVars.ZEPPELIN_WAR_TEMPDIR));
warTempDirectory.mkdir();
LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
webApp.setTempDirectory(warTempDirectory);
@mwkang
mwkang / bash
Created February 28, 2016 05:02
GEM_HOME=/usr/local/bin
@mwkang
mwkang / gem
Created February 28, 2016 05:06
sudo gem install -n /usr/local/bin GEM_NAME_HERE
@mwkang
mwkang / internedstrings.java
Created May 16, 2016 09:01
test for interned strings
{
List<String> set = Lists.newArrayList();
for (int i = 0; i < 5; i++) {
String a = new String("a");
String b = "a";
System.out.println(System.identityHashCode(a));
System.out.println(System.identityHashCode(b));
set.add("c");
System.out.println("?? =====> " + System.identityHashCode(set.get(0)));
set.clear();
@Override
public int getProgress(InterpreterContext context) {
open();
return intp.getProgress(context);
}
@mwkang
mwkang / hbase hbaseid
Created August 9, 2016 05:42
/hbase/hbaseid 주키퍼에 접근할 수 없을 때 발생하는 stacktrace
2016-08-02 11:34:31,836 ERROR [main] zookeeper.ZooKeeperWatcher: hconnection-0x6c302a1d0x0, quorum=localhost:2181, baseZNode=/hbase Received unexpected KeeperException, re-throwing exception
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1102)
at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:220)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:416)
at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:65)
at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:102)
at org.apache.hadoop.hbase.client.ConnectionImplementation.retrieveClusterId(ConnectionImplementation.java:443)
[INFO] Zeppelin ...........................................
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p