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 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>

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
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
@j0lvera
j0lvera / .vimrc
Created May 5, 2014 21:49
.vimrc on mac
set nocompatible
" set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
nmap <leader>l :set list!<CR>
" set listchars=tab:▸\ ,eol:¬
" pathogen
call pathogen#infect()
call pathogen#helptags()
@j0lvera
j0lvera / $.3.js
Created May 10, 2014 16:26 — forked from ofca/$.3.js
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
mkdir heroku
cd heroku/
virtualenv --no-site-packages env
source env/bin/activate
pip install bottle gevent
pip freeze > requirements.txt
cat >app.py <<EOF
import bottle
import os
@j0lvera
j0lvera / app.py
Created May 26, 2014 18:17
seoapp
#!/usr/bin/env python
# bottle.py boilerplate project
from bottle import route, run, template, static_file, request, response
from bs4 import BeautifulSoup
import requests, simplejson as json, webbrowser, os, lxml, re
# the decorator
def enable_cors(fn):
def _enable_cors(*args, **kwargs):