Skip to content

Instantly share code, notes, and snippets.

@victorcastelan
victorcastelan / countdown
Created October 10, 2013 22:17
Countdown javascript auto ajustable
var start = new Date().getTime(),
time = 0,
elapsed = '0.0';
function instance()
{
time += 100;
elapsed = Math.floor(time / 100) / 10;
if(Math.round(elapsed) == elapsed) { elapsed += '.0'; }
@victorcastelan
victorcastelan / LiberarMemoria
Last active December 20, 2015 22:49
Liberar memoria Ubuntu
echo;
echo "Memoria actual...";
echo;
free -m;
sudo sync;
sudo sysctl -w vm.drop_caches=3;
echo "Memoria liberada...";
echo;
echo;
free -m;
// Math.floor
Math.floor(89.938 / 293.3);
Math.floor(83784 / 9289.2);
Math.floor(7 / 60);
// Math.round
Math.round(89.938 / 293.3);
Math.round(83784 / 9289.2);
Math.round(7 / 60);
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Collision 3D</title>
<link rel="stylesheet" href="../include/style.css">
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
@victorcastelan
victorcastelan / requestanimationframe.js
Created July 3, 2013 14:33 — forked from yacafx/utils.js
requestanimationframe.js
/**
* Normalize the browser animation API across implementations. This requests
* the browser to schedule a repaint of the window for the next animation frame.
* Checks for cross-browser support, and, failing to find it, falls back to setTimeout.
* @param {function} callback Function to call when it's time to update your animation for the next repaint.
* @param {HTMLElement} element Optional parameter specifying the element that visually bounds the entire animation.
* @return {number} Animation frame request.
*/
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (window.webkitRequestAnimationFrame ||
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Real Walk</title>
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
@victorcastelan
victorcastelan / Slider.js
Created July 3, 2013 14:32 — forked from yacafx/Slider.js
Slider
function Slider (min, max, value) {
this.min = (min === undefined) ? 0 : min;
this.max = (max === undefined) ? 100 : max;
this.value = (value === undefined) ? 100 : value;
this.onchange = null;
this.x = 0;
this.y = 0;
this.width = 16;
this.height = 100;
@victorcastelan
victorcastelan / dateDiff.php
Created August 24, 2012 03:25
Get a date diff between 2 dates
/*
example:
$count_from = "2010-09-30 00:00:01"; // 24-Hour Format: YYYY-MM-DD HH:MM:SS"
$count_to = date("Y-m-d H:i:s");//today (2012-08-23 00:00:01)
echo datediff("d",$count_from,$count_to);
return: 693 (days)
*/
function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {
/*
@victorcastelan
victorcastelan / clock.sh
Created August 23, 2012 16:41
Muestra un reloj con segundero en la consola (linux)
#/usr/bin/bash
while [ 1 ]; do
printf "\r$(date +%T)";
sleep 1s;
done
@victorcastelan
victorcastelan / procesosHttp.sh
Created August 23, 2012 15:07
Cuenta los procesos httpd activos en el server. Útil para conocer conexiones activas.
#/usr/bin/bash
#Capturamos Ctrl-C para terminar
trap 'echo;echo;echo Proceso terminado Ctrl-C Hasta la vista Baby;echo; exit' SIGINT SIGQUIT;
#procesosHttp.sh
#victorcastelan@gmail.com
pausa=10;
header="\n %-10s %8s %10s %10s %10s\n"
format="\r %-10s %8s %10s %10s %10s"