Skip to content

Instantly share code, notes, and snippets.

View lbiaggi's full-sized avatar

Lucas Biaggi lbiaggi

  • 17:45 (UTC +01:00)
View GitHub Profile
@lbiaggi
lbiaggi / simple-calculator.rs
Created January 18, 2022 19:41
Calculator with support for overflow/underflow
use std::env;
fn sub(a: u64, b:u64) -> u64 {
a.wrapping_sub(b)
}
fn add(a:u64, b:u64) -> u64 {
a.wrapping_add(b)
}
fn main() {
let args: Vec<String> = env::args().collect();
let result: u64 = if &args[3] == "add" {
@lbiaggi
lbiaggi / closures-basic.c
Created July 16, 2021 14:16 — forked from vidarh/closures-basic.c
A number of ways to implement closures in C, in preparation of an upcoming blog post
#include <stdio.h>
#include <stdlib.h>
struct closure {
void (* call)(struct closure *);
int x;
};
@lbiaggi
lbiaggi / closure-wrap-function.c
Created July 16, 2021 14:16 — forked from cyfdecyf/closure-wrap-function.c
Examples to wrap function in C in different ways (workable or not)
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
// This code can now only work on Linux system.
// It has some problem on OS X. Maybe I'll fix it someday.
#if __WORDSIZE != 64 || !defined(__x86_64__)
#error "This program only works on IA64 machine."
@lbiaggi
lbiaggi / ltex.lua
Last active October 20, 2023 19:27
ltex-ls support WIP
--- BEFORE USING, change language entries to fit your needs.
local lspconfig = require'lspconfig'
local configs = require'lspconfig/configs'
local util = require 'lspconfig/util'
local Dictionary_file = {
["pt-BR"] = {vim.fn.getenv("NVIM_HOME") .. "spell/dictionary.txt"} -- there is another way to find ~/.config/nvim ?
}
local DisabledRules_file = {