Archivo

Entradas Etiquetadas ‘javascript’

Processing.js

jueves, 10 de junio de 2010 Albertux 1 comentario

Processing.js

Processing.js is an open programming language for people who want to program images, animation, and interactions for the web without using Flash or Java applets. Processing.js uses Javascript to draw shapes and manipulate images on the HTML5 Canvas element. The code is light-weight, simple to learn and makes an ideal tool for visualizing data, creating user-interfaces and developing web-based games.

Processing IDE:

Let’s play:

Examples on the Web:
http://processingjs.org/learning

Website: http://processingjs.org/

Categories: web Tags: ,

Aardvark

jueves, 10 de junio de 2010 Albertux Sin comentarios

Aardvark

Things You Can Do With Aardvark:

  • Clean up unwanted banners and surrounding “fluff,” especially prior to printing a page
  • See how the page is created, block by block
  • View the source code of one or more elements

Project page: http://karmatics.com/aardvark/

Download Firefox Extension:
https://addons.mozilla.org/en-US/firefox/addon/4111/

Categories: web Tags:

Fixing the Time

domingo, 7 de diciembre de 2008 Albertux Sin comentarios

Fixing the Time

function total(year) {
  var seconds = 365 * 24 * 60 * 60; //Normal Year;
  var plus = 24 * 60 * 60; // Leap year have one more day
  var leap = false;
  if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) leap = true;
  if (leap) seconds += plus;
  if (year == 1972) seconds += 2;
  if (year > 1972 && year < 1980) seconds += 1;
  if (year > 1980 && year < 1984) seconds += 1;
  if (year > 1988 && year < 1991) seconds += 1;
  if (year > 1991 && year < 1996) seconds += 1;
  if (year > 1996 && year < 1999) seconds += 1;
  if (year == 1985 || year == 1987 || year == 2005 || year == 2008) seconds += 1;
  document.write('Year: '+year+', Total of secods: '+seconds+'<br />');
}
total(1972);
total(1975);
total(1980);
total(1981);
total(2004);
total(2005);
total(2006);
total(2007);
total(2008);
total(2009);

Result:
Year: 1972, Total of secods: 31622402
Year: 1975, Total of secods: 31536001
Year: 1980, Total of secods: 31622400
Year: 1981, Total of secods: 31536001
Year: 2004, Total of secods: 31622400
Year: 2005, Total of secods: 31536001
Year: 2006, Total of secods: 31536000
Year: 2007, Total of secods: 31536000
Year: 2008, Total of secods: 31622401
Year: 2009, Total of secods: 31536000

Leap Second (http://en.wikipedia.org/wiki/Leap_second)
Leap Years (http://en.wikipedia.org/wiki/Leap_year)

Categories: security, web Tags: , , ,

CSS and MSIE

lunes, 1 de septiembre de 2008 Albertux Sin comentarios

CSS and MSIE

MSIE (Microsoft Internet Explorer) CSS Hack:

.somediv {
    height: 15px; /* all browsers */
    #height: 20px; /* all IE Browser */
    _height: 25px; /* only IE6 Browser */
}

MSIE usa comentarios condicionales: (http://msdn.microsoft.com/en-us/library/ms537512.aspx)

 <!--[if IE 6]>
    <script src="js/iefix.js" type="text/javascript"></script>
    <link rel="stylesheet"  href="css/iefix.css" type="text/css"></style>
    <div> some html code </div>
<![endif]-->

En este ejemplo si se usa IE6 agrega este codigo:

<script src="js/iefix.js" type="text/javascript"></script>
<link rel="stylesheet"  href="css/iefix.css" type="text/css"></style>
<div> some html code </div>

Para los navegadores viejos (MSIE) soporta :hover, :active y :focus:
http://www.xs4all.nl/~peterned/csshover.html

<style type="text/css">
    body {
        behavior:url("csshover.htc");
    }
</style>

Hacer que MSIE sea compatible con los estándares. Arregla algunos detalles del HTML y CSS y hace PNG transparentes funciona correctamente en IE5 y IE6 http://code.google.com/p/ie7-js/

Categories: web Tags: ,

Safe and Dirty Remote XMLHttpRequest

miércoles, 27 de agosto de 2008 Albertux 2 comentarios

Safe and Dirty Remote XMLHttpRequest Algunas veces necesitamos que el XMLHttpRequest funcione en diferentes dominios, una solucion simple, necesitas JavaScript y Perl:

El XMLHttpRequest(); ejemplo:

var req = new XMLHttpRequest() // IE7, Firefox, Safari, Opera
req.open('GET', 'http://localhost/cgi-bin/remote.pl?url='+url, false);
req.send(null);

Para hacer que funcione usamos remote.pl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
use LWP::UserAgent;
use CGI qw(:standard);
print "Content-type: text/plain\n";
my $url = param ('url');
$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/8.0");
$req = HTTP::Request->new(GET => $url);
$req->header('Accept' => 'text/html');
$res =$ua->request($req);
if ($res->is_success) {
	$page = $res->content;
} else {
	$page = "error";
} print $page;

Aqui un ejemplo:

El remote.pl se puede implementar mucho mejor (metodos GET y POST, parametros y sus valores).

Categories: web Tags: ,