Skip to content

Instantly share code, notes, and snippets.

@niyazpk
niyazpk / gist:4046552
Created November 9, 2012 16:11
JavaScript for Windows8 live tiles
var notifications = Windows.UI.Notifications;
var recurrence = notifications.PeriodicUpdateRecurrence.hour;
var urls = [
new Windows.Foundation.Uri("http://localhost/tile1.xml"),
new Windows.Foundation.Uri("http://localhost/tile2.xml"),
new Windows.Foundation.Uri("http://localhost/tile3.xml"),
new Windows.Foundation.Uri("http://localhost/tile4.xml"),
new Windows.Foundation.Uri("http://localhost/tile5.xml")
];
@niyazpk
niyazpk / gist:2289547
Created April 3, 2012 05:35
Get the server time using JS
$.ajax({
type: 'HEAD',
url: '/',
success: function(data, textStatus, jqXHR){
log( new Date(jqXHR.getResponseHeader('Date')) );
}
});
@niyazpk
niyazpk / gist:1891361
Created February 23, 2012 07:43
Removed color-mappings from Background color animation plugin: http://stackoverflow.com/questions/190560/
(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseIn
if (!(square & 0x88)){
// valid move
}
if (!(square & 0x40)){
// valid move
}
var WHITE_PAWN = 0x01;
var WHITE_KNIGHT = 0x02;
var WHITE_KING = 0x03;
var WHITE_BISHOP = 0x05;
var WHITE_ROOK = 0x06;
var WHITE_QUEEN = 0x07;
var BLACK_PAWN = 0x09;
var BLACK_KNIGHT = 0x0A;
var BLACK_KING = 0x0B;
Decimal 2 = 00000010 Binary
Decimal 1 = 00000001 Binary
Decimal 0 = 00000000 Binary
Decimal -1 = 11111111 Binary
Decimal -2 = 11111110 Binary
Decimal 62 = 0111110 Binary
Decimal 63 = 0111111 Binary
Decimal 64 = 1000000 Binary
Decimal 65 = 1000001 Binary
if (square > 0 && square < 64){
// valid move
}
if (row > 0 && row < 8 && column > 0 && column < 8 ){
// valid move
}