Skip to content

Instantly share code, notes, and snippets.

View xealits's full-sized avatar
🥘

Alex Toldaiev xealits

🥘
View GitHub Profile
@subfuzion
subfuzion / curl.md
Last active May 31, 2025 17:08
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@brendangregg
brendangregg / usdt
Created January 29, 2016 17:24
usdt (ftrace)
#!/bin/bash
#
# usdt - trace user statically defined tracepoints. User-level dynamic tracing.
# Written using Linux ftrace. Experimental.
#
# WARNING: This is a proof of concept for USDT tracing from Linux ftrace, and
# is not safe to use in production environments. In particular, the -i option
# sets memory semaphores by piping the output of printf through dd and then
# to process memory via /proc/PID/mem. Yes, this program pipes the output of
# the shell directly over top of live process memory. If you don't understand
@drmalex07
drmalex07 / README-oneshot-systemd-service.md
Last active July 7, 2024 19:47
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@tribut
tribut / btrfs-scrub.sh
Created September 15, 2015 21:45
Btrfs scrub cronjob with logs from systemd's journalctl
#!/bin/sh
# also see http://marc.merlins.org/perso/btrfs/post_2014-03-19_Btrfs-Tips_-Btrfs-Scrub-and-Btrfs-Filesystem-Repair.html
for fs in $(grep ' btrfs ' /proc/mounts | cut -d' ' -f1 | sort -u)
do
starttime="$(date "+%Y-%m-%d %H:%M:%S")"
logger "Starting btrfs scrub on $fs"
btrfs scrub start -Bd "$fs"
journalctl -q -k --since "$starttime" | grep BTRFS
@david7482
david7482 / C++11_string_swtich.cpp
Last active December 14, 2023 21:09
Use C++11's constexpr to achieve string switch
// http://stackoverflow.com/a/107657
constexpr unsigned long long int HashStringToInt(const char *str, unsigned long long int hash = 0)
{
return (*str == 0) ? hash : 101 * HashStringToInt(str + 1) + *str;
}
void simple_switch(const std::string &str)
{
switch (HashStringToInt(str.c_str()))
{
xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ xsd cxx-tree hello.xsd
xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ ls
driver.cxx hello.cxx hello.hxx hello.xml hello.xsd makefile README
xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ cat hello.hxx
// Copyright (c) 2005-2014 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema to
// C++ data binding compiler.
@dzeban
dzeban / jprobe_etn_io.c
Last active November 5, 2018 23:43
jprobes example
/*
* Here's a sample kernel module showing the use of jprobes to dump
* the arguments of third-party network driver for Bercut ETN.
*
* For more information on theory of operation of jprobes, see
* Documentation/kprobes.txt
*
* Build and insert the kernel module as done in the kprobe example.
* You will see the trace data in /var/log/messages and on the
* console whenever do_fork() is invoked to create a new process.
@junegunn
junegunn / gist:f4fca918e937e6bf5bad
Last active May 18, 2025 18:46
Browsing git commit history with fzf
# fshow - git commit browser (enter for show, ctrl-d for diff, ` toggles sort)
fshow() {
local out shas sha q k
while out=$(
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --multi --no-sort --reverse --query="$q" \
--print-query --expect=ctrl-d --toggle-sort=\`); do
q=$(head -1 <<< "$out")
k=$(head -2 <<< "$out" | tail -1)
What exactly is "iowait"?
To summarize it in one sentence, 'iowait' is the percentage
of time the CPU is idle AND there is at least one I/O
in progress.
Each CPU can be in one of four states: user, sys, idle, iowait.
Performance tools such as vmstat, iostat, sar, etc. print
out these four states as a percentage. The sar tool can
print out the states on a per CPU basis (-P flag) but most
@kfei
kfei / fileio3.py
Created October 13, 2014 02:35
A Python3 ZMQ file transfer example
# File Transfer model #3
#
# In which the client requests each chunk individually, using
# command pipelining to give us a credit-based flow control.
import os
import sys
from threading import Thread
import zmq