Skip to content

Instantly share code, notes, and snippets.

@hivefans
hivefans / Korpse.scala
Last active March 17, 2020 02:03 — forked from ariens/Korpse.scala
Kafka Offset Range Provider/Storage Engine|-|{"files":{"KorpseExample.scala":{"env":"plain"},"Korpse.scala":{"env":"plain"}},"tag":"Uncategorized"}
package com.blackberry.bdp.korpse
import scala.collection.parallel.ParIterable
import scala.collection.mutable
import scala.collection.mutable.{ Map => MutableMap }
import org.apache.spark.streaming.kafka.OffsetRange
import kafka.api._
import kafka.api.OffsetResponse
@hivefans
hivefans / authorize.lua
Last active March 17, 2020 02:03 — forked from philwinder/authorize.lua
IVZ: Nginx config for using Lua as the authentication module. You must install nginx with lua support. See "openresty" for linux distros or the vagrant bootstrap shell script.|-|{"files":{"nginx_authorize_by_lua_kibana.conf":{"env":"plain"},"nginx_authorize_by_lua.conf":{"env":"plain"},"htpasswd":{"env":"plain"},"authorize.lua":{"env":"plain"}},…
--[[
Provides custom authorization for nginx.
See the `nginx_authorize_by_lua.conf` for the Nginx config. This lua file is referenced in the config
See testWebserverAccess.sh for unit tests.
To Run nginx (make sure you have the lua, config and htpasswd file):
$ /usr/local/openresty/nginx/sbin/nginx -c /etc/nginx/conf/nginx_authorize_by_lua.conf
Logs are available at: /usr/local/openresty/nginx/logs/lua.log
To write to the log:
@hivefans
hivefans / access.lua
Last active March 17, 2020 02:03 — forked from mariocesar/access.lua
Nginx Lua script redis based for Basic user authentication|-|{"files":{"vhost.conf":{"env":"plain"},"access.lua":{"env":"plain"}},"tag":"Uncategorized"}
function password_encode(password)
local bcrypt = require 'bcrypt'
return bcrypt.digest(password, 12)
end
function check_password(password, encoded_password)
local bcrypt = require 'bcrypt'
return bcrypt.verify(password, encoded_password)
end
@hivefans
hivefans / example.txt
Last active March 17, 2020 02:03
openresty中的lua配置调试递归显示table内容,在连接mysql,redis中可以查看table结构|-|{"files":{"example.txt":{"env":"plain"},"ngx_rPrint.lua":{"env":"plain"}},"tag":"Uncategorized"}
res,err,errcode,sqlstate=db:query("select * from user where username='test'")
if next(res) ~=nil then
rPrint(res,nil,"res----");
end
res--------table
res---- [1] ----table
res---- [1] [role_id] ----number----1
res---- [1] [username] ----string----jack
@hivefans
hivefans / shardallocate.sh
Last active March 17, 2020 02:03
|-|{"files":{"shardallocate.sh":{"env":"plain"}},"tag":"bigdata"}
function reroute() {
curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -d '{
"commands" : [ {
"allocate" : {
"index" : "'$1'",
"shard" : '$2'
"allow_primary" : true,
"node" : "<node>"
}
}
@hivefans
hivefans / auto_relocate.py
Last active March 17, 2020 02:03 — forked from simonluijk/auto_relocate.py
|-|{"files":{"auto_relocate.py":{"env":"plain"}},"tag":"bigdata"}
#!/usr/bin/env python
import sys
from random import choice
from argparse import ArgumentParser
from pprint import pprint
from elasticsearch import Elasticsearch
def auto_relocate(host='localhost'):
@hivefans
hivefans / flume-monitor.py
Last active March 17, 2020 02:04
flume-monitor|-|{"files":{"zookeeper-monitor.sh":{"env":"plain"},"flume-monitor.py":{"env":"plain"}},"tag":"Uncategorized"}
#!/usr/bin/python
"""
Copyright 2013 Nextdoor.com, Inc.
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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@hivefans
hivefans / monitor_process.py
Last active March 17, 2020 02:03
|-|{"files":{"monitor_process.py":{"env":"plain"}},"tag":"bigdata"}
#!/bin/env python
#-*- coding:utf-8 -*-
import os,sys
import os.path
from os.path import isfile
from traceback import format_exc
import xmlrpclib
import socket
import time
@hivefans
hivefans / sitemonitor.py
Last active March 17, 2020 02:03
网页监控|-|{"files":{"sitemonitor.py":{"env":"plain"}},"tag":"bigdata"}
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle
import os
import logging
import time
import re
from optparse import OptionParser, OptionValueError
@hivefans
hivefans / gossiper.py
Last active March 17, 2020 02:04
|-|{"files":{"gossiper.py":{"env":"plain"}},"tag":"bigdata"}
#!/usr/bin/env python
"""
This simple Python program implements a gossip network protocol. It is
intended only for fun and learning.
Written and directed by Stephane Bortzmeyer
<[email protected]> Licence as liberal as you want but no
warranty.