Skip to content

Instantly share code, notes, and snippets.

View jonatasnona's full-sized avatar
🇧🇷
Working from home

Jonatas Pedraza jonatasnona

🇧🇷
Working from home
View GitHub Profile
@jonatasnona
jonatasnona / .bashrc
Last active December 20, 2015 03:29
bashrc
# cd shortcurs
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
# smart mkdir
alias mkdir='mkdir -pv'
@jonatasnona
jonatasnona / linkedlist.c
Last active December 19, 2015 13:18
Criar um arquivo chamado linked-list.c
#include <stdio.h>
#include <stdlib.h>
#include "linkedlist.h"
// insert in the end of the list
void append(int element, list **l) {
}
// removes a specific element from the list
@jonatasnona
jonatasnona / linkedlist.h
Last active December 19, 2015 13:18
Criar um arquivo chamado linked-list.h
#ifndef _LINKEDLIST_H
#define _LINKEDLIST_H
#define remove(element, l) _list_remove(element, l)
struct node {
int data;
struct node *next;
};
@jonatasnona
jonatasnona / C: Consumer Producer
Created April 12, 2013 13:05
implementação do problema de threads consumidor/produtor
// arquivo: prodcons.c
// descricao: Programa produtor-consumidor com mutex
// Utiliza a biblioteca pthreads.
// para compilar: cc -o phtread pthread.c -lpthread
#include <pthread.h>
#define FALSE 0
#define TRUE 1
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
""""Create "The Matrix" of binary numbers scrolling vertically in your terminal.
original code adapted from juancarlospaco:
- http://ubuntuforums.org/showpost.php?p=10306676
Inspired by the movie: The Matrix
- Corey Goldberg (2013)
Requires:
@jonatasnona
jonatasnona / pre-commit
Created November 22, 2012 13:38 — forked from mrkschan/pre-commit
a pre-commit hook for git to remove trailing whitespace
#!/bin/sh
#
# A git hook script to find and fix trailing whitespace
# in your commits. Bypass it with the --no-verify option
# to git-commit
# Ref - http://is.gd/PerowD
#
if git rev-parse --verify HEAD >/dev/null 2>&1
then
@jonatasnona
jonatasnona / gist:4131215
Created November 22, 2012 13:38 — forked from mxgrn/gist:663933
Git's pre-commit hook to remove trailing whitespaces/tabs
#!/bin/sh
#
# This will abort "git commit" and remove the trailing whitespaces from the files to be committed.
# Simply repeating the last "git commit" command will do the commit then.
#
# Put this into .git/hooks/pre-commit, and chmod +x it.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
@jonatasnona
jonatasnona / gist:4105908
Created November 18, 2012 15:46
Algoritmos: Heapsort
http://sourcecode4u.com/sortings/8-heapsort
http://www.algorithmist.com/index.php/Heap_sort.c
http://www.thelearningpoint.net/computer-science/arrays-and-sorting-heap-sort--with-c-program-source-code
http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Sorting/heapSort.htm
http://rosettacode.org/wiki/Sorting_algorithms/Heapsort#C
http://www.lemoda.net/c/qsort-example/
@jonatasnona
jonatasnona / gist:4051335
Created November 10, 2012 15:04
VIM: Navigation Commands
[Navigation: File]
Ctrl-f #page down
Ctrl-b #page up
Ctrl-d #half page down
Ctrl-u #half page up
Shift-g #end of the file
g #top of the file
Shift-h #top of screen view
Shift-m #middle of screen view