Skip to content

Instantly share code, notes, and snippets.

View DavadDi's full-sized avatar

DavadDi DavadDi

View GitHub Profile
@DavadDi
DavadDi / readme.md
Created February 17, 2022 12:14 — forked from jasonkarns/readme.md
Git send-email using Gmail
  1. Configure git.
# ~/.config/git/config
[sendemail]
  confirm = auto
  smtpServer = smtp.gmail.com
  smtpServerPort = 587
  smtpEncryption = tls
  smtpUser = <gmail email address>
@DavadDi
DavadDi / sync-projects
Created September 27, 2021 07:42 — forked from JonasGroeger/sync-projects
Gitlab: Clone / Pull all projects in a group
#!/usr/bin/env bash
# Documentation
# https://docs.gitlab.com/ce/api/projects.html#list-projects
NAMESPACE="YOUR_NAMESPACE"
BASE_PATH="https://gitlab.example.com/"
PROJECT_SEARCH_PARAM=""
PROJECT_SELECTION="select(.namespace.name == \"$NAMESPACE\")"
PROJECT_PROJECTION="{ "path": .path, "git": .ssh_url_to_repo }"
// hijack.c
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#include <asm/uaccess.h> /* for copy_from_user */
#include <linux/fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/kallsyms.h>
#include <linux/cpu.h>
@DavadDi
DavadDi / traceicmpsoftirq.py
Created November 27, 2020 02:02 — forked from theojulienne/traceicmpsoftirq.py
ICMP packet tracer using BCC
#!/usr/bin/python
bpf_text = """
#include <linux/ptrace.h>
#include <linux/sched.h> /* For TASK_COMM_LEN */
#include <linux/icmp.h>
#include <linux/netdevice.h>
struct probe_icmp_data_t
{
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# author: guiu
# data: 2020.2.28
import requests
import json
import mimetypes
import argparse
import sys
/*
Copyright (c) 2016, Nitin Gode
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
@DavadDi
DavadDi / skbtracer.c
Created August 10, 2020 04:23 — forked from chendotjs/skbtracer.c
ebpf-skbtracer
#include <bcc/proto.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <uapi/linux/icmp.h>
#include <uapi/linux/tcp.h>
#include <uapi/linux/udp.h>
#include <uapi/linux/icmpv6.h>
#include <net/inet_sock.h>
#include <linux/netfilter/x_tables.h>
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
field.cattle.io/publicEndpoints: '[{"addresses":["172.25.11.99"],"port":80,"protocol":"HTTP","serviceName":"qtt-infra-dev:adcoder","ingressName":"qtt-infra-dev:ingress-weight-test","hostname":"adcoder.cdad3fc3448684306b7f8003e6ceeb429.cn-zhangjiakou.alicontainer.com","path":"/version","allNodes":false},{"addresses":["172.25.11.99"],"port":80,"protocol":"HTTP","serviceName":"qtt-infra-dev:adcoder-test","ingressName":"qtt-infra-dev:ingress-weight-test","hostname":"adcoder.cdad3fc3448684306b7f8003e6ceeb429.cn-zhangjiakou.alicontainer.com","path":"/version","allNodes":false}]'
nginx.ingress.kubernetes.io/service-weight: 'adcoder: 200, adcoder-test: 200'
creationTimestamp: 2019-09-02T12:07:10Z
generation: 1
name: ingress-weight-test
namespace: qtt-infra-dev
@DavadDi
DavadDi / nginx.conf
Created September 13, 2019 14:02
ingress nginx example
# Configuration checksum: 15488413709381799850
# setup custom paths that do not require root access
pid /tmp/nginx.pid;
load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;
daemon off;
-- k8s.io/ingress-nginx/rootfs/etc/nginx/lua/
local ngx_balancer = require("ngx.balancer")
local cjson = require("cjson.safe")
local util = require("util")
local dns_util = require("util.dns")
local configuration = require("configuration")
local round_robin = require("balancer.round_robin")
local chash = require("balancer.chash")
local chashsubset = require("balancer.chashsubset")
local sticky = require("balancer.sticky")