Skip to content

Instantly share code, notes, and snippets.

@codexico
codexico / robot.js
Created December 5, 2012 03:30
xicoloco
var Robot = function (robot) {};
Robot.prototype.onIdle = function (ev) {
var robot = ev.robot;
//search
robot.ahead(4);
robot.rotateCannon(6);
robot.turn(1);
};
@codexico
codexico / robot.js
Created December 5, 2012 03:35 — forked from jsyrek/robot.js
QR-bot-009
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
var rx = robot.position.x;
var ry = robot.position.y;
var aH = robot.arenaHeight;
var aW = robot.arenaWidth;
robot.clone()
};
@codexico
codexico / robot.js
Created December 5, 2012 05:01 — forked from rfloriano/robot.js
[CAELUM TEAM]Megatron
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.clone();
var matched, browser;
// Use of jQuery.browser is frowned upon.
// More details: http://api.jquery.com/jQuery.browser
// jQuery.uaMatch maintained for back-compat
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
//http://tryhandlebarsjs.com/
//{{#list_fl people}}{{firstName}} {{lastName}}{{/list_fl}}
{
people : [
{ firstName: "Yehuda", lastName: "Katz" },
{ firstName: "Carl", lastName: "Lerche" },
{ firstName: "Alan", lastName: "Johnson" }
]
@codexico
codexico / utils.js
Created January 28, 2013 16:44
date utils
//http://stackoverflow.com/questions/7388001/javascript-regex-to-validate-date
//http://jsfiddle.net/mplungjan/Mqh8D/
var isDate = function (str) {
var parms = str.split(/[\.\-\/]/);
var yyyy = parseInt(parms[2],10);
var mm = parseInt(parms[1],10);
var dd = parseInt(parms[0],10);
var date = new Date(yyyy,mm-1,dd,0,0,0,0);
return mm === (date.getMonth()+1) && dd === date.getDate() && yyyy === date.getFullYear();
}
@codexico
codexico / main.js
Created February 19, 2013 20:02
solucao para o fade nos ies
$(function() {
if (jQuery.browser.msie)
$('img[src$=".png"]').each(function() { // must have quotes around .png
this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+this.src+",sizingMethod='scale')";
});
});
@codexico
codexico / pvt.fb.js
Created April 1, 2013 16:52
scrollTo animate Facebook
// http://stackoverflow.com/questions/7193425/how-do-you-animate-fb-canvas-scrollto
function scrollTo(y){
FB.Canvas.getPageInfo(function(pageInfo){
$({y: pageInfo.scrollTop}).animate(
{y: y},
{duration: 1000, step: function(offset){
FB.Canvas.scrollTo(0, offset);
}
});
@codexico
codexico / utils.js
Created April 4, 2013 15:59
getUrlParameter javascript
var getURLParameter = function (name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[undefined,""])[1].replace(/\+/g, '%20'))||null;
};
@codexico
codexico / stringWidth stringWordCrop
Created April 9, 2013 22:48
Crop string by width and word and append " ...".
// http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript
function stringWidth(s, className) {
var c = className || "",
o = $('<div class="' + c + '">' + s + '</div>')
.css({'position': 'absolute', 'float': 'left', 'white-space': 'nowrap', 'visibility': 'hidden'})
.appendTo($('body')),
w = o.width();
o.remove();