Skip to content

Instantly share code, notes, and snippets.

View j0lvera's full-sized avatar
🎯
Focusing

Juan Olvera j0lvera

🎯
Focusing
View GitHub Profile
@j0lvera
j0lvera / smooth.js
Created January 10, 2014 02:53
smooth srcoll
(function($) {
$('a[href^="#"]').click(function(event) {
var id = $(this).attr("href");
var offset = 60;
var target = $(id).offset().top - offset;
$('html, body').animate({scrollTop:target}, 500);
event.preventDefault();
@j0lvera
j0lvera / __request
Created January 23, 2014 19:45 — forked from natos/__request
var request = require('request')
/**
* Handle multiple requests at once
* @param urls [array]
* @param callback [function]
* @requires request module for node ( https://github.com/mikeal/request )
*/
var __request = function (urls, callback) {
// bootstrap
PX.app = new PX.App();
Backbone.history.start();
@j0lvera
j0lvera / pwg.js
Created March 2, 2014 19:46
pwg.js a strong password generator
function pwg(length, option) {
var pw = "",
arr = [],
isOpera = false,
chars = [
"abcdefghijklmnopqrstuvwxyz",
"1234567890",
"!@#$%&*()_+}{:?-=}[;/.,]",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
],
@j0lvera
j0lvera / smooth.js
Created March 20, 2014 19:52
jQuery Smooth Scrool
var smoothScroll = function(id) {
var target = $(id).offset().top - 60;
$('html, body').animate({scrollTop:target}, 500);
};
/*
* Use
*/
$('a#link').on('click', function(e) {
@j0lvera
j0lvera / index.html
Last active August 29, 2015 13:58
simple grid
<div class="row">
<div class="col-1-3">
<img src="something.jpg">
</div>
<div class="col-1-3">
<img src="something.jpg">
</div>
<div class="col-1-3">
<img src="something.jpg">
</div>
@j0lvera
j0lvera / auth.py
Created April 6, 2014 06:42
auth.py
#!/usr/bin/env python
from bottle import route, run, template, static_file, request, parse_auth, auth_basic
from redis import StrictRedis as Redis
from cork import Cork
from hashids import Hashids
from passlib.hash import pbkdf2_sha256
incr1 = Hashids(salt="Eehu6laucelohh3b", min_length="16")
incr2 = Hashids(salt="Phiejapie2ahr9wa", min_length="8")

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@j0lvera
j0lvera / intro.md
Created April 21, 2014 05:41 — forked from gschema/intro.md

Basic JavaScript MVC Implementation

Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.

How Web MVC typically works

Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.

At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).

@j0lvera
j0lvera / 0_reuse_code.js
Created April 27, 2014 23:34
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console