Skip to content

Instantly share code, notes, and snippets.

View clemensg's full-sized avatar

Clemens Gruber clemensg

  • Austria
  • 19:58 (UTC +02:00)
View GitHub Profile
@clemensg
clemensg / curl_multi_test.c
Last active July 22, 2025 07:48
libcurl multi interface example
/* curl_multi_test.c
Clemens Gruber, 2013
<clemens.gruber@pqgruber.com>
Code description:
Requests 4 Web pages via the CURL multi interface
and checks if the HTTP status code is 200.
Update: Fixed! The check for !numfds was the problem.
@clemensg
clemensg / tree.rs
Last active May 17, 2025 14:54
Rust tree example
use std::{env,ffi,fs,io,path};
const DEFAULT_DEPTH: usize = 1024;
fn main() -> io::Result<()> {
let max_depth: usize = env::args()
.nth(1)
.and_then(|s| s.parse().ok())
.unwrap_or(DEFAULT_DEPTH);
@clemensg
clemensg / etc_sysctl.conf
Created February 5, 2014 16:50
My FreeBSD /etc/sysctl.conf
# /etc/sysctl.conf
# Clemens Gruber, 2014
#
# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
security.bsd.see_other_uids=0
## I/O
@clemensg
clemensg / curl_libuv_example.c
Last active November 21, 2024 09:50
An example on how to use libuv with libcurl's multi interface Should be equally fast on Unixes (uses epoll/kqueue/etc like libev/libevent) but MUCH faster on Windows due to libuv's usage of IO completion ports. Could come in handy if you have to manage several hundreds or thousands of connections!
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <curl/curl.h>
uv_loop_t *loop;
CURLM *curl_handle;
uv_timer_t timeout;
typedef struct curl_context_s {
@clemensg
clemensg / nginx.service
Created November 22, 2017 22:08
Example nginx service file for systemd
[Unit]
Description=NGINX HTTP and reverse proxy server
After=syslog.target network.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
@clemensg
clemensg / BusyBox-stty-Add-RS485-config-options.patch
Created January 7, 2017 13:30
Patch for Busybox 1.25.1 to add RS-485 configuration to stty
From: Clemens Gruber <clemens.gruber@pqgruber.com>
Date: Thu, 4 Aug 2016 14:51:44 +0200
Subject: [PATCH] stty: RS-485 support
Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
---
coreutils/stty.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 150 insertions(+), 9 deletions(-)
diff --git a/coreutils/stty.c b/coreutils/stty.c
@clemensg
clemensg / etc_make.conf
Last active June 1, 2020 21:37
My FreeBSD make.conf
# /etc/make.conf
# Clemens Gruber, 2017
#
# Nearby mirror
#MASTER_SITE_OVERRIDE="ftp://ftp.at.freebsd.org/pub/FreeBSD/ports/distfiles/"
#MASTER_SITE_OVERRIDE="ftp://ftp.de.freebsd.org/pub/FreeBSD/ports/distfiles/"
# Build
MAKE_JOBS_NUMBER?=8
@clemensg
clemensg / clang-format-problem-1.c
Last active February 10, 2020 13:30
Bug 34649 - clang-format messes up comment indentations - Problem 1
unsigned int
/* a = 1, */ /* Comment A */
b = 2, /* Comment B */
c = 3; /* Comment C */
int main(int argc, char *argv[])
{
return 0;
}
@clemensg
clemensg / clang-format-problem-2.c
Created November 29, 2017 10:13
Bug 34649 - clang-format messes up comment indentations - Problem 2
void main(void)
{
int a = 1;
/* FOO begins */
#ifndef FOO
if (a)
{
return;
}
@clemensg
clemensg / clang-format-problem-3.c
Created November 29, 2017 10:41
Bug 34649 - clang-format messes up comment indentations - Problem 3
void main(void)
{
if (1)
{
/* Comment */
#ifdef FOO
printf("bar");
#endif
}
}