Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#define CIDADES 20
int explorado[CIDADES],
localizacoes[CIDADES][CIDADES] =
{
{0, 71, -1, -1, -1, -1, -1, -1, -1, 151, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{71, 0, 75, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, 75, 0, 118, -1, -1, -1, -1, -1, 140, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
@felipap
felipap / game.c
Created September 14, 2012 23:31
joguinho do Brito
#include <stdio.h>
#include <stdlib.h>
struct _element {
struct _element *prev, *next;
int value;
};
struct _column {
struct _column *prev, *next;
@felipap
felipap / gist:4215161
Created December 5, 2012 12:31
php renato
<?php
$HEIGHT = 600;
$WIDTH = 1000;
$xfactor = 2; 5;
$yfactor = 1; 0.001; 0.5;
$CENTER_X = $WIDTH/2;
$CENTER_Y = 400;
<?php
function stickFile ($file, $x, $y)
{
global $dest;
$img = imagecreatefromjpeg($file["tmp_name"]);
$thumb = imagecreatetruecolor(150, 150);
list($width, $height) = getimagesize($file["tmp_name"]);
@felipap
felipap / henon.html
Last active December 19, 2015 17:48
Hénon attractor
<!DOCTYPE html>
<html>
<head>
<style>
canvas { border: 1px solid #DDD; }
</style>
</head>
<canvas width=1500 height=1000></canvas>
<script>
var ctx = document.querySelector('canvas').getContext('2d'),
@felipap
felipap / 4pong.html
Last active December 20, 2015 18:08
Trabalho do Castaneda.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>Pong Game</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.0/css/font-awesome.css" rel="stylesheet">
<style type="text/css">
@felipap
felipap / backpatch.js
Last active December 21, 2015 20:09
Extending patch:true behaviour in a Backbone application, to update only the given attributes.
// Extend PATCH:true option of Backbone.
// When model.save([attrs], {patch:true}) is called:
// - the method is changed to PUT;
// - the data sent is a hash with the passed attributes and their values;
var originalSync = Backbone.sync;
Backbone.sync = function(method, model, options) {
if (method === 'patch' && options.attrs instanceof Array) {
// pop attributes and add their values
while (e = options.attrs.pop())
options.attrs[e] = model.get(e);
@felipap
felipap / painter.coffee
Created October 4, 2013 11:34
A set of functions for basic canvas 2d functionality. I find it easier to manipulate objects abstractly like this, even when using a dedicated render() method for each of them.
painter =
applyCanvasOptions : (context, options) ->
if options.fill is true
context.fillStyle = options.color or 'black'
else
context.strokeStyle = options.color or 'blue'
context.lineWidth = options.width or 1
###### Canvas manipulation functions
@felipap
felipap / animateOnFrameRate.coffee
Created October 6, 2013 20:46
Coffee script version. ;)
window.AnimateOnFrameRate = do ->
# thanks, Paul Irish
window.requestAnimationFrame or
window.webkitRequestAnimationFrame or
window.mozRequestAnimationFrame or
window.oRequestAnimationFrame or
window.msRequestAnimationFrame or
(callback) ->
window.setTimeout callback, 1000/60
@felipap
felipap / max.js
Last active January 17, 2017 19:05
Script for TamperMonkey for maximizing youtube videos.
// ==UserScript==
// @name youtube plz
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match http://www.youtube.com/watch?*
// @match https://www.youtube.com/watch?*
// @copyright 2012+, You
// ==/UserScript==