Skip to content

Instantly share code, notes, and snippets.

View web20opensource's full-sized avatar
🎯
Focusing

Mario Ruiz web20opensource

🎯
Focusing
View GitHub Profile
@web20opensource
web20opensource / Number.isNaN.js
Last active August 29, 2015 14:19
polyfill_Number.isNaN
/*check mdn Number.isNaN*/
/*mdn example*/
Number.isNaN = Number.isNaN || function(value) {
return typeof value === "number" && value !== value;
}
var sum = 0; for(var i=0 ; i<1000 ; i++){if (!(i%3) or !(i%5) ) sum+=i} console.log(sum);
var fib = [1,2] , i=0;j=1 , index=2 , sum=2;
while ( fib[j]<4*Math.pow(10,6) ){
fib[index] = fib[i]+fib[j];
if (4*Math.pow(10,6)<=fib[index]) {
break;
}
if ( !(fib[index]%2) )
sum+=fib[index];
@web20opensource
web20opensource / _map.js
Last active August 29, 2015 14:18
mapping with map js javascript
console.time('mapping in js');
var isAType = {};
isAType._array = "[object Array]";
isAType._function = "[object Function]";
isAType._string = "[object String]";
isAType.isFunction = function(fn) {
return Object.prototype.toString.call(fn) === this._function;
}
@web20opensource
web20opensource / palindrome
Last active August 29, 2015 14:17
Check if a given text is a palindrome
var isPalindrome = function(text){
while(text.length!=1){
var firstChar = text.charAt(0);
var lastChar = text.charAt(text.length-1);
if (firstChar===lastChar){
text = text.substr(1,text.length-2);
}
else{
return false;
}
@web20opensource
web20opensource / anaGram
Created March 24, 2015 16:47
Check if the given words are an anagram
(function(){
var first_words = ["iceman","animal"];
var second_words = ["cinema","lamina"];
check_anagrams(first_words, second_words);
function check_anagrams(first_words, second_words) {
// To print results to the standard output please use console.log()
// Example: console.log("Hello world!");
function anagram(first_word,second_word){
firstArr = first_word.split('');
@web20opensource
web20opensource / happyNumbers
Last active August 29, 2015 14:17
The max safe integer representation in js is a Happy Number :) . Number.MAX_SAFE_INTEGER
var myHN = function (){
var happyClosure = function(number){
//started at
var timeStamp = new Date().getTime();
//save original number
var happyNumber = number;
//iterations done
@web20opensource
web20opensource / dabblet.css
Last active August 29, 2015 14:16
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.miniSliderContainer{
padding-bottom: 9em;
width: 100%;
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
@web20opensource
web20opensource / load event attachEvent addEventListener cross-browser
Created February 18, 2015 16:48
using the cross-browser event handler await until the load event happens and execute a callback
function attachEventApart(object, cB, event, onEvent){
if (object.addEventListener){
object.addEventListener(event, cB, false);
}
else if (window.attachEvent){
object.attachEvent(onEvent, cB);
}
else
object[onEvent] = cB;
}
@web20opensource
web20opensource / coffeTesting4.html
Last active December 23, 2015 22:49
mootools + some js stuff for validate the list like a shopping food menu in a restaurant
<!DOCTYPE html>
<html>
<head>
<script src="http://mootools.net/download/get/mootools-core-1.4.5-full-compat-yc.js"></script>
<script src="coffee.js"></script>
<title></title>
<style>
*[id*="S1_98"]{
display:none;
}