Skip to content

Instantly share code, notes, and snippets.

View mmacedo's full-sized avatar

Michel Pavan Macedo mmacedo

View GitHub Profile
@mmacedo
mmacedo / Func.java
Created November 14, 2013 22:04
Functional Java
public interface Func<TReturn, TArg0> {
public TReturn call(TArg0 arg0);
}
@mmacedo
mmacedo / test_url_regex.rb
Last active December 31, 2015 19:48
Script I was using to test regex to match urls
#!/usr/bin/env ruby
require 'awesome_print'
r = %r{ \A
(?:(?<protocol>http)://)?
(?<domain>(?:[a-z\d-]+\.)+[a-z\d]{2,})
(?:
/
(?<path>(?:[a-z\d._\-+,%&()!'~&=:]+\/)*[a-z\d._\-+,%&()!'~&=:]+)
@mmacedo
mmacedo / gradient.html
Created July 8, 2014 05:32
Linear gradient for any two points
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Alignment</title>
<meta name="author" content="Michel Pavan Macedo">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
Lazy = _.chain;
Lazy.range = function() {
return _.chain(_.range.apply(_, arguments));
};
_.prototype.toArray = function() {
return this.value();
};
@mmacedo
mmacedo / Gemfile
Last active August 29, 2015 14:20
Simula eleição municipal de 2012 sem coligações
gem 'table_print'
@mmacedo
mmacedo / compact.fish
Created September 3, 2015 14:43
Compact porn stash
#!/usr/bin/env fish
set max_width 320
set input_folder ~/Videos
set output_folder ~/compressed
function downsample
set file $argv[1]
set input $input_folder/$file
@mmacedo
mmacedo / astar.js
Last active September 8, 2015 17:48
Simple A* with JavaScript
#!/usr/bin/env node
var Pathfinding = Object.create(null);
Pathfinding.Node = function(value) {
this.value = value;
this.neighbors = [];
};
Pathfinding.Node.prototype.reset = function() {
@mmacedo
mmacedo / BH2.java
Last active September 8, 2015 22:10
Trabalho de IA
package blackhawk;
import java.util.*;
import static robocode.util.Utils.normalRelativeAngleDegrees;
public class BH2 extends robocode.Robot {
private class Point {
private double x;