Skip to content

Instantly share code, notes, and snippets.

@lfborjas
lfborjas / filters.js
Created September 16, 2011 09:05
Backbone conditional filters
/*From: https://github.com/FLOChip/backbone_router_filter*/
_.extend(Backbone.Router.prototype, Backbone.Events, {
before: function(){},
after : function(){},
route : function(route, name, callback) {
Backbone.history || (Backbone.history = new Backbone.History);
var _r = route;
if (!_.isRegExp(route)) route = this._routeToRegExp(route);
Backbone.history.route(route, _.bind(function(fragment) {
var args = this._extractParameters(route, fragment);
@lfborjas
lfborjas / proxy.ru
Created September 10, 2011 03:54
Simple proxy server for developing front-ends for APIs (using rack middleware)
require 'rack'
require 'rack/proxy' #gem install rack-proxy
class Proxy < Rack::Proxy
def rewrite_env(env)
env["HTTP_HOST"] = "my.host.com"
env["SERVER_PORT"] = "80"
env
end
end
#include <stdio.h>
#include <ctime>
#include <iostream>
using namespace std;
int main(){
struct tm* hora1;
struct tm* hora2;
time_t rawtime;
time( &rawtime);
@lfborjas
lfborjas / .vimrc
Created July 26, 2011 22:24 — forked from jeresig/.vimrc
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on

##El flujo

  • El user está autenticado

  • Crearías un tour haciendo POST a /tours.json y eso te devolvería algo similar a esto

    {"tour":{"name":"Fri, 24 Jun 2011","slug":"a44a1f","created_at":"2011-06-24T03:26:19Z","updated_at":"2011-06-24T03:26:19Z","url":"http://pictour.us/tours/a44a1f","id":980191027,"user_id":null,"things":[]}}

  • Ya en posesión del slug de arriba, para subir una foto harías POST a /tours/<slug>/things.json y te devolvería un json como este:

class Book extends Backbone.Model
fullName: ->
"#{@get('title')} by #{@get('author')}"
tempest = new Book
id: 1
title: "The tempest"
author: "William Shakespeare"
$ ->
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and you're using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
gnome-terminal --tab -e "./manage.py celeryd -l DEBUG" --tab -e "./manage.py runserver"
#!/usr/bin/env ruby
%w(rubygems grit json pathname).each{|d| require d}
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
def lcs(s1, s2=nil)
#This i just copied from wikipedia, 'cause, knowing that it was just
#a case of the Longest Common Subsequence problem, it didn't seem
#worthwhile to reinvent the wheel
#http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Longest_common_substring#Ruby
s2 ||= s1.reverse
res=""
num=Array.new(s1.size){Array.new(s2.size)}
len,ans=0
lastsub=0