Skip to content

Instantly share code, notes, and snippets.

View selfboot's full-sized avatar
🎯
Focusing

selfboot selfboot

🎯
Focusing
View GitHub Profile
@selfboot
selfboot / ebpf-func-time.cpp
Last active June 30, 2023 06:20
In the common product business, the distribution of time consumption of functions is usually uneven, so in order to get closer to the real world, we deliberately designed this function so that its P99 (99th percentile) time consumption is significantly larger than the average time consumed.
#include <iostream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <thread>
class Timer {
public:
@selfboot
selfboot / func_time_hist.py
Last active June 30, 2023 08:34
bcc monitors process function execution time
from __future__ import print_function
import os
from bcc import BPF
from time import sleep
import numpy as np
import argparse
from collections import defaultdict
# Argument parsing
parser = argparse.ArgumentParser(description="Measure function duration for a specific PID")

ai_tutor

Name: Mr. Ranedeer Author: JushBJJ Version: 2.5

Features

Personalization

Depth

This is the level of depth of the content the student wants to learn. The lowest depth level is 1, and the highest is 10.

@selfboot
selfboot / waiter.h
Created October 11, 2019 10:05 — forked from chenshuo/waiter.h
A handful of implementations of Waiter class for discussion.
#include <boost/noncopyable.hpp>
#include <pthread.h>
#include <stdlib.h>
// a superfluous check for pedantic people
inline void CHECK_SUCCESS(int ret)
{
if (ret != 0)
{
abort();
@selfboot
selfboot / test_backtrace.cpp
Created June 17, 2019 02:48 — forked from owent/test_backtrace.cpp
test_backtrace
/**
* traceback for cpp
*
* Created on: 2018-01-27
* Author: owent
*
* Released under the MIT license
*
* @note Required flag -rdynamic or addr2line to get the function name when using gcc/clang in unix like system
* @note Using addr2line -Cfpe <exe_path> [func_addr...] for more detail when using gcc/clang
@selfboot
selfboot / py_scripts.md
Last active April 29, 2019 07:51
py_scripts.md

You can use os.path.expanduser to convert ~ into your home directory:

>>> import os
>>> os.path.expanduser('~/.config.txt')
'/root/.config.txt'
>>>

This works on both *nix and Windows systems.

!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var i=r();for(var e in i)("object"==typeof exports?exports:t)[e]=i[e]}}(window,function(){return function(t){var r={};function i(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=r,i.d=function(t,r,e){i.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,r){if(1&r&&(t=i(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(i.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var n in t)i.d(e,n,function(r){return t[r]}.bind(null,n));return e},i.n=function(t){var r=t&&t.__esModule?function(){return
@selfboot
selfboot / OpenSSLExample.cpp
Created December 25, 2018 09:21 — forked from irbull/OpenSSLExample.cpp
Code signing and verification with OpenSSL
#include <iostream>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <assert.h>
// Random number generator - requires a PRNG backend, e.g. prng4.js
// For best results, put code like
// <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>
// in your main HTML document.
var rng_state;
var rng_pool;
var rng_pptr;
@selfboot
selfboot / Nginx-centos.md
Created September 25, 2017 08:19
Centos Install Nginx

centopia | the nginx build guide

This is a step-by-step guide on how to build Nginx-1.6.2 from source on a CentOS 7 VPS or Virtualbox.

Manual Build

update yum to use current & stable CentOs libraries

$ yum -y update