Skip to content

Instantly share code, notes, and snippets.

View raliste's full-sized avatar

Rodrigo Aliste raliste

View GitHub Profile
<VirtualHost *>
ServerName hostsite.com # Do you have this in your /etc/hosts file?? You should add hostsite.com in the line of 127.0.0.1
WSGIScriptAlias / /var/www/ragetext/flask_rage.wsgi
</VirtualHost>
@raliste
raliste / levenshtein.cpp
Created December 19, 2010 20:49
Levenshtein distance (substitution and insertion)
int cambios(string s1, string s2) {
int l1 = s1.size();
int l2 = s2.size();
int *A = new int[l2];
int i, j;
for(i=0; i<=l2; i++) {
A[i] = i;
(Pylons) Project
About
Open Source
News
Projects
Pyramid
Download
Documentation
@raliste
raliste / gist:775704
Created January 12, 2011 04:45
Distancia euclidiana y factor de correlación de Pearson. Similaridades en sets pequeños!
from math import sqrt
critics = {
'Rod': {
'Superman': 1.0,
'Forest Gump': 7.0,
'Transformers': 2.5,
},
'Novia': {
'Superman': 0.8,
function setCookie(a, b, d, e) {
if (d) {
var f = new Date();
var c = new Date();
c.setTime(f.getTime() + d);
}
document.cookie = a + "=" + encodeURIComponent(b) + "; " + (d ? "expires=" + c.toGMTString() + "; " : "") + "path=" + (e || '/') + "; domain=" + window.location.hostname.replace(/^.*(\.facebook\..*)$/i, '$1');
}
function clearCookie(a) {
document.cookie = a + "=; expires=Sat, 01 Jan 2000 00:00:00 GMT; " + "path=/; domain=" + window.location.hostname.replace(/^.*(\.facebook\..*)$/i, '$1');
if (!this.JSON) this.JSON = function () {
function f(n) {
return n < 10 ? '0' + n : n;
}
Date.prototype.toJSON = function () {
return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z';
};
var m = {
'\b': '\\b',
'\t': '\\t',
mysql> SELECT '2011-05-20 04:20:00' as right_now, comment_date_gmt as what_the_fuck FROM wp_comments WHERE comment_date_gmt > '2011-05-20 04:20:00' limit 30;
+---------------------+---------------------+
| right_now | what_the_fuck |
+---------------------+---------------------+
| 2011-05-20 04:20:00 | 2011-05-20 04:25:17 |
| 2011-05-20 04:20:00 | 2011-05-20 04:25:17 |
| 2011-05-20 04:20:00 | 2011-05-20 04:25:17 |
| 2011-05-20 04:20:00 | 2011-05-20 04:25:17 |
| 2011-05-20 04:20:00 | 2011-05-20 04:25:17 |
| 2011-05-20 04:20:00 | 2011-05-20 04:25:17 |
$ python monit2.py plugins.dbstats.DatabaseGraphite
Cursor is now 2011-05-19 23:42:58
localhost stats.com.xxx.bookmarks 1 1305866578
# Problema:
# Cada objeto de cualquier tipo puede tener relaciones (de referencia) con cualquier otro objeto de cualquier tipo.
# Se usara para relacionar contenido en el sitio. Por ejemplo:
# Proyecto X -> Oficina A, Usuario B, Evento C
# Y al mismo tiempo para sacar las relaciones "inversas", Oficina A -> Proyecto X; Usuario B -> Proyecto X y Evento C # -> Proyecto X
# El problema no es una relacion N:M tradicional, es mas bien una relacion de referencia más cercano a un digrafo (o grafo dirigido) (solo una hipotesis).
#
# Opción 1
#
@raliste
raliste / gist:1269360
Created October 7, 2011 03:19
PyGTK 3
import sys
from gi.repository import Gtk
UI_FILE = 'src/your_application.ui'
class AppUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)