Skip to content

Instantly share code, notes, and snippets.

making money

JasonWong medusar

making money
  • Beijing,China
View GitHub Profile
medusar / tcp_flags.txt
Created Dec 17, 2020 — forked from tuxfight3r/tcp_flags.txt
tcpdump - reading tcp flags
View tcp_flags.txt
Unskilled Attackers Pester Real Security Folks
Unskilled = URG = (Not Displayed in Flag Field, Displayed elsewhere)
Attackers = ACK = (Not Displayed in Flag Field, Displayed elsewhere)
Pester = PSH = [P] (Push Data)
Real = RST = [R] (Reset Connection)
Security = SYN = [S] (Start Connection)
medusar / udp_to_local.c
Created Jun 10, 2020 — forked from leonid-ed/udp_to_local.c
Examples of using raw sockets (c, linux, raw socket)
View udp_to_local.c
An example of using raw sockets.
You can capture packets by tcpdump:
tcpdump -X -s0 -i lo -p udp
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
medusar /
Created Sep 20, 2019 — forked from benjchristensen/ Example of using Futures for nested calls showing how it blocks inefficiently.
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
medusar / nginx.conf
Created Apr 12, 2019 — forked from yllan/nginx.conf
設定 nginx 使用 server sent event
View nginx.conf
location xxxx {
proxy_pass http://localhost:9000;
proxy_buffering off;
proxy_cache off;
proxy_redirect off;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
medusar /
Created Oct 30, 2018 — forked from josiahcarlson/
Regular and sliding window rate limiting to accompany two blog posts.
Copyright 2014, Josiah Carlson -
Released under the MIT license
This module intends to show how to perform standard and sliding-window rate
limits as a companion to the two articles posted on Binpress entitled
"Introduction to rate limiting with Redis", parts 1 and 2:

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

medusar /
Created Jul 3, 2018
how to flatten a nested map in java8
public void testFlattenMap() {
Map<String, Map<String, Long>> counters = new HashMap<>();
Map<String, Long> nested = new HashMap<>();
nested.put("inner1", 1L);
nested.put("inner2", 2L);
nested.put("inner3", 3L);
counters.put("out1", nested);
counters.put("out2", nested);
medusar /
Created Jul 2, 2018 — forked from caoxudong/
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
medusar /
Created Mar 14, 2018 — forked from yisibl/
在Mac、Linux 终端显示 Git 当前所在分支

在Mac、Linux 终端显示 Git 当前所在分支

  1. 进入你的home目录
cd ~
  1. 编辑.bashrc文件
medusar /
Created Jan 4, 2018 — forked from LanderlYoung/
Linux /proc/<pid>/smaps analyzer python script
#!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
analyze /proc/<pid>/smaps