Skip to content

Instantly share code, notes, and snippets.

View acadavid's full-sized avatar

Alejandro Cadavid acadavid

View GitHub Profile
<div id=colombia>
<div id=anqtioquia>
<div id=chigo>
<div id=plaza>
<div id=mesa1></div>
<div id=mesa2></div>
</div>
<div id=otro>
<div id=mesa4></div>
<div id=mesa5></div>
# PostgreSQL. Versions 7.4 and 8.x are supported.
#
# Install the ruby-postgres driver:
# gem install ruby-postgres
# On Mac OS X:
# gem install ruby-postgres -- --include=/usr/local/pgsql
# On Windows:
# gem install ruby-postgres
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
class User < ActiveRecord::Base
has_and_belongs_to_many :products_of_interest, :class_name => "Product"
has_and_belongs_to_many :brands_of_interest, :class_name => "Brand"
end
class Deal < ActiveRecord::Base
belongs_to :brand
belongs_to :product
end
class User < ActiveRecord::Base
has_and_belongs_to_many :products_of_interest, :class_name => "Product"
has_and_belongs_to_many :brands_of_interest, :class_name => "Brand"
end
class Deal < ActiveRecord::Base
belongs_to :brand
belongs_to :product
end
@acadavid
acadavid / about.md
Created August 9, 2011 13:40 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer

Provee

Actividades

- (Void) realizarActividad(Actividad actividad)

Nota: El tipo de dato Actividad, contiene una referencia al usuario si la actividad a realizar requiere de uno. Por esta razón no es necesario un segundo parámetro que indique el usuario.

@acadavid
acadavid / InsertionSort.cpp
Created September 16, 2011 15:46
Código Insertion sort
vector<int> insertion_sort(vector<int> numbers) {
int i,j,key;
for(int j=0; j<numbers.size(); j++) {
int key = numbers[j];
i = j-1;
while(i>=0 && numbers[i]>key) {
numbers[i+1]=numbers[i];
i--;
}
@acadavid
acadavid / gist:1275391
Created October 10, 2011 13:56 — forked from javan/gist:1168475
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@acadavid
acadavid / template.cpp
Created October 11, 2011 22:17
C++ Template
using namespace std;
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
@acadavid
acadavid / CondorcetVoting.cpp
Created October 12, 2011 00:01
CondorcetVoting
void ranks(const string &v, map<char, int> &m){
for(int i=0; i<v.size(); ++i) {
m[v[i]] = -1;
}
int c=0;
for(map<char, int>::iterator it = m.begin(); it != m.end(); it++) {
it->second = c++;
}
}
int winner(vector<string> votes) {