Skip to content

Instantly share code, notes, and snippets.

View luizdepra's full-sized avatar
🐶

Luiz F. A. de Prá luizdepra

🐶
View GitHub Profile
@luizdepra
luizdepra / main.py
Created January 16, 2023 13:05
Python List Allocation
from dataclasses import dataclass
from functools import wraps
from time import time
@dataclass
class Thing:
pass
@luizdepra
luizdepra / api.c
Last active January 10, 2020 15:00
C Opaque Structure
#include <stdlib.h>
#include "api.h"
#include "internal.h"
api* create_api() {
internal* in = malloc(sizeof(internal));
in->the_api.x = 1;
in->the_api.y = 2;
@luizdepra
luizdepra / main.go
Created December 14, 2015 16:15
How can I insert and extract data from structs dynamically in Go?
package main
import (
"fmt"
"reflect"
"strconv"
"strings"
)
type Data interface{}
@luizdepra
luizdepra / install.bat
Last active January 2, 2016 19:29
Install script for Windows and Linux used for syncing packages and configuration from Sublime Text 3 via Dropbox.
@echo off
:: Change those two varaibles
set DROPBOX_PATH=C:\Users\<YourUserHere>\Dropbox\AppData\SublimeText3
set SUBLIME_PATH=C:\Users\<YourUserHere>\AppData\Roaming\Sublime Text 3
:: Remove default folders if exists
if exist "%SUBLIME_PATH%\Installed Packages" (goto remove_ipkg) else (goto check_pkg)
:remove_ipkg
@luizdepra
luizdepra / mixin_game.cpp
Created February 1, 2013 13:14
A pattern idea using mixins to develop game engines in C++.
#include <iostream>
#include <string>
using namespace std;
// Entity Base Class
class Entity
{
protected:
int _x;
@luizdepra
luizdepra / mapgen.py
Created September 6, 2012 14:17
Map Generator
# -*- coding: utf-8 -*-
# -- MAPGEN.PY --
import sys
import math
import random
class Map:
# consts
_FOUR_DIRECTIONS = [(1, 0), (-1, 0), (0, 1), (0, -1)]
@luizdepra
luizdepra / State.h
Created August 17, 2012 19:51
StateMachine State
#ifndef __STATE_H__
#define __STATE_H__
#include <string>
class State
{
public:
State(const std::string &name, void (*startFunction)(), void (*updateFunction)(float), void (*stopFunction)());
~State();
@luizdepra
luizdepra / State.h
Created August 17, 2012 19:23
StateMachine State
#ifndef __STATE_H__
#define __STATE_H__
#include <string>
class State
{
public:
State(const std::string &name, void (*startFunction)(), void (*updateFunction)(float), void (*stopFunction)());
~State();
@luizdepra
luizdepra / db.py
Created July 11, 2012 18:27
DataBase
from google.appengine.ext import db
class Post(db.Model):
title = db.StringProperty()
slug = db.StringProperty()
date = db.DateTimeProperty(auto_now_add=True)
author = db.StringProperty()
content = db.TextProperty()
category = db.ReferenceProperty(Category, collection_name='posts')
tags = db.ListProperty(db.Key)
@luizdepra
luizdepra / spiralflood.py
Created June 20, 2012 17:08
Spiral Water Flood
# Dont work =(
tiles = []
def spiralFlood(tiles, sx, sy, K, m):
x = y = 0
dx = 0
dy = -1
i = 0
while i < m and i < K*K: