Skip to content

Instantly share code, notes, and snippets.

View justdoit0823's full-sized avatar

余森彬 justdoit0823

View GitHub Profile
@justdoit0823
justdoit0823 / benchmark_grpc_server.sh
Last active November 22, 2017 07:20
How to do benchmark test for gRPC server.
DEFAULT_GRPC_ENDPOINT="localhost:50051"
# First generate a file filled with gRPC request payload
python -c "import helloworld_pb2; open('/tmp/test.grpc.payload', 'wb').write(helloworld_pb2.HelloRequest(name='Python').SerializeToString())"
echo -e "Payload file has been generated.\n"
if [[ -z $GRPC_ENDPOINT ]]; then
GRPC_ENDPOINT=$DEFAULT_GRPC_ENDPOINT
@justdoit0823
justdoit0823 / show_libraries_referenced_by_executables.md
Created November 23, 2017 13:02
List all libraries used by executables on linux.

Command

  • ldd
lddb executable_file

In some circumstances, some versions of ldd may attempt to obtain the dependency information by directly executing the program.

@justdoit0823
justdoit0823 / http_message_versus_entity.md
Last active January 6, 2018 12:16
A comparision between http message and entity.

Message

HTTP messages consist of requests from client to server and responses from server to client.

HTTP-message   = Request | Response     ; HTTP/1.1 messages
generic-message = start-line
@justdoit0823
justdoit0823 / digest_command_collection.md
Created January 10, 2018 06:24
A collection of digest commands.

Mac OSX

  • md5
md5 -r filename
@justdoit0823
justdoit0823 / netcat_examples.md
Last active April 15, 2023 20:23
A collection of examples about using netcat.

Netcat Examples

Establish TCP Connection

  • Connect to network host over TCP connection
@justdoit0823
justdoit0823 / list_top_output_memory_clients.sh
Last active February 23, 2018 06:50
List top redis output memory cliens.
# List top ten output memory redis clients
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_PSW client list|awk '{split($2, addr, "="); split($16, omem, "="); print addr[2], omem[2], $0}'|awk '$2 > 0'|sort -nr -k 2|head -10
# List redis client processes
ss -p '( sport == $REDIS_ADDR ) and ( dport == 6379 )'|awk '{split($NF, a, "pid="); split(a[2], b, ",fd"); if(b[1]) {if(pids) pids=b[1]","pids; else pids=b[1]}} END {print "-p "pids" -o pid,ppid,pgid,sid,cmd"}'|xargs ps
@justdoit0823
justdoit0823 / celery_task_memory_estimation.md
Last active March 29, 2018 08:58
An estimation of celery task memory usage.
  • average task size

1000B

  • redis memory encoding type

list

  • capacity
import asyncio
import threading
from tornado.ioloop import IOLoop
def non_main_thread_task(g_io_loop):
assert IOLoop.current(False) is None, "invalid current thread's ioloop object."
assert IOLoop.current() is g_io_loop, "invalid current thread's ioloop object."
io_loop = IOLoop()
@justdoit0823
justdoit0823 / top_100_ai_companies.md
Created March 3, 2018 05:05
A top 100 AI companies from jazzyear.
@justdoit0823
justdoit0823 / why-adding-column-with-default-value-is-harmful.sql
Last active March 4, 2018 14:02
Show how adding column with default value behaves in postgresql.
drop table if exists s_test_adding_column_with_default_value;
create table s_test_adding_column_with_default_value (id int primary key, value int);
insert into s_test_adding_column_with_default_value select id, random() * 100 from generate_series(1, 500) as id;
select ctid, * from s_test_adding_column_with_default_value where id = 1 or id = 500;
alter table s_test_adding_column_with_default_value add column score1 float;