Skip to content

Instantly share code, notes, and snippets.

@hn5092
hn5092 / checkStyle.js
Created May 28, 2015 11:40
自动检测Input输入格式.并且返回结果
/**
* create by imad.x
* email:100650920@qq.com
*/
var app = angular.module('plunker', []);
function createDirective() {
return function () {
return {
restrict: 'A',
compile: function (tElem, tAttrs) {
@hn5092
hn5092 / MultipleOutputsExample.scala
Created February 26, 2016 08:42 — forked from mlehman/MultipleOutputsExample.scala
Hadoop MultipleOutputs on Spark Example
/* Example using MultipleOutputs to write a Spark RDD to multiples files.
Based on saveAsNewAPIHadoopFile implemented in org.apache.spark.rdd.PairRDDFunctions, org.apache.hadoop.mapreduce.SparkHadoopMapReduceUtil.
val values = sc.parallelize(List(
("fruit/items", "apple"),
("vegetable/items", "broccoli"),
("fruit/items", "pear"),
("fruit/items", "peach"),
("vegetable/items", "celery"),
("vegetable/items", "spinach")
@hn5092
hn5092 / HDFSUtil.scala
Created March 31, 2016 02:13
mv files to table dir
def moveFile(day: String, fileSystem: FileSystem): Unit = {
val status: Array[FileStatus] = fileSystem.listStatus(new Path(TableConstents.TEMP_TRANSFER_TABLE_PATH + day))
status.foreach {
s =>
if (s.isDirectory) {
fileSystem.listStatus(s.getPath).foreach {
p =>
val path: String = p.getPath.toString
//1.replace path
val newPath = path.replace("/temp/" + day, "")
@hn5092
hn5092 / common.scala
Created April 1, 2016 05:55
reduce is args is head,s fold
object common extends App {
val a = "s"
println(s"wo kao $a")
case class Foo(val name: String, val age: Int, val sex: Symbol)
val fooList = Foo("Hugh Jass", 25, 'male) ::
Foo("Biggus Dickus", 43, 'male) ::
Foo("Incontinentia Buttocks", 37, 'female) ::
Nil
private static enum SingletonHolder {
INSTANCE;
Object lock = new Object();
SpanReceiverHost host = null;
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@hn5092
hn5092 / ExecutorCompletionService.java
Created July 19, 2016 08:50
how to use futuretask
public class ExecutorCompletionService<V> implements CompletionService<V> {
private final Executor executor;
private final AbstractExecutorService aes;
private final BlockingQueue<Future<V>> completionQueue;
/**
* FutureTask extension to enqueue upon completion
*/
private class QueueingFuture extends FutureTask<Void> {
QueueingFuture(RunnableFuture<V> task) {
@hn5092
hn5092 / HRegion.java
Created July 19, 2016 08:53
user executorcompletionservice
CompletionService<HStore> completionService =
new ExecutorCompletionService<HStore>(storeOpenerThreadPool);
// initialize each store in parallel
for (final HColumnDescriptor family : htableDescriptor.getFamilies()) {
status.setStatus("Instantiating store for column family " + family);
completionService.submit(new Callable<HStore>() {
@Override
public HStore call() throws IOException {
return instantiateHStore(family);
@hn5092
hn5092 / DefaultMemStore.java
Created July 20, 2016 01:52
singletion obj
Collections.<KeyValueScanner> singletonList(new MemStoreScanner(readPt));
@hn5092
hn5092 / bootstrap.js
Created August 16, 2016 02:39
angular watch
$rootScope.$watch('tmpChartCount', function (newValue, oldValue, isRefren) {
console.log("change");
if ($rootScope.tmpChartMap.count() > 0)
$rootScope.tmpChartMap.forEach(function (k, v) {
$http.get(v.url).then(function (response) {
v.data = response.data;
v.draw();
$rootScope.chartMap.set(k, v);
$rootScope.tmpChartMap.remove(k);
});