Skip to content

Instantly share code, notes, and snippets.

View LucasMW's full-sized avatar

Lucas Menezes LucasMW

View GitHub Profile
@LucasMW
LucasMW / bfinterpreter.monga
Last active December 17, 2016 11:11
implements brainfuck using monga
/* BF INTERPRETER IN MONGA
Copyright 25/10/16
Modified 17/12/16
Lucas Menezes */
int sleep(int t);
int exit(int number);
char getchar();
void putchar(int c);
@LucasMW
LucasMW / multi-language code
Last active August 6, 2016 20:50
Program valid in Rust, Ruby, Python, C, C++, Brainfuck, and POSIX Shell
#/*[/**/include <stdio.h>
#define print(_) int main() { if (sizeof('a') > 1) { printf("Hello from C\n"); } else { printf("Hello from C++\n"); } }
#define X */[allow()] macro_rules! p { ($($t:tt)*) => (fn main() { println!("Hello from Rust") }) } p! {
""":"
false || "exec" "echo" "Hello from sh"
" """
print((0 and "Hello from Ruby\n" or "Hello from Python"))
#define Y }/*
#define A ]-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[--->+<]>-----.++[->+++<]>.++++++++++++.---.--.[->+++++<]>-.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.++++++++.+++++.--------.-[--->+<]>--.+[->+++<]>+.++++++++.+[++>---<]>-.*/
--------------------------------------------- -- 001
-- Funcional language with maybe computing -- 002
--------------------------------------------- -- 003
-- 004
-- 005
-- variables are just names -- 006
type Var = String -- 007
-- 008
-- values are integers and functions -- 009
data Value = ValInt Int -- 010
@LucasMW
LucasMW / plotFunctionWithPoints
Created April 24, 2015 01:33
plotFunctionWithPointsAssembly
"-[FunctionPlotter plotFunctionWithPoints:numberOfPoints:withScale:colored:]": ## @"\01-[FunctionPlotter plotFunctionWithPoints:numberOfPoints:withScale:colored:]"
Lfunc_begin0:
.loc 20 13 0 ## /Users/lmenezes/Documents/PUC/VisualizeSpline/VisualizeSpline/FunctionPlotter.m:13:0
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
@LucasMW
LucasMW / GRA_ExisteCaminho.c
Created October 31, 2014 13:37
GRA_ExisteCaminho . Retorna se existe ou não caminho entre os vértices ditos
GRA_tpCondRet GRA_ExisteCaminho(GRA_tppGrafo grafo, int noInicioId, int noFimId)
{
int* ptrIds;
int tam;
int i;
GRA_tpCondRet ret;
ret=GRA_DFS(grafo,&ptrIds,&tam,noInicioId);
if(ret!=GRA_CondRetOK)
return ret;
for(i=0;i<tam;i++)
static void visit(GRA_noGrafo noCorr,int* visited,int tam,int* ordened);
/***************************************************************************
*
* Função: GRA &DFS
* ****/
GRA_tpCondRet GRA_DFS(GRA_tppGrafo grafo, int** refPtrIds, int * tam,int noId)
{
/* vá em cada vértice e imprima suas componentes conexas */
GRA_noGrafo p; //percorredor
/***********************************************************************
*
* $FC Função: GRA &DFS
*
* $ED Descrição da função
* Esta função retorna o um vetor de ids de nós de grafo
* que são o todos os que são posíveis se chegar pelo no recebido.
* $EP Parâmetros
* grafo - ponteiro para a cabeça do grafo a ser impresso
* noId - inteiro para o Id do nó que virará corrente
@LucasMW
LucasMW / gist:9daa00a3b8dde695888b
Created October 10, 2014 20:47
Como pretendo Fazer o prioridades. Atualmente trava no 4 e a prioridade do processo vai an zero
#include<stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#define EVER ;;
#define CPUTIME 50 //Mileseconds
#define ON 1
#define OFF 0
#define DEBUGMSGS OFF
static void filhoHandler (int sinal);