Skip to content

Instantly share code, notes, and snippets.

View mtortonesi's full-sized avatar

Mauro Tortonesi mtortonesi

View GitHub Profile
@mtortonesi
mtortonesi / liburing_server_echo.c
Created October 4, 2022 10:12
Simple io_uring echo server example
#include "liburing.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#define QUEUE_DEPTH 32
#define READ_SZ 4096
const std = @import("std");
pub const io_mode = .evented;
const ArgStruct = struct {
// Apparently, the following two lines do not compile because of https://github.com/ziglang/zig/issues/10184
// (also see https://github.com/ziglang/zig/pull/4567 and https://github.com/ziglang/zig/issues/1268)
// in: *@TypeOf(std.io.Reader),
// out: *@TypeOf(std.io.Writer),
// Apparently, the following two lines do not compile because of https://github.com/ziglang/zig/issues/5877
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
int get_port(const char *str)
{
long ret;
char *endptr;
@mtortonesi
mtortonesi / profile_all.sh
Created June 19, 2020 20:41
Profiling script for sisfc
#!/bin/sh
TIME_BASED_ID=$(date +%Y%m%d%H%M%S)
rbenv local jruby-9.2.11.1
export JRUBY_OPTS="-Xcompile.invokedynamic=true"
time bundle exec ./bin/sisfc examples/simulator.conf examples/vm_allocation.conf 2>&1 | tee log_sisfc_jruby_${TIME_BASED_ID}.txt
rbenv local 2.7.1
time bundle exec ./bin/sisfc examples/simulator.conf examples/vm_allocation.conf 2>&1 | tee log_sisfc_mri_${TIME_BASED_ID}.txt
@mtortonesi
mtortonesi / app--controllers--actors_controller.rb
Created December 10, 2019 14:32
Example of dry-validation and dry-transaction adoption within Rails 6
require_relative '../operations/create_actor'
require_relative '../operations/update_actor'
class ActorsController < ApplicationController
# GET /actors
# GET /actors.json
def index
# @actors = Actor.all
@actors = Actor.order(:name).page(params[:page])