Skip to content

Instantly share code, notes, and snippets.

View joseph-montanez's full-sized avatar

Joseph Montanez joseph-montanez

View GitHub Profile
@joseph-montanez
joseph-montanez / clock.cpp
Created May 31, 2011 03:51
Read and Write Mapping
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <vector>
#include <stdint.h>
#include <cstring>
#include <string>
#include <fstream>
typedef struct mapformat {
@joseph-montanez
joseph-montanez / Makefile
Created June 3, 2011 06:48
Vala Pong Makefile for Windows
PKGS = \
--pkg gee-1.0 \
--pkg gsl \
--pkg sdl \
--pkg sdl-mixer \
--pkg sdl-image \
--pkg gl \
--pkg glu
LIBS = \
-X -LC:\Windows\System32 \
@joseph-montanez
joseph-montanez / test.cpp
Created June 6, 2011 22:55
lamdba Example
#include <iostream>
int main (int argc, char *argv[]) {
int x = 42;
int y = 99;
auto lambda = [x, &y]() mutable {
x++;
// Because x is not referenced, it will never effect the global x
// however it will be effected inside this same lambda, so running it
// multiple times will result x incremenint, but not the global x
@joseph-montanez
joseph-montanez / main.adb
Created June 18, 2011 00:54
Simple utf8 console based tile map rendering
with Ada.Wide_Text_IO;
procedure Main is
subtype Tile_Width is Wide_String (1 .. 3);
Dot : constant Tile_Width := ". ";
Map : constant array (1 .. 5, 1 .. 5) of Tile_Width :=
(("╔", "═", "═", "═", "╗"),
("║", Dot, Dot, Dot, "║"),
("║", Dot, Dot, Dot, "║"),
("║", Dot, Dot, Dot, "║"),
all:
gnatmake -O3 -gnatv -gnaty main.adb
time ./main
@joseph-montanez
joseph-montanez / Makefile
Created July 14, 2011 15:47
GD versus ImageMagic Resizing an Image
all:
gcc gd-bench.c -lgd -o gd-bench
gcc `MagickWand-config --cflags --cppflags` magick-bench.c -o magick-bench `MagickWand-config --ldflags --libs`
time ./gd-bench
time ./magick-bench
#GD is faster 29% faster
@joseph-montanez
joseph-montanez / Makefile
Created July 27, 2011 06:51
FastCGI example that doesn't work, well kind of
all:
/usr/local/lib/fpc/2.4.4/ppc386 -g fprun.pas;
@joseph-montanez
joseph-montanez / toDouble.hs
Created July 30, 2011 20:52
Learning me a Haskell
{-|
The 'toDouble' will take a string and force it to a Double. On failure the
it will just return 0.00
-}
toDouble :: String -> Double
toDouble x = do
-- try to convert a String to a decimal number, if not fall back to a string,
-- this will prevent haskell from erroring out
case reads x :: [(Double, String)] of
-- if there is a match for any decimal number and an empty string
@joseph-montanez
joseph-montanez / atm.hs
Created July 31, 2011 00:43
ATM Test example in Haskell
import Text.Printf
isInt x = x == fromInteger (round x)
{-|
The 'toDouble' will take a string and force it to a Double. On failure, it
will return 0.00
-}
toDouble :: String -> Double
toDouble x = do
CREATE TABLE `movies`.`movies_movie` (
`id` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`year` SMALLINT NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;