Skip to content

Instantly share code, notes, and snippets.

View Ben-PH's full-sized avatar

Ben Ben-PH

  • Cornus, France
View GitHub Profile
@Ben-PH
Ben-PH / spacemacs-cheshe.md
Last active August 27, 2019 05:29 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@Ben-PH
Ben-PH / TCPServer.c
Created October 7, 2019 22:28
The meat and bones of setting up a listen queueueueueue
int wait_size = 5; // maximum number of waiting clients
if (listen(listen_sock, wait_size) < 0) {
printf("could not open socket for listening\n");
return 1;
}
@Ben-PH
Ben-PH / strace.md
Last active June 6, 2020 02:56
Comaprison of C and Rust syscalls on startup/shutdown.

Abstract

For some situations, understanding system calls made during processes start-up and shut-down can be valuable. For example, consider a shell-scripts long-running hot loop that runs a very short-running process. Thus it is perhaps reasonable to hypothesise that a difference in system calls during process start-up/shut-down has a non-negligable impact on the run time of said hot-loop.

This write-up looks at how C and Rust programs differ in terms of system-calls for start-up/shutdown. It is not intended as a performance analysis and only looks at one target system.

At the end, we take a quick look at using statically linked libraries by building with # cargo build --target x86_64-unknown-linux-musl --release and removing even more syscalls by removing the main function

System

@Ben-PH
Ben-PH / lib.rs
Created August 4, 2020 13:01
why is line 47 requiring 'static?
use seed::{prelude::*, *};
use serde::{Deserialize, Serialize};
fn init(_: Url, orders: &mut impl Orders<Message>) -> Model {
log!("I N I T I A L I Z E");
// orders.subscribe(Message::UrlChanged);
// orders.send_msg(Message::GoToUrl(Url::new().set_path(&["login"])));
Model::default()
}