Skip to content

Instantly share code, notes, and snippets.

View mezantrop's full-sized avatar
🔀
See my other projects: https://gitlab.com/users/mezantrop/projects

Mikhail Zakharov mezantrop

🔀
See my other projects: https://gitlab.com/users/mezantrop/projects
View GitHub Profile
@kazuho
kazuho / sockaddr_cmp.c
Last active April 9, 2022 18:05
compare sockaddr
/*
* As of May 25 2021, this code is provided as CC0 / public domain (Kazuho Oku)
*
* Copyright (c) 2014 Kazuho Oku
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@bladeSk
bladeSk / SQLite-PHP-quickstart.php
Last active July 4, 2024 06:42
SQLite3 PHP Quickstart Tutorial
<?php
// This file walks you through the most common features of PHP's SQLite3 API.
// The code is runnable in its entirety and results in an `analytics.sqlite` file.
// Create a new database, if the file doesn't exist and open it for reading/writing.
// The extension of the file is arbitrary.
$db = new SQLite3('analytics.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
// Errors are emitted as warnings by default, enable proper error handling.
@nguyen-phillip
nguyen-phillip / proc.c
Last active November 30, 2023 13:01
Using libproc.h
#include <stdio.h>
#include <stdlib.h>
#include <libproc.h>
// Uses proc_pidinfo from libproc.h to find the parent of given pid.
// Call this repeatedly until ppid(pid) == pid to get ancestors.
int ppid(pid_t pid) {
struct proc_bsdinfo info;
proc_pidinfo(pid, PROC_PIDTBSDINFO, 0, &info, sizeof(info));
return info.pbi_ppid;
@fnky
fnky / ANSI.md
Last active July 7, 2024 15:39
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27