Skip to content

Instantly share code, notes, and snippets.

View koute's full-sized avatar

Koute koute

View GitHub Profile
@koute
koute / calculate-deps.rb
Last active September 8, 2023 11:59
Calculate total lines of code for a Rust crate, local and external (requires `cargo-tree` and `tokei` to be installed)
#!/usr/bin/ruby
require "shellwords"
require "json"
if ARGV.length == 0
extra_args = ""
elsif ARGV.length == 1
extra_args = "-p #{ARGV[0]}"
else
@koute
koute / list-syscalls.rb
Last active February 3, 2024 17:29
A script to statically list syscalls used by a given binary
#!/usr/bin/ruby
require "shellwords"
require "set"
# Generated from `libc` using the following regex:
# 'pub const SYS_([a-z0-9_]+): ::c_long = (\d+);'
# ' \2 => "\1",'
SYSCALLS = {
0 => "read",
#!/usr/bin/ruby
DEFAULT_SYSTEM_CORE_COUNT = 2
USE_MLOCK_ALL = false
exit if ARGV.empty?
raise "/usr/bin/setarch not found" unless File.exist? "/usr/bin/setarch"
raise "/usr/bin/schedtool not found" unless File.exist? "/usr/bin/schedtool"
mlockall_source = <<-EOS
@koute
koute / borrow_vs_as_ref.rs
Created March 15, 2017 18:14
Rust: Borrow vs AsRef
#![allow(non_snake_case)]
#![allow(dead_code)]
use std::borrow::Borrow;
use std::convert::AsRef;
struct Y;
struct X {
y: Y
@koute
koute / opengl3_hello.c
Created November 9, 2013 23:16
Minimal SDL2 + OpenGL3 example.
/*
Minimal SDL2 + OpenGL3 example.
Author: https://github.com/koute
This file is in the public domain; you can do whatever you want with it.
In case the concept of public domain doesn't exist in your jurisdiction
you can also use this code under the terms of Creative Commons CC0 license,
either version 1.0 or (at your option) any later version; for details see:
http://creativecommons.org/publicdomain/zero/1.0/