Skip to content

Instantly share code, notes, and snippets.

View dantin's full-sized avatar
🎯
Focusing

David Ding dantin

🎯
Focusing
  • Shanghai
View GitHub Profile
@dantin
dantin / docker-compose.yml
Created January 3, 2018 11:40
wormhole's docker-compose
version: '2'
services:
zookeeper:
# use official zookeeper image
image: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
package main
import (
"database/sql"
"flag"
"fmt"
"os"
"os/signal"
"strings"
"sync"
# -*- coding: utf-8 -*-
import argparse
import logging
import sys
import threading
import pymysql.cursors
from datetime import datetime
package main
import (
"database/sql"
"flag"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
@dantin
dantin / setup.sh
Created September 29, 2017 07:16
spf13's vim setup script
#!/usr/bin/env bash
# Copyright 2014 Steve Francia
#
# Licensed 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
#
func init() {
rand.Seed(time.Now().UnixNano())
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func RandStringRunes(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
@dantin
dantin / HadoopMapReduceJobTemplate.java
Last active March 14, 2016 06:21
Hadoop MapReduce Code Template
/**
* Template class for Hadoop MapReduce Job
*/
public class HadoopMapReduceJobTemplate extends Configured implements Tool {
/**
* Mapper
*/
public static class MapClass extends MapReduceBase implements Mapper<Text, Text, Text, Text> {
public void map(Text key, Text value,
@dantin
dantin / PutMerge.java
Last active March 11, 2016 10:00
PutMerge sample Hadoop example
/**
*
* 拷贝本地目录下的所有文件至HDFS
*
*/
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
@dantin
dantin / spring-waring
Created March 10, 2016 10:06
Advanced wire
@Autowired
public void setDessert(Dessert dessert) {
this.dessert = dessert;
}
===
Dessert.java接口有多个实现类
public Employee getEmployeeById(long id) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = dataSource.getConnection();
stmt = conn.prepareStatement(
"select id, firstname, lastname, salary from " +