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 / robot.js
Created December 2, 2012 15:08
Robotnik
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot;
robot = ev.robot;
robot.ahead(150);
# 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 %
@andrestc
andrestc / .bash_profile
Last active March 21, 2016 12:32
Colored bash_profile with git branch and aliases
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' -e 's/^[ \t]*//'
}
export PS1="\[\033[36m\]\u\[\033[m\]:\[\033[33;1m\]\w\[\033[m\]:\[\033[00m\]\[\033[31m\]\$(parse_git_branch)\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=GxFxBxDxCxegedabagacad
alias ls='ls -GFh'
# Git aliases
@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 {
#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;
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);
@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]));
}
Verifying that "andrestc.id" is my Blockstack ID. https://onename.com/andrestc
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
void handler(int sig)
{
exit(sig);
}
@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.