Skip to content

Instantly share code, notes, and snippets.

View juandazapata's full-sized avatar

Juanda juandazapata

View GitHub Profile
@juandazapata
juandazapata / gist:5212968
Created March 21, 2013 13:22
MySQL number of connections
mysql -u root -p -e"show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq -c
template = require 'views/templates/hostels/search'
CollectionView= require 'views/base/collection-view'
HostelItemView = require 'views/hostels/item'
module.exports = class HostelSearchView extends CollectionView
className: 'search-results'
itemView: HostelItemView
template: template
listSelector: '.hostels'
fallbackSelector: '.empty-message'
# Include the authorization tokens if we're issuing an API request.
# By doing this, we can call the API and the system will include the authorization headers for us.
# http://api.jquery.com/jQuery.ajaxPrefilter/
$.ajaxPrefilter (options, originalOptions, xhr) ->
is_request_to_api = (options.url.indexOf('<%= Settings.API.URL %>') == 0)
if is_request_to_api
xhr.setRequestHeader('Authorization', "Token token=\"<%= Settings.API.TOKEN %>\", signature=\"<%= Settings.API.SIGNATURE %>\", timestamp=\"<%= Settings.API.TIMESTAMP %>\"")
return
# Get the user location using our API
@juandazapata
juandazapata / .aliases
Last active December 13, 2015 17:39
Vim dotfiles
alias fucking='sudo'
alias be='bundle exec'
alias r='bundle exec rake'
alias fs='bundle exec foreman start'
alias rs='bundle exec rails server'
alias rg='bundle exec rails generate'
alias rc='bundle exec rails console'
alias log='tail -f log/*.log'
alias c='clear'
alias v='vim'
@juandazapata
juandazapata / deploy.rake
Created February 12, 2013 15:10
Deploy task to Heroku
# Pushes to heroku origin
# Call like this:
# >> rake deploy:heroku staging
# >> rake deploy:heroku production
namespace :deploy do
task :heroku do
current_branch = `git branch --no-color | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`.gsub("\n", "").gsub("* ", "")
deploy_to = ARGV[1].try(:dup) || 'staging'
sh "git push #{deploy_to} #{current_branch}:master -f"
@juandazapata
juandazapata / conventions.md
Last active December 12, 2015 05:38
JSON Conventions

URL Conventions

CreatePOST/people
ActionHTTP VerbURL
FindGET/people/123
Find AllGET/people
UpdatePUT/people/123
.logo
+at2x(logo-mams, 74px, 84px)
@juandazapata
juandazapata / mountain_lion_home_brew.md
Created July 26, 2012 15:07
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

After upgrading to Mountain Lion, I got this message when trying to run my local rails server:

Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    Users/user/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby extconf.rb
@juandazapata
juandazapata / Top traffic.md
Created June 21, 2012 16:52
See top traffic
brew install iftop  
ifconfig -l

>>> et0 et1 ....

sudo iftop -i et1
@juandazapata
juandazapata / jquery.selectbox-1.2.js
Created June 14, 2012 16:03 — forked from itsadok/jquery.selectbox-1.2.js
jQuery selectbox plugin
/*
* jQuery selectbox plugin
*
* Copyright (c) 2007 Sadri Sahraoui (brainfault.com)
* Licensed under the GPL license and MIT:
* http://www.opensource.org/licenses/GPL-license.php
* http://www.opensource.org/licenses/mit-license.php
*
* The code is inspired from Autocomplete plugin (http://www.dyve.net/jquery/?autocomplete)
*