Skip to content

Instantly share code, notes, and snippets.

@cdmz
cdmz / gifencoder.class.php
Created October 10, 2016 01:05 — forked from allometry/gifencoder.class.php
GIFEncoder Class
<?php
/*
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: GIFEncoder Version 2.0 by László Zsidi, http://gifs.hu
::
:: This class is a rewritten 'GifMerge.class.php' version.
::
:: Modification:
:: - Simplified and easy code,
@cdmz
cdmz / Bubble sort javascript
Created January 28, 2016 23:00
Bubble sort javascript
function bubble_sort(values) {
var length = values.length - 1;
do {
var swapped = false;
for(var i = 0; i < length; ++i) {
if (values[i] > values[i+1]) {
var temp = values[i];
values[i] = values[i+1];
values[i+1] = temp;
swapped = true;
@cdmz
cdmz / insertion_sort javascript
Created January 28, 2016 22:55
insertion_sort javascript
function insertion_sort(values) {
var length = values.length;
for(var i = 1; i < length; ++i) {
var temp = values[i];
var j = i - 1;
for(; j >= 0 && values[j] > temp; --j) {
values[j+1] = values[j];
}
values[j+1] = temp;
}
@cdmz
cdmz / get position mouse javascript
Created January 26, 2016 17:05
get position mouse javascript
$('html').mousemove(function(e){
console.log("X Axis Position = " + e.pageX + " and Y Axis Position = " + e.pageY);
});
@cdmz
cdmz / browser detect javascript
Created January 26, 2016 17:02
browser detect javascript
var browser = function() {
// Return cached result if avalible, else get result then cache it.
if (browser.prototype._cachedResult)
return browser.prototype._cachedResult;
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined';// Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
@cdmz
cdmz / preload images javascript Jquery
Created January 26, 2016 02:30
preload images javascript Jquery
jQuery.preloadImagesInWebPage = function() {
for (var ctr = 0; ctr < arguments.length; ctr++) {
jQuery("<img>").attr("src", arguments[ctr]);
}
}
//Carregando as imagens
$.preloadImages("image1.gif", "image2.gif", "image3.gif");
//verificar se imagem foi carregada.
$('#imageObject').attr('src', 'image1.gif').load(function() {
alert('A imagem foi carregada');
@cdmz
cdmz / multiplicar valores array javascript
Created January 26, 2016 01:46
multiplicar valores array javascript
var squares = [1,2,3,4].map(function (val) {
return val * val;
});
@cdmz
cdmz / get max and min value in array javascript
Created January 26, 2016 01:39
get max and min value in array javascript
var numbers = [-215, 458 ,5, , 120 , 584 , 228 , 400 , 122205, -85411];
var max = Math.max.apply(Math, numbers);
var min = Math.min.apply(Math, numbers);
@cdmz
cdmz / get random item javascript
Created January 26, 2016 01:28
get random item javascript
var arr = [25,477,244,5872,145,8,778,2,21,4];
var random = arr[Math.floor(Math.random() * arr.length)];
@cdmz
cdmz / isNumber javascript
Created January 26, 2016 01:24
isNumber javascript
function isNumber(n){
return !isNaN(parseFloat(n)) && isFinite(n);
}