Skip to content

Instantly share code, notes, and snippets.

View ivolivares's full-sized avatar
🤙
Probably coding!

Iván Olivares R. ivolivares

🤙
Probably coding!
View GitHub Profile
@ivolivares
ivolivares / SimplePageScroller.js
Last active December 17, 2015 00:10
Un simple "Page Scroller" en 146 bytes de Javascript. | A simple "Page Scroller" in 146 bytes of Javascript.
$("a[data-go]").on("click",function(event){
var elem = $("#" + $(this).attr("data-go"));
$('html, body').animate({
scrollTop: elem.offset().top
}, 'slow');
event.preventDefault();
});
@ivolivares
ivolivares / random.js
Last active December 23, 2015 02:19
"Perfecto" random de un array.
var arr = [0,1,2,3,4,5,6,7,8,9], // Example array
rand = Math.floor(Math.random() * arr.length); // Formula, where "arrr" = "n" elements.
// Show result
console.log(rand);
@ivolivares
ivolivares / randomString.php
Last active December 23, 2015 10:19
Una cadena de texto aleatoria, perfecto para "contraseñas seguras" (sin entropía obviamente).
<?php
/*
* Random String ();
* Developed by: @ivolivares
*
* Uso: randomString(20);
* Donde: 20 = Cantidad de caracteres o el largo total del texto a generar.
*
*/
function randomString($charactersLength = 30) {
@ivolivares
ivolivares / multi-social-apis.js
Last active December 23, 2015 10:29
Multi-Social-SDKs & APIs. Optimiza tu código obteniendo múltiples APIs sin escribir lo mismo 5 veces.
/*
* Nota: Asegúrate de incluir el "_gaq" de Google Analytics y el "fbAsyncInit" de Facebook antes que esta función.
*
* Algo así para Google Analytics:
* window._gaq = [['_setAccount','UA-00000'],['_trackPageview']];
*
* Algo así para Facebook (con apoyo de jQuery):
*
* $(document).ready(function(){
* function facebookReady(){
// Pre-requisites:
// 1. Device core plugin
// 2. Splashscreen core plugin (3.1.0)
// 3. config.xml: <preference name="AutoHideSplashScreen" value="false" />
// 4. config.xml: <preference name="DisallowOverscroll" value="true" />
function onDeviceReady() {
if (parseFloat(window.device.version) >= 7.0) {
document.body.style.marginTop = "20px";
// OR do whatever layout you need here, to expand a navigation bar etc
/**
* Object descriptor
**/
var a = {
prop1 : 14
}
var descriptorObj1 = Object.getOwnPropertyDescriptor(a, 'prop1');
/**
* The sample usage of ECMA 5 Mozilla Features Implemented in V8
* https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8
* You can use thease new feature of ECMA5 on Node.js as you like.
* because there is no IE :)
* Order is deferent form original wiki.
* Sources are Checked on Node.js v0.5.0(unstable), v0.4.9(stable)
*
* you can execute this file.
* $ node ecma5_on_v8.js
<!DOCTYPE html>
<html>
<link href="style.css" rel="stylesheet" />
<body>
<button id="open">click!</button>
<div id="popup" class="closed"><button id="close">click!</button></div>
</body>
<script src="popup.js"></script>
<script>
var p = document.getElementById('popup');
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
module.exports = function(grunt) {
// Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: [
'source/js/libs/*.js', // All JS in the libs folder