Skip to content

Instantly share code, notes, and snippets.

@jintao-zero
jintao-zero / redis-list-transfer.sh
Last active April 1, 2017 07:11
使用shell redis-cli命令迁移list类型数据
#!/bin/sh
if [ $# -lt 1 ]
then
echo $0 list-key
exit
fi
src_redis_host="dsff.redis.rds.aliyuncs.com"
src_redis_passwd="wwwww"
src_redis_db=15
@jintao-zero
jintao-zero / weibo_search_page.py
Last active February 28, 2020 15:52
解析微博搜索结果,获取微博内容和博主信息
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
import urllib
import urllib2
from lxml import etree
import time
import random
import logging
@jintao-zero
jintao-zero / mafengwo.py
Created April 4, 2017 09:09
将马蜂窝旅游网站中关于某个旅游景点的旅游攻略下载到本地
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib
import urllib2
from lxml import etree
import time
import random
package main
import (
"flag"
"fmt"
)
var name = flag.String("name", "", "the name ")
var age int
@jintao-zero
jintao-zero / bash_argument_case.sh
Created August 18, 2017 02:41
bash argument case
#!/bin/sh
if [ $# -lt 1 ]
then
echo $0 opt
echo 'list (list all topic)'
echo 'describe topic (describe topic info)'
echo 'len topic (show topic len)'
fi
case $1 in
list)
@jintao-zero
jintao-zero / python_redis.py
Created August 18, 2017 09:06
python redis test
#!/usr/bin/env python
import redis
print 'this is python redis test'
if __name__ == '__main__':
#redis.Redis
r = redis.Redis()
print r.dbsize()
@jintao-zero
jintao-zero / python_mongo.py
Created August 18, 2017 09:06
python mongo test
#!/usr/bin/env python
import pymongo
import pprint
print 'this is a python test'
mongo_host = 'localhost'
#http://api.mongodb.com/python/current/tutorial.html#getting-a-database
@jintao-zero
jintao-zero / exepath.cpp
Created September 27, 2017 08:11
linux c/c++ get exe path
#include <string>
#include <iostream>
#include <limits.h>
#include <unistd.h>
std::string getexepath()
{
char result[ PATH_MAX ];
ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
return std::string( result, (count > 0) ? count : 0 );
@jintao-zero
jintao-zero / benchmark-commands.txt
Created September 27, 2017 09:21 — forked from jkreps/benchmark-commands.txt
Kafka Benchmark Commands
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
@jintao-zero
jintao-zero / process-check.sh
Created October 24, 2017 06:04
check some process is running, if not start it
#!/usr/bin/env bash
# get dir
fullpath=$(readlink -f "$0")
path=$(dirname "$fullpath")
exec=$path/l2-proxy
#`ps -ef | grep "/root/l2/hsl-level2hq/client/"`
checkresult=$(ps -e -o cmd | grep -v "grep" | grep "$exec" | wc -l)
if [ $checkresult -eq 1 ];