Skip to content

Instantly share code, notes, and snippets.

View mmacedo's full-sized avatar

Michel Pavan Macedo mmacedo

View GitHub Profile
@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;
@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 / 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 / Gemfile
Last active August 29, 2015 14:20
Simula eleição municipal de 2012 sem coligações
gem 'table_print'
Lazy = _.chain;
Lazy.range = function() {
return _.chain(_.range.apply(_, arguments));
};
_.prototype.toArray = function() {
return this.value();
};
@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">
@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 / Func.java
Created November 14, 2013 22:04
Functional Java
public interface Func<TReturn, TArg0> {
public TReturn call(TArg0 arg0);
}
@mmacedo
mmacedo / keyboardEverywhere.js
Created September 6, 2013 05:02
User script that adds shortcuts to Google Translate (updated version)
// ==UserScript==
// @name Google Translate Keyboard Everywhere
// @description 25 keyboard shortcuts (with on-screen help) to use GT at rapid pace.
// @icon http://translate.google.com/favicon.ico
// @version 1.0-20130224
// @namespace http://jakub-g.github.com
// @author http://jakub-g.github.com
// @license Apache 2.0
// @downloadURL https://raw.github.com/jakub-g/greasemonkey-userscripts/master/googleTranslate/keyboardEverywhere.js
// @userscriptsOrg http://userscripts.org/scripts/show/...
@mmacedo
mmacedo / translate.fish
Created August 1, 2013 04:25
Rename file names and contents
#!/usr/bin/env fish
for tool in ack rename perl
if not which $tool >/dev/null
echo You need $tool to run this tool >&2
exit 1
end
end
if [ (count $argv) != 3 ]