Skip to content

Instantly share code, notes, and snippets.

View andrestc's full-sized avatar
⛑️
Firefighting

André Carvalho andrestc

⛑️
Firefighting
View GitHub Profile
@andrestc
andrestc / go-missing-examples.md
Last active September 26, 2021 18:49
Go std lib funcs/methods missing examples

About this

This list has the goal of helping developers interested in contributing to the Go language but are unsure of where to start. This was not generated manually so some functions and methods here may not require examples (maybe because they are too simple, e.g .String()) and some of these may only make sense in a package level example (which are not considered for this list yet). Use your best judgment and check the documentation before you open up a CL to add an example.

You should also search in gerrit for open CLs that are already adding examples.

I will try to keep this list as up to date as possible. If you find any mistakes, please comment below and I will try to fix it.

#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
void handler(int sig)
{
exit(sig);
}
Verifying that "andrestc.id" is my Blockstack ID. https://onename.com/andrestc
/* scan_merge scans the free list in order to find
* continuous free blocks that can be merged and also
* checks if our last free block ends where the program
* break is. If it does, and the free block is larger then
* MIN_DEALLOC then the block is released to the OS, by
* calling brk to set the program break to the begin of
* the block */
void
scan_merge()
{
void *
_malloc(size_t size)
{
void *block_mem;
block_t *ptr, *newptr;
size_t alloc_size = size >= ALLOC_UNIT ? size + sizeof(block_t)
: ALLOC_UNIT;
ptr = head;
while (ptr) {
if (ptr->size >= size + sizeof(block_t)) {
@andrestc
andrestc / malloc_test.c
Last active June 14, 2017 15:31
malloc
#include <malloc.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
malloc(atoi(argv[1]));
}
int i, holes = 0;
while ((numRead = read(inputFd, buf, BUF_SIZE)) > 0)
{
if (keepHoles == 1) {
for (i = 0; i < numRead; i++) {
if (buf[i] == '\0') {
holes++;
continue;
} else if (holes > 0) {
lseek(outputFd, holes, SEEK_CUR);
#include <fcntl.h>
#include "tlpi_hdr.h"
#include "error_functions.c"
#include "get_num.c"
int main(int argc, char *argv[])
{
int outputFd, openFlags;
mode_t filePerms;
off_t offset;
@andrestc
andrestc / magic.go
Created May 26, 2017 14:38
reboot(2) magic numbers
package main
import (
"fmt"
"strconv"
)
func main() {
consts := []int64{672274793, 85072278, 369367448, 537993216}
for _, c := range consts {
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %